static void PlayGame() { Dungeon dungeon = new Dungeon(); player.X = dungeon.SpawnPoint[0]; player.Y = dungeon.SpawnPoint[1]; Cell currentRoom; ConsoleKey key = new ConsoleKey(); do { IO.CleanConsole(); //Console.WriteLine(player.X + ", " + player.Y); dungeon.Print(player); currentRoom = dungeon.Cells[player.X, player.Y]; if (IO.PickUp(key)) { player.Loot(currentRoom); } else { if (currentRoom.HasItem) { IO.PlayFoundItem(); currentRoom.Item.WriteFoundItem(); } else { IO.PadLines(2); } } key = Console.ReadKey().Key; player.Move(dungeon, key); } while (player.Health > 0); }
public void Move(Dungeon dungeon, ConsoleKey key) { if (IO.MoveUp(key)) { try { if (dungeon.Cells[X, Y - 1].IsRoom()) { Y -= 1; IO.PlayMove(); } } catch { } } else if (IO.MoveLeft(key)) { try { if (dungeon.Cells[X - 1, Y].IsRoom()) { X -= 1; IO.PlayMove(); } } catch { } } else if (IO.MoveDown(key)) { try { if (dungeon.Cells[X, Y + 1].IsRoom()) { Y += 1; IO.PlayMove(); } } catch { } } else if (IO.MoveRight(key)) { try { if (dungeon.Cells[X + 1, Y].IsRoom()) { X += 1; IO.PlayMove(); } } catch { } } }