Beispiel #1
0
        public override void OnCheckCollision(List <Collider> colliders)
        {
            foreach (Collider collider in colliders)
            {
                Vector2 penetrationVector = Collision.CheckCollision(this, collider);

                if (collider.TileGid == 38 || collider.TileGid == 39 || collider.TileGid == 40)
                {
                    if (SwinGame.KeyDown(KeyCode.vk_DOWN) || Velocity.Y < 0)
                    {
                        continue;
                    }
                }

                if (penetrationVector != null)
                {
                    Position -= penetrationVector;

                    if (!MathUtilities.ApproximatelyEqual(penetrationVector.X, 0))
                    {
                        Velocity.X = 0;
                    }

                    if (!MathUtilities.ApproximatelyEqual(penetrationVector.Y, 0))
                    {
                        Velocity.Y = 0;
                        if (penetrationVector.Y > 0)
                        {
                            OnGround = true;
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public virtual void OnCheckCollision(List <Collider> colliders)
        {
            foreach (Collider collider in colliders)
            {
                Vector2 penetrationVector = Collision.CheckCollision(this, collider);

                if (penetrationVector != null)
                {
                    Position -= penetrationVector;

                    if (!MathUtilities.ApproximatelyEqual(penetrationVector.X, 0))
                    {
                        Velocity.X = 0;
                    }

                    if (!MathUtilities.ApproximatelyEqual(penetrationVector.Y, 0))
                    {
                        Velocity.Y = 0;
                        if (penetrationVector.Y > 0)
                        {
                            OnGround = true;
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public void ApproximateEqualTrueTest()
        {
            float left = 5.0f, right = 10.0f;
            bool  result = MathUtilities.ApproximatelyEqual(left, right, 5.0f);

            Assert.IsTrue(result);
        }