Пример #1
0
        static void Main(string[] args)
        {
            var mapInfo = new MapFile(new Tile[30, 30], new List <Spawn>());

            for (int y = 0; y < mapInfo.TileSet.GetLength(1); y++)
            {
                for (int x = 0; x < mapInfo.TileSet.GetLength(0); x++)
                {
                    mapInfo.TileSet[x, y].TileType = EnumTileTypes.Snow;
                }
            }

            var mapIndex    = args.Length > 0 ? args[0] : null;
            var newFileMenu = new MapFileHandler.MapFileHandler(ref mapInfo, mapIndex);

            //Set LOS default
            for (int y = 0; y < mapInfo.TileSet.GetLength(1); y++)
            {
                for (int x = 0; x < mapInfo.TileSet.GetLength(0); x++)
                {
                    mapInfo.TileSet[x, y].IsInLos = false;
                }
            }

            var gameSystemManager = new GameSystemManager(mapInfo);
        }
Пример #2
0
        public void MainLoop()
        {
            DrawMap();
            ConsoleKeyInfo keyPressed;

            keyPressed = Console.ReadKey(true);
            while (keyPressed.Key != ConsoleKey.Escape)
            {
                if (keyPressed.Key == ConsoleKey.W)
                {
                    WindowYPosition--;
                }
                else if (keyPressed.Key == ConsoleKey.S)
                {
                    WindowYPosition++;
                }
                else if (keyPressed.Key == ConsoleKey.A)
                {
                    WindowXPosition--;
                }
                else if (keyPressed.Key == ConsoleKey.D)
                {
                    WindowXPosition++;
                }
                else if (keyPressed.Key == ConsoleKey.UpArrow)
                {
                    if (CursorYPosition > 0)
                    {
                        CursorYPosition--;
                    }
                    if (CursorYPosition < WindowYPosition)
                    {
                        WindowYPosition--;
                    }
                }
                else if (keyPressed.Key == ConsoleKey.DownArrow)
                {
                    if (CursorYPosition < mapInfo.TileSet.GetLength(1) - 1)
                    {
                        CursorYPosition++;
                    }
                    if (CursorYPosition >= WindowYPosition + ScreenWidth)
                    {
                        WindowYPosition++;
                    }
                }
                else if (keyPressed.Key == ConsoleKey.LeftArrow)
                {
                    if (CursorXPosition > 0)
                    {
                        CursorXPosition--;
                    }
                    if (CursorXPosition < WindowXPosition)
                    {
                        WindowXPosition--;
                    }
                }
                else if (keyPressed.Key == ConsoleKey.RightArrow)
                {
                    if (CursorXPosition < mapInfo.TileSet.GetLength(0) - 1)
                    {
                        CursorXPosition++;
                    }
                    if (CursorXPosition >= WindowXPosition + ScreenWidth)
                    {
                        WindowXPosition++;
                    }
                }
                else if (keyPressed.Key == ConsoleKey.Add)
                {
                    if (_cursorSize < 2)
                    {
                        _cursorSize++;
                    }
                }
                else if (keyPressed.Key == ConsoleKey.Subtract)
                {
                    if (_cursorSize > 0)
                    {
                        _cursorSize--;
                    }
                }
                else if (keyPressed.Key == ConsoleKey.B)
                {
                    Console.Clear();
                    // Create new map with specified
                    Console.WriteLine("Enter the new map width (in tiles)");
                    var newX = Console.ReadLine();
                    Console.WriteLine("Enter the new map height (in tiles)");
                    var newY = Console.ReadLine();
                    mapInfo = new MapFile(new Tile[int.Parse(newX), int.Parse(newY)], new List <Spawn>());
                    ResetMap();
                }
                else if (keyPressed.Key == ConsoleKey.M)
                {
                    var newFileMenu = new MapFileHandler.MapFileHandler(ref mapInfo);
                }
                else if (keyPressed.Key == ConsoleKey.N)
                {
                    ResetMap();
                }
                else
                {
                    HandleTileChangeKeyPressed(keyPressed.Key);
                }

                DrawMap();

                keyPressed = Console.ReadKey(true);
            }
        }