public Player(Vector2 position) : base(position) { strategyMovePlayer = null; Keys = 0; Score = 0; Position = position; Speed = Vector2.Zero; Active = true; CurrentEntityStates = new HashSet <EntityStates>(); CurrentEntityStates.Add(EntityStates.OnAir); }
public void Move(GameTime gameTime, Map map) { Vector2 nextPosition = GetNextPosition(gameTime); Vector2 playerMovement = nextPosition - Position; if (playerMovement.X > 0 && playerMovement.Y > 0) { strategyMovePlayer = new StrategyMovePlayerRightDown(); } else if (playerMovement.X > 0 && playerMovement.Y < 0) { strategyMovePlayer = new StrategyMovePlayerRightUp(); } else if (playerMovement.X > 0) { strategyMovePlayer = new StrategyMovePlayerRight(); } else if (playerMovement.X < 0 && playerMovement.Y > 0) { strategyMovePlayer = new StrategyMovePlayerLeftDown(); } else if (playerMovement.X < 0 && playerMovement.Y < 0) { strategyMovePlayer = new StrategyMovePlayerLeftUp(); } else if (playerMovement.X < 0) { strategyMovePlayer = new StrategyMovePlayerLeft(); } else if (playerMovement.Y > 0) { strategyMovePlayer = new StrategyMovePlayerDown(); } else if (playerMovement.Y < 0) { strategyMovePlayer = new StrategyMovePlayerUp(); } else { strategyMovePlayer = null; } if (strategyMovePlayer != null) { strategyMovePlayer.Move(this, nextPosition, map); } }