Esempio n. 1
0
        //currently does not work if called before Initialize, this will change when Board is implemented
        public bool CreateFile(Board map, string timeStamp)
        {
            if (map == null)
            {
                return(false);
            }
            string newMap = "";

            newMap += String.Format("{0}X{1}\n", map.numRows, map.numColumns);
            for (int i = 0; i < map.numRows; i++)
            {
                for (int j = 0; j < map.numColumns; j++)
                {
                    int             row         = i;
                    int             column      = j;
                    Tile            currentTile = map.spaces[row, column];
                    TileEnumeration terrain     = currentTile.m_terrainType;
                    Unit            unit        = currentTile.m_unit;
                    if (i == map.numRows - 1 && j == map.numColumns - 1)
                    {
                        newMap += String.Format("{0}{1} {2}{3}", (char)(row + 'A'), column + 1, (int)terrain, (unit == null) ? "" : " " + ConvertUnitToRegexFormat(unit));
                    }
                    else
                    {
                        newMap += String.Format("{0}{1} {2}{3}\n", (char)(row + 'A'), column + 1, (int)terrain, (unit == null) ? "" : " " + ConvertUnitToRegexFormat(unit));
                    }
                }
            }
            ResourceSet                 reader   = new ResourceSet("MapFiles.resources");
            IDictionaryEnumerator       saves    = reader.GetEnumerator();
            Dictionary <object, object> saveInfo = new Dictionary <object, object>();

            foreach (DictionaryEntry entry in reader)
            {
                saveInfo.Add(entry.Key, entry.Value);
            }
            reader.Close();
            ResourceWriter resWriter = new ResourceWriter("MapFiles.resources");

            foreach (KeyValuePair <object, object> entry in saveInfo)
            {
                string key   = entry.Key.ToString();
                string value = entry.Value.ToString();
                resWriter.AddResource(key, value);
            }
            resWriter.AddResource(String.Format("{0}_{1}", map.name, timeStamp), newMap);
            resWriter.Close();
            return(true);
        }
Esempio n. 2
0
 public Tile(TileEnumeration terrain, Unit unit)
 {
     m_terrainType = terrain;
     m_unit        = unit;
 }