Ejemplo n.º 1
0
        private void HandleCollisions()
        {
            List <CollisionEvent> collisionEvents;

            isOnGround = false;

            while ((collisionEvents = collisionHandler.GetCollisions(this)).Count > 0)
            {
                CollisionEvent collisionEvent = collisionEvents.First();

                if (collisionEvent.CollisionSide == CollisionSide.Horizontal)
                {
                    Move((int)-collisionEvent.CollisionAmount.X, 0);
                }
                else if (collisionEvent.CollisionSide == CollisionSide.Vertical)
                {
                    Move(0, -(int)collisionEvent.CollisionAmount.Y);
                    isOnGround = true;
                }
            }

            if (!isOnGround)
            {
                isOnGround = collisionHandler.GetCollisions(new PlayerGroundCollider(this)).Count > 0;
            }
        }
Ejemplo n.º 2
0
        private void StopConditions()
        {
            var collisions = collisionHandler.GetCollisions(owner);

            if (collisions.Any(c => c.CollisionSide == CollisionSide.Horizontal) || Vector2.Distance(startPosition, owner.Position.ToVector2()) > DashDistance)
            {
                active = false;
            }
        }