public Point GetMapSize(int level) { return(TerrainManager.GetMapSize(level)); }
public static void ProcessPlayerMovement(GameTime gameTime) { if (gameTime.TotalGameTime.TotalMilliseconds - MainGame.GetPlayer.LastUpdate >= MainGame.GetPlayer.MovementTimeLimit && !MainGame.GetPlayer.MoveAllowed) { MainGame.GetPlayer.MoveAllowed = true; } if (!MainGame.GetPlayer.MoveAllowed) { return; } Point newGridPosition = MainGame.GetPlayer.GridPosition; if (Keyboard.GetState().IsKeyDown(Keys.Up)) { newGridPosition.Y -= 1; } else if (Keyboard.GetState().IsKeyDown(Keys.Down)) { newGridPosition.Y += 1; } else if (Keyboard.GetState().IsKeyDown(Keys.Left)) { newGridPosition.X -= 1; } else if (Keyboard.GetState().IsKeyDown(Keys.Right)) { newGridPosition.X += 1; } else { return; // No movement input detected, exit early } if (newGridPosition != MainGame.GetPlayer.GridPosition) { // Movement has been detected, verify that we can actually move into this tile if (MainGame.GetPlayer.CanMoveIntoTile(MainGame.GetPlayer.CurrentLevel, newGridPosition)) { MainGame.GetPlayer.DrawRectangle = MainGame.GetPlayer.UpdateDrawRectangle(newGridPosition, TerrainManager.GetMapSize(MainGame.GetPlayer.CurrentLevel)); MainGame.GetPlayer.LastUpdate = gameTime.TotalGameTime.TotalMilliseconds; MainGame.GetPlayer.MoveAllowed = false; } else { return; // Illegal move, exit } } }