static void Main(string[] args) { var ui = new Ui(width: 110, height: 50); do { var game = new Game(ui); game.Play(); } while (ui.AskForKey("Another game? (y/n)") == ConsoleKey.Y); }
internal void Run() { // Initialisera // skapa hjälte hero = new Hero(health: 100) { Damage = 10 }; // placera monster map.Populate(); // gör en första utskrift log.Add("Welcome to Donjon!"); while (!quit) { // rita spelplan och övrig information Draw(); // hantera indata var acted = UserActions(); if (hero.Health <= 0) { log.Add("The hero is dead... Game Over"); quit = true; break; } // updatera spelobjekt if (acted) { GameActions(); } if (hero.Health <= 0) { log.Add("The hero is dead... Game Over"); quit = true; } } Draw(); ui.AskForKey("Press a key to quit"); }
private static void Main() { var width = 30; var height = 30; var ui = new Ui(width * 2 + 1, height + 2); var symbols = new Dictionary <MazeBuilder.CellType, string> { { MazeBuilder.CellType.Door, " D" }, { MazeBuilder.CellType.Wall, " #" }, { MazeBuilder.CellType.Open, " " }, }; var tiles = new Dictionary <TileType, string> { { TileType.OpenDoor, " □" }, { TileType.ClosedDoor, " ■" }, { TileType.Wall, "█#" }, { TileType.Floor, " " }, }; do { Console.Clear(); //var map = MazeBuilder.Generate(width, height).Map; //for (int y = 0; y < height; y++) { // for (int x = 0; x < width; x++) { // ui.Write(symbols[map[x, y]]); // } // ui.WriteLine(); //} var level = Generator.Dungeon(width / 2 * 2 + 1, height / 2 * 2 + 1); foreach (var position in level.Bounds) { ui.WriteAt(position.X, position.Y, tiles[level.CellAt(position).Tile]); } } while (ui.AskForKey("Q to quit") != ConsoleKey.Q); }