예제 #1
0
        public void ResolveThreeColliders_ShouldTriggerOnCollisionTwoTimeForEachObject()
        {
            int firstCounter = 0, secondCounter = 0, thirdCounter = 0;

            var firstObject = new TestObject
            {
                Layer           = 1,
                HasCollider     = true,
                Position        = new Vector2D(0, 0),
                FireOnCollision = () => firstCounter++
            };

            firstObject.AddComponent <RigidBody2D>().Velocity = Vector2D.Zero;

            var secondObject = new TestObject
            {
                Layer           = 1,
                HasCollider     = true,
                Position        = new Vector2D(0, 0),
                FireOnCollision = () => secondCounter++
            };

            secondObject.AddComponent <RigidBody2D>().Velocity = Vector2D.Zero;

            var thirdObject = new TestObject
            {
                Layer           = 1,
                HasCollider     = true,
                Position        = new Vector2D(0, 0),
                FireOnCollision = () => thirdCounter++
            };

            thirdObject.AddComponent <RigidBody2D>().Velocity = Vector2D.Zero;

            CollisionHandler.ResolveCollisions(new[] { firstObject, secondObject, thirdObject });

            firstCounter.Should().Be(2);
            secondCounter.Should().Be(2);
            thirdCounter.Should().Be(2);
        }