static void Main(string[] args) { GameMap map = new GameMap(); Player player = new Player(ref map); while (true) { map.Print(); Console.Write("Good sir, would you kindly enter a cardinal direction? "); player.ParseDirection(ref map, Console.ReadLine()); } }
public void MoveWest(ref GameMap map) { if (map.GetPoint(coordinates[(int)Grid.Row], coordinates[(int)Grid.Col] - 1) == "#") { Console.WriteLine("you dumb!"); } else { map.SetPoint(coordinates[(int)Grid.Row], coordinates[(int)Grid.Col], "."); map.SetPoint(coordinates[(int)Grid.Row], coordinates[(int)Grid.Col] - 1, sprite); coordinates[(int)Grid.Col] -= 1; } }
private static void PrintMap(GameMap map) { Console.Clear(); for (int j = 0; j < GameMap._xSize; j++) { for (int i = 0; i < GameMap._ySize; i++) { DrawCell(map[i, j]); } Console.WriteLine(); } }
public void ParseDirection(ref GameMap map, string direction) { string udirection = direction.ToUpper(); if (udirection.Length != 0) { switch (udirection[0]) { case 'N': MoveNorth(ref map); break; case 'E': MoveEast(ref map); break; case 'S': MoveSouth(ref map); break; case 'W': MoveWest(ref map); break; default: FailedDirection(); break; } } }
public Player(ref GameMap map) { coordinates = map.StartCoordinates; map.SetPoint(coordinates[(int) Grid.Row], coordinates[(int) Grid.Col], sprite); }