Inheritance: XCom.Interfaces.Base.IMap_Base
Beispiel #1
0
        public static void LoadBlanks(
            string basename,
            string blankPath,
            XCMapFile myFile)
        {
            BinaryReader br = new BinaryReader(File.OpenRead(blankPath + basename + Extension));

            bool flip = true;
            int  curr = 0;

            while (br.BaseStream.Length > br.BaseStream.Position)
            {
                UInt16 v = br.ReadUInt16();

                if (flip)
                {
                    for (int i = curr; i < curr + v; i++)
                    {
                        int h = i / (myFile.MapSize.Rows * myFile.MapSize.Cols);
                        int c = i % myFile.MapSize.Cols;
                        int r = (i / myFile.MapSize.Cols) - h * myFile.MapSize.Rows;

                        ((XCMapTile)myFile[r, c, h]).DrawAbove = false;
                    }
                }

                curr += v;
                flip  = !flip;
            }

            br.Close();
        }
Beispiel #2
0
		public static void LoadBlanks(string basename, string blankPath,XCMapFile myFile)
		{
			BinaryReader br = new BinaryReader(File.OpenRead(blankPath+basename+Extension));

			bool flip=true;
			int curr=0;

			while(br.BaseStream.Length>br.BaseStream.Position)
			{
				UInt16 v = br.ReadUInt16();

				if(flip)
				{
					for(int i=curr;i<curr+v;i++)
					{
						int h = i / (myFile.MapSize.Rows * myFile.MapSize.Cols);
						int c = i % myFile.MapSize.Cols;
						int r = (i / myFile.MapSize.Cols) - h * myFile.MapSize.Rows;

						((XCMapTile)myFile[r,c,h]).DrawAbove=false;
					}						
				}
	
				curr+=v;
				flip=!flip;
			}

			br.Close();
		}
Beispiel #3
0
        public static void SaveBlanks(
            string basename,
            string blankPath,
            XCMapFile myFile)
        {
            if (!Directory.Exists(blankPath))
            {
                Directory.CreateDirectory(blankPath);
            }

            BinaryWriter bw = new BinaryWriter(new FileStream(blankPath + basename + Extension, FileMode.Create));

            UInt16 curr = 0;
            bool   flip = true;

            for (int h = 0; h < myFile.MapSize.Height; h++)
            {
                for (int r = 0; r < myFile.MapSize.Rows; r++)
                {
                    for (int c = 0; c < myFile.MapSize.Cols; c++)
                    {
                        if (flip)
                        {
                            if (((XCMapTile)myFile[r, c, h]).DrawAbove)
                            {
                                flip = !flip;
                                bw.Write(curr);
                                curr = 1;
                            }
                            else
                            {
                                curr++;
                            }
                        }
                        else
                        {
                            if (((XCMapTile)myFile[r, c, h]).DrawAbove)
                            {
                                curr++;
                            }
                            else
                            {
                                flip = !flip;
                                bw.Write(curr);
                                curr = 1;
                            }
                        }
                    }
                }
            }

            bw.Flush();
            bw.Close();
        }
		public XCMapFile GetShip()
		{
			ImageInfo images = GameInfo.ImageInfo;

			List<ITile> a = new List<ITile>();
			foreach(string s in dependencies)
			{
				McdFile mcd = images[s].GetMcdFile();
				foreach(XCTile t in mcd)
					a.Add(t);
			}

			XCMapFile ship = new XCMapFile(basename,basePath,blankPath,a,dependencies);

			return ship;
		}
Beispiel #5
0
        public XCMapFile GetShip()
        {
            ImageInfo images = GameInfo.ImageInfo;

            List <ITile> a = new List <ITile>();

            foreach (string s in dependencies)
            {
                McdFile mcd = images[s].GetMcdFile();
                foreach (XCTile t in mcd)
                {
                    a.Add(t);
                }
            }

            XCMapFile ship = new XCMapFile(basename, basePath, blankPath, a, dependencies);

            return(ship);
        }
Beispiel #6
0
		public static void SaveBlanks(string basename,string blankPath,XCMapFile myFile)
		{
			if(!Directory.Exists(blankPath))
				Directory.CreateDirectory(blankPath);

			BinaryWriter bw = new BinaryWriter(new FileStream(blankPath+basename+Extension,FileMode.Create));

			UInt16 curr=0;
			bool flip=true;

			for (int h = 0; h < myFile.MapSize.Height; h++)
				for (int r = 0; r < myFile.MapSize.Rows; r++)
					for (int c = 0; c < myFile.MapSize.Cols; c++)
					{
						if(flip)
						{
							if(((XCMapTile)myFile[r,c,h]).DrawAbove)
							{
								flip=!flip;
								bw.Write(curr);
								curr=1;								
							}
							else
								curr++;
						}
						else
						{
							if(((XCMapTile)myFile[r,c,h]).DrawAbove)
								curr++;
							else
							{
								flip=!flip;
								bw.Write(curr);
								curr=1;
							}
						}						
					}

			bw.Flush();
			bw.Close();
		}
        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);
        }
Beispiel #8
0
		public override IMap_Base GetMapFile() 
		{
            var filePath = basePath + basename + ".MAP";
		    if (!File.Exists(filePath)) return null;
			ImageInfo images = GameInfo.ImageInfo;

			List<ITile> a = new List<ITile>();
			//if (p == null)
			//    p = GameInfo.DefaultPalette;

			foreach (string s in dependencies)
			{
				if (images[s] != null)
				{
					McdFile mcd = images[s].GetMcdFile(myPal);
					foreach (XCTile t in mcd)
						a.Add(t);
				}
			}

            XCMapFile map = new XCMapFile(basename, basePath, blankPath, a, dependencies);
			map.Rmp = new RmpFile(basename, rmpPath);
			return map;
		}