public void Fall()
 {
     if (!isCollideFloor)
     {
         mario.SetPosition(mario.Bounds.X, mario.Bounds.Y + SEVEN);
     }
     else
     {
         isCollideUnder = false;
         EndJump();
     }
 }
Example #2
0
        public void OnCollisionResponse(IPlayer player, CollisionSide side)
        {
            if (player.IsDead || mario.IsDead)
            {
                return;
            }
            switch (side)
            {
            case CollisionSide.Bottom:
                //((Mario)player).stateMachine.DamageMario();
                marioPhysics.velocity.Y  = ZERO;
                marioPhysics.velocity.Y += ONE_HUNDRED_FIFTY;
                state.HandleJump();
                mario.SetPosition(mario.Bounds.X, (player.Bounds.Y - mario.Bounds.Height));
                if (this.mario.Tag == 0)
                {
                    Score.marioScore += 1000;
                }
                else
                {
                    Score.luigiScore += 1000;
                }
                if (((Mario)player).stateMachine.StarPowered)
                {
                    state.DamageMario();
                }
                break;

            case CollisionSide.Top:
                if (state.CurrentMovement.Equals(MarioStateMachine.MarioMovement.Die) || ((Mario)player).stateMachine.CurrentMovement.Equals(MarioStateMachine.MarioMovement.Die))
                {
                    return;
                }
                if (!((Mario)player).stateMachine.CurrentState.Equals(MarioStateMachine.MarioState.Small) || ((Mario)player).stateMachine.StarPowered)
                {
                    state.DamageMario();
                }
                mario.SetPosition(mario.Bounds.X, (player.Bounds.Y + player.Bounds.Height));
                break;

            case CollisionSide.Left:
                if (((Mario)player).stateMachine.StarPowered)
                {
                    state.DamageMario();
                }
                if (mario.Tag == 1)
                {
                    marioPhysics.velocity.X = marioPhysics.velocity.X / 10.0f;
                }
                mario.SetPosition(player.Bounds.X + player.Bounds.Width, mario.Bounds.Y);
                break;

            case CollisionSide.Right:
                if (((Mario)player).stateMachine.StarPowered)
                {
                    state.DamageMario();
                }
                if (mario.Tag == 1)
                {
                    marioPhysics.velocity.X = marioPhysics.velocity.X / 10.0f;
                }
                mario.SetPosition(player.Bounds.X - mario.Bounds.Width, mario.Bounds.Y);

                break;
            }
        }