diff --git a/demo/Blackholio/client-unity/Assets/PlayModeTests/PlayModeExampleTest.cs b/demo/Blackholio/client-unity/Assets/PlayModeTests/PlayModeExampleTest.cs index 6684c2dc924..09d5622dd99 100644 --- a/demo/Blackholio/client-unity/Assets/PlayModeTests/PlayModeExampleTest.cs +++ b/demo/Blackholio/client-unity/Assets/PlayModeTests/PlayModeExampleTest.cs @@ -15,7 +15,7 @@ public class PlayModeExampleTest { - // [UnityTest] - This won't work until we have reconnections + [UnityTest] public IEnumerator SimpleConnectionTest() { PlayerPrefs.DeleteAll(); @@ -84,7 +84,7 @@ public IEnumerator CreatePlayerAndTestDecay() // Standing still should decay a bit PlayerController.Local.EnableTestInput(); - while (foodEaten < 200) + while (foodEaten < 50) { Debug.Assert(circle != null, nameof(circle) + " != null"); var ourEntity = GameManager.Conn.Db.Entity.EntityId.Find(circle.EntityId); @@ -116,6 +116,11 @@ public IEnumerator CreatePlayerAndTestDecay() Debug.Assert(foodEntity != null, nameof(foodEntity) + " != null"); Debug.Assert(ourNewEntity != null, nameof(ourNewEntity) + " != null"); var toThisFood = (Vector2)foodEntity.Position - (Vector2)ourNewEntity.Position; + // We have to go slow for the first few pieces of food otherwise we can "hop" over it + if (foodEaten < 10) + { + toThisFood = toThisFood.normalized * 0.5f; + } PlayerController.Local.SetTestInput(toThisFood); } @@ -131,7 +136,7 @@ public IEnumerator CreatePlayerAndTestDecay() Debug.Assert(massEnd < massStart, "Mass should have decayed"); } - // [UnityTest] - This won't work until we have reconnections + [UnityTest] public IEnumerator OneOffTest1() { var connected = false; @@ -176,7 +181,7 @@ public IEnumerator OneOffTest1() Debug.Log($"id: {players[0].PlayerId} Username: {players[0].Name}"); } - // [UnityTest] - This won't work until we have reconnections + [UnityTest] public IEnumerator OneOffTest2() { var connected = false; @@ -220,7 +225,7 @@ public IEnumerator OneOffTest2() Debug.Log($"id: {players[0].PlayerId} Username: {players[0].Name}"); } - //[UnityTest] + [UnityTest] public IEnumerator ReconnectionViaReloadingScene() { var connected = false; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/GameManager.cs b/demo/Blackholio/client-unity/Assets/Scripts/GameManager.cs index 018ddf69fb9..e56bddc82e0 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/GameManager.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/GameManager.cs @@ -29,6 +29,9 @@ public class GameManager : MonoBehaviour private void Start() { + // Clear game state in case we've disconnected and reconnected + Entities.Clear(); + Players.Clear(); Instance = this; Application.targetFrameRate = 60;