Beispiel #1
0
        public TileTypeDictionary() : base()
        {
            var fileName = GameGlobals.Instance().Get <string>("textureDir");

            if (!File.Exists(fileName))
            {
                fileName = @"G:\Programming\CSConsoleRL\CSConsoleRL\CSConsoleRL\bin\x64\Debug\Data\Sprites\Tiles20x20.png";
            }
            if (!File.Exists(fileName))
            {
                fileName = @"F:\Programming\CSConsoleRL\Data\Sprites\Tiles20x20.png";
            }
            if (!File.Exists(fileName))
            {
                fileName = @"/home/jason/dev/CSConsoleRL/Data/Sprites/Tiles20x20.png";
            }
            Add(EnumTileTypes.Snow, new TileData('~', new Texture(fileName, new IntRect(0, 0, 20, 20)), ConsoleColor.Gray, false, false, false));
            Add(EnumTileTypes.SnowWalked, new TileData('8', new Texture(fileName, new IntRect(20, 20, 20, 20)), ConsoleColor.Gray, false, false, false));
            Add(EnumTileTypes.Road, new TileData('-', new Texture(fileName, new IntRect(0, 0, 20, 20)), ConsoleColor.DarkGray, false, false, false));
            Add(EnumTileTypes.Grass, new TileData(';', new Texture(fileName, new IntRect(0, 0, 20, 20)), ConsoleColor.Green, false, false, false));
            Add(EnumTileTypes.CabinWall, new TileData('=', new Texture(fileName, new IntRect(0, 60, 20, 20)), ConsoleColor.DarkMagenta, true, true, true));
            Add(EnumTileTypes.CabinFloor, new TileData('+', new Texture(fileName, new IntRect(0, 40, 20, 20)), ConsoleColor.DarkMagenta, false, false, false));
            Add(EnumTileTypes.CabinDoor, new TileData('%', new Texture(fileName, new IntRect(0, 40, 20, 20)), ConsoleColor.DarkMagenta, false, true, true));
            Add(EnumTileTypes.Tree, new TileData('T', new Texture(fileName, new IntRect(0, 20, 20, 20)), ConsoleColor.DarkGreen, true, true, true));
            Add(EnumTileTypes.River, new TileData('^', new Texture(fileName, new IntRect(0, 100, 20, 20)), ConsoleColor.Blue, true, false, false));
            Add(EnumTileTypes.CabinWindow, new TileData('_', new Texture(fileName, new IntRect(0, 80, 20, 20)), ConsoleColor.DarkMagenta, true, false, false));
            Add(EnumTileTypes.Mountain, new TileData('^', new Texture(fileName, new IntRect(40, 20, 20, 20)), ConsoleColor.DarkGray, true, true, true));
        }
Beispiel #2
0
        public void LoadMapFileBrowser(ref MapFile mapFileToLoadTo, string mapIndex = null)
        {
            var mapDir = GameGlobals.Instance().Get <string>("mapDir");

            if (!Directory.Exists(mapDir))
            {
                mapDir = @"F:\Programming\CSConsoleRL\Data\Maps\";
            }
            string[] filesInDirectory = Directory.GetFiles(mapDir, "*.csr");
            int      tempInt          = 0;
            string   input            = "";

            if (!String.IsNullOrWhiteSpace(mapIndex))
            {
                if (int.TryParse(mapIndex, out tempInt) && tempInt != 0 && tempInt <= filesInDirectory.GetLength(0))
                {
                    LoadMap(filesInDirectory[tempInt - 1], ref mapFileToLoadTo);
                    return;
                }
            }

            while (string.Compare(input, "exit", true) != 0)
            {
                for (int index = 0; index < filesInDirectory.GetLength(0); index++)
                {
                    Console.WriteLine((index + 1) + ": " + filesInDirectory[index]);
                }

                input = Console.ReadLine();

                if (int.TryParse(input, out tempInt) && tempInt != 0 && tempInt <= filesInDirectory.GetLength(0))
                {
                    LoadMap(filesInDirectory[tempInt - 1], ref mapFileToLoadTo);
                    return;
                }
                else if (string.Compare(input, "exit", true) != 0)
                {
                    LoadMap(mapDir + input, ref mapFileToLoadTo);
                    return;
                }
            }
        }
        private void LoadGlobals()
        {
            var xWindowCharWidth = GameGlobals.Instance().Get <long>("xWindowCharWidth");

            if (xWindowCharWidth > 0)
            {
                _xWindowCharWidth = (int)xWindowCharWidth;
            }

            var yPlayableAreaCharHeight = GameGlobals.Instance().Get <long>("yPlayableAreaCharHeight");

            if (yPlayableAreaCharHeight > 0)
            {
                _yPlayableAreaCharHeight = (int)yPlayableAreaCharHeight;
            }

            var tilePixelSize = GameGlobals.Instance().Get <long>("tilePixelSize");

            if (tilePixelSize > 0)
            {
                _tilePixelSize = (int)tilePixelSize;
            }

            var windowXSize = GameGlobals.Instance().Get <long>("windowXSize");

            if (windowXSize > 0)
            {
                _windowXSize = (int)windowXSize;
            }

            var windowYSize = GameGlobals.Instance().Get <long>("windowYSize");

            if (windowYSize > 0)
            {
                _windowYSize = (int)windowYSize;
            }
        }