Example #1
0
        private void ProcessCollisionsRecursive(IList <GameObject> layer, GameObject caller)
        {
            for (int x = 0; x < layer.Count; x++)
            {
                GameObject node = layer[x];
                //Don't check for collisions with noclip objectws or with the object you are checking
                if (!node.NoClip && !caller.NoClip && node != caller)
                {
                    if (node.Intersects(caller))
                    {
                        caller.OnObjectCollision(node);
                        //TODO: Should we call OnCollision For both objects? (both fireballs should explode)
                    }
                }

                ProcessCollisionsRecursive(node.Children, caller);
            }
        }
Example #2
0
        public void Intersects_False()
        {
            GameObject obj1 = new GameObject() { NoClip = false };
            obj1.SetCollisionSize(32, 32);
            obj1.Position = new Vector2(128f, 128f);
            GameObject obj2 = new GameObject() { NoClip = false };
            obj2.SetCollisionSize(32, 32);
            obj2.Position = new Vector2(32f, 32f);

            Assert.That(!obj1.Intersects(obj2));
            Assert.That(!obj2.Intersects(obj1));
        }
Example #3
0
        public void Intersects()
        {
            GameObject obj1 = new GameObject() { NoClip = false };
            obj1.SetCollisionSize(32, 32);
            GameObject obj2 = new GameObject() { NoClip = false };
            obj2.SetCollisionSize(32, 32);

            Assert.That(obj1.Intersects(obj2));
            Assert.That(obj2.Intersects(obj1));
        }