Exemplo n.º 1
0
        public void Move(List <Rectangle> platforms)
        {
            PossibilityMove.RecalculatePossibilitys(this, platforms);
            var newX = GoAbility.RecalculateX(this, PossibilityMove);
            var newY = JumpAbility.RecalculateY(this, PossibilityMove);

            Location = new Rectangle(new Point(newX, newY), Location.Size);
        }
Exemplo n.º 2
0
        public Player(Point startLocation)
        {
            PossibilityMove = new PossibilityMove();
            var PlayerSize = PlayerImages.standFrames[0].Size;

            Location            = new Rectangle(startLocation, PlayerSize);
            CurrentTypeMovement = MoveType.Stand;
            JumpAbility         = new JumpAndFall();
            GoAbility           = new RightAndLeft();
        }
Exemplo n.º 3
0
 public int RecalculateX(Player player, PossibilityMove possibility)
 {
     if (player.CurrentTypeMovement == MoveType.Stand)
     {
         return(player.Location.Left);
     }
     if (player.CurrentTypeMovement == MoveType.Right)
     {
         return(possibility.RightWall.HasValue
                                 ? possibility.RightWall.Value.Left - player.Location.Width
                                 : player.Location.Left + Config.PlayerGoDelta);
     }
     if (player.CurrentTypeMovement == MoveType.Left)
     {
         return(possibility.LeftWall.HasValue
                                 ? possibility.LeftWall.Value.Right
                                 : player.Location.Left - Config.PlayerGoDelta);
     }
     return(player.Location.Left);
 }
Exemplo n.º 4
0
 public int RecalculateY(Player player, PossibilityMove possibility)
 {
     if (possibility.Floor.HasValue && IsFalling)
     {
         IsFalling         = IsJumping = false;
         CurrentJumpHeight = 0;
         JumpCount         = 0;
         return(possibility.Floor.Value.Top - player.Location.Height);
     }
     if (CurrentJumpHeight >= Config.MaxJumpHeight)
     {
         CurrentJumpHeight = 0;
         IsJumping         = false;
         IsFalling         = true;
     }
     if (!possibility.Floor.HasValue && !IsJumping)
     {
         IsFalling = true;
     }
     if (IsJumping)
     {
         if (possibility.Ceiling.HasValue)
         {
             IsFalling         = true;
             IsJumping         = false;
             CurrentJumpHeight = 0;
             return(possibility.Ceiling.Value.Bottom);
         }
         CurrentJumpHeight += Config.PlayerJumpDelta;;
         return(player.Location.Top - Config.PlayerJumpDelta);;
     }
     if (IsFalling)
     {
         return(player.Location.Top + Config.PlayerJumpDelta);
     }
     ;
     return(player.Location.Top);
 }