public void Left(Mario mario) // walk left if facing left, stand left if facing right. { if (mario.Parameters.IsLeft) { mario.ChangeToWalk(); } else { mario.Parameters.IsLeft = true; } }
public void Right(Mario mario) // walk right if facing right, stand right if facing left. { if (mario.Parameters.IsLeft) { mario.Parameters.IsLeft = false; } else { mario.ChangeToWalk(); } }
public void CollideWithBlock(bool hitBottomOrTop, bool movingUp) { if (hitBottomOrTop && movingUp) // hit block's bottom { if (Mario.MarioState.GetActionType == MarioState.ActionType.Crouch) { Mario.Parameters.SetVelocity(0, 0); } else if (Mario.MarioState.GetActionType == MarioState.ActionType.Walk) { Mario.Parameters.SetVelocity(Mario.XVelocity, 0); } else if (GetAction == MarioState.ActionType.Other && Win) { Mario.ChangeToWalk(); Mario.MarioState.LockOrUnlock(true); Parameters.SetVelocity(Mario.XVelocity, 0); } else { Mario.ChangeToIdle(); } } else { if (!hitBottomOrTop)// hit left or right side { Parameters.SetVelocity(0, Parameters.Velocity.Y); float x = Parameters.IsLeft ? 2 : -2; //Console.WriteLine("Mario Position before mdification = " + GetMaxPosition()); Parameters.SetPosition(Parameters.Position.X + x, Parameters.Position.Y); } else if (Parameters.Velocity.Y < 0) //stand on the block { Mario.ChangeToFalling(); Parameters.SetPosition(Parameters.Position.X, Parameters.Position.Y + 1); Parameters.SetVelocity(Math.Abs(Parameters.Velocity.X), -Parameters.Velocity.Y); } } }