Inheritance: IEnumerable
示例#1
0
        public XCMapFile(
            string baseName,
            string basePath,
            string blankPath,
            List <TileBase> tiles,
            string[] depList,
            RmpFile rmp)
            :
            base(baseName, tiles)
        {
            BaseName      = baseName;
            BasePath      = basePath;
            _blankPath    = blankPath;
            _dependencies = depList;
            Rmp           = rmp;

            var filePath = basePath + baseName + ".MAP";

            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException(filePath);
            }

            for (int i = 0; i < tiles.Count; i++)
            {
                tiles[i].MapId = i;
            }

            ReadMap(File.OpenRead(filePath), tiles);

            SetupRoutes(rmp);

            if (File.Exists(blankPath + baseName + BlankFile.Extension))
            {
                try
                {
                    BlankFile.LoadBlanks(baseName, blankPath, this);
                }
                catch
                {
                    for (int h = 0; h < MapSize.Height; h++)
                    {
                        for (int r = 0; r < MapSize.Rows; r++)
                        {
                            for (int c = 0; c < MapSize.Cols; c++)
                            {
                                this[r, c, h].DrawAbove = true;
                            }
                        }
                    }
                }
            }
            else if (!string.IsNullOrEmpty(blankPath))
            {
                CalcDrawAbove();
                SaveBlanks();
            }
        }
示例#2
0
        private void SetupRoutes(RmpFile rmp)
        {
            // remove extraHeight from edit-mode
            if (rmp.ExtraHeight != 0)
            {
                foreach (RmpEntry route in rmp)
                {
                    route.Height -= rmp.ExtraHeight;
                }
            }

            // Set tile
            foreach (RmpEntry re in rmp)
            {
                var tile = this[re.Row, re.Col, re.Height];

                if (tile != null)
                {
                    ((XCMapTile)tile).Rmp = re;
                }
            }
        }
示例#3
0
        public IMap_Base Load(XCMapDesc imd)
        {
            if (imd == null)
            {
                return(null);
            }
            if (!File.Exists(imd.FilePath))
            {
                return(null);
            }
            var filePath = imd.BasePath + imd.Basename + ".MAP";

            if (!File.Exists(filePath))
            {
                return(null);
            }
            ImageInfo images = GameInfo.ImageInfo;

            var tiles = new List <TileBase>();

            foreach (string dependency in imd.Dependencies)
            {
                var image = images[dependency];
                if (image != null)
                {
                    McdFile mcd = image.GetMcdFile(imd.Palette, _xcTileFactory);
                    foreach (XCTile t in mcd)
                    {
                        tiles.Add(t);
                    }
                }
            }

            var rmp = new RmpFile(imd.Basename, imd.RmpPath);
            var map = new XCMapFile(imd.Basename, imd.BasePath, imd.BlankPath, tiles, imd.Dependencies, rmp);

            return(map);
        }