public void CalculateTransforms_BeforeCollisionCheck() { SceneGraph graph = BuildSceneGraph(); Vector2 parentPosition = new Vector2(32, 64); GameObject obj = new GameObject(); obj.Position = parentPosition; obj.NoClip = false; obj.SetCollisionSize(16, 16); Vector2 childPosition = new Vector2(96, 128); GameObject childObj = new GameObject(); childObj.Position = childPosition; childObj.NoClip = false; childObj.SetCollisionSize(16, 16); obj.AddChild(childObj); GameObjectCounter collisionObj = new GameObjectCounter(); collisionObj.Position = parentPosition + childPosition; collisionObj.NoClip = false; collisionObj.SetCollisionSize(16, 16); graph.Add(obj); graph.Add(collisionObj); graph.Update(); Assert.That(collisionObj.Stats.CollisionCount, Is.EqualTo(1)); }
public void IgnoreCollision_NoClip() { SceneGraph graph = BuildSceneGraph(); GameObjectCounter obj1 = new GameObjectCounter() { NoClip = true }; obj1.SetCollisionSize(32, 32); graph.Add(obj1); GameObjectCounter obj2 = new GameObjectCounter() { NoClip = false }; obj2.SetCollisionSize(32, 32); graph.Add(obj2); graph.Update(); Assert.That(GetObjectTotals(graph).CollisionTestCount, Is.EqualTo(0)); Assert.That(GetObjectTotals(graph).CollisionCount, Is.EqualTo(0)); }
public void SpawnAtMe_Position() { SceneGraph graph = BuildSceneGraph(); Vector2 objPosition = new Vector2(32, 64); GameObjectCounter obj = new GameObjectCounter(); obj.Position = objPosition; GameObject childObj = new GameObject(); childObj.Position = new Vector2(16, 16); childObj.SceneGraph = graph; obj.AddChild(childObj); graph.Add(obj); graph.Update(); GameObjectCounter spawn = new GameObjectCounter(); childObj.SpawnAtMe(spawn); graph.Update(); Assert.That(spawn.Position, Is.EqualTo(childObj.AbsolutePosition)); Assert.That(spawn.Position, Is.EqualTo(new Vector2(48f, 80f))); }
public void Draw_SkipOffScreen() { SceneGraph graph = BuildSceneGraph(); GameObject obj = new GameObjectCounter(); obj.Position = new Vector2(-33f, -33f); graph.Add(obj); graph.Update(); graph.Draw(null); Assert.That(GetObjectTotals(graph).DrawCount, Is.EqualTo(0)); Assert.That(graph.NodesCulled, Is.EqualTo(1)); }
public void SpawnAtMe() { ISceneGraph graph = CreateSceneGraphScaffolding(); Vector2 objPosition = new Vector2(32, 64); GameObjectCounter obj = new GameObjectCounter(); obj.SceneGraph = graph; obj.Position = objPosition; GameObjectCounter spawn = new GameObjectCounter(); obj.SpawnAtMe(spawn); Assert.That(graph.RootGraph.Contains(spawn)); }
// Start is called before the first frame update void Start() { playAgainPanel = GameObject.Find("PlayAgainPanel"); playerUIPanel = GameObject.Find("PlayerUIPanel"); gameConditionText = playAgainPanel.GetComponentsInChildren <Text>() .ToList() .Find(text => text != null && text.gameObject.name.Equals("GameConditionText")); playerLifeManager = FindObjectOfType <PlayerLifeManager>(); asteroidSpawner = FindObjectOfType <AsteroidSpawner>(); gameObjectCounter = FindObjectOfType <GameObjectCounter>(); playerLifeManager.playerUIPanel = playerUIPanel; playAgainPanel.SetActive(false); playerUIPanel.SetActive(false); }
public void Intersects_CallOnCollision() { GameObjectCounter obj1 = new GameObjectCounter() { NoClip = false }; obj1.SetCollisionSize(32, 32); GameObject obj2 = new GameObject() { NoClip = false }; obj2.SetCollisionSize(32, 32); obj1.OnObjectCollision(obj2); Assert.That(obj1.Stats.CollisionCount, Is.EqualTo(1)); }
public void LockToMap_BeforeCollisionCheck() { SceneGraph graph = BuildSceneGraph(); GameObjectCounter obj = new GameObjectCounter(); obj.NoClip = false; obj.Position = new Vector2(0, 0); obj.SetCollisionSize(16, 16); graph.Add(obj); GameObject offScreen = new GameObject(); offScreen.NoClip = false; offScreen.Position = new Vector2(-32, -32); offScreen.SetCollisionSize(16, 16); graph.Add(offScreen); //LockToMap should be called before collision checking graph.Update(); Assert.That(obj.Stats.CollisionCount, Is.EqualTo(1)); }
// Start is called before the first frame update void Start() { gameObjectCounter = FindObjectOfType <GameObjectCounter>(); StartCoroutine(CheckIfUfoCanSpawn()); }