/// <summary> /// Draws the entire game screen /// </summary> /// <param name="map">Map to draw</param> /// <param name="hero">Hero to draw</param> /// <param name="world">World to draw</param> public static void DrawGame(Map map, Hero hero, World world) { Console.Clear(); Console.Write(MapToString(map)); DrawActionBlocks(map); ActionMenu.RenderMenu(hero, world); }
/// <summary> /// CLones the exit from provided map and renders game /// </summary> /// <param name="map">Map to draw</param> /// <param name="exitMap">Map from where we came</param> /// <param name="exitDirection">The direction to generate the exit</param> /// <param name="hero">Hero to render</param> /// <param name="world">World to render</param> public static void CloneExitsAndDrawThisMapPlease(Map map, Dictionary<Direction, Map> adjactenMaps, Hero hero, World world) { foreach (var adjacentMap in adjactenMaps) { MapHandler.CloneExit(adjacentMap.Value, adjacentMap.Key, map); } DrawGame(map, hero, world); }
static void Main(string[] args) { //Remove cursor Console.CursorVisible = false; //Init hero Hero = new Hero("Herald Grimrian"); //Height has to be 1 more than map Console.SetWindowSize(80, 31); //Create map _currentMap = MapHandler.CreateMap(MapWidth, MapHeight, 40, RandomBlockConfiguration); //Init new world from 0,0 _world = new World { WhereAmI = new Coordinate(0, 0), MapGrid = new Dictionary<Coordinate, Map>() }; _world.MapGrid.Add(new Coordinate(0, 0), _currentMap); //Generate one exit in each direction MapHandler.GenerateExit(Direction.North, _currentMap); MapHandler.GenerateExit(Direction.South, _currentMap); MapHandler.GenerateExit(Direction.East, _currentMap); MapHandler.GenerateExit(Direction.West, _currentMap); //Draw the map TheCartographer.DrawGame(_currentMap, Hero, _world); //Let's get it on! InitGame(MapHandler.GetValidStartLocation(15, 15, _currentMap)); //Main loop. Check if arrow keys are pressed and move accordingly. ConsoleKeyInfo keyInfo; while ((keyInfo = Console.ReadKey(true)).Key != ConsoleKey.Escape) { switch (keyInfo.Key) { case ConsoleKey.UpArrow: MoveHero(0, -1); break; case ConsoleKey.RightArrow: MoveHero(1, 0); break; case ConsoleKey.DownArrow: MoveHero(0, 1); break; case ConsoleKey.LeftArrow: MoveHero(-1, 0); break; } } }