Beispiel #1
0
        private static bool precache(string name)
        {
            FOMapParser parser = new FOMapParser(Config.PresetsPath + @"\" + name);

            if (!parser.Parse())
            {
                return(false);
            }

            FOMap map = parser.Map;

            Preset p = new Preset();

            foreach (FOCommon.Maps.Tile tile in map.Tiles)
            {
                BigTile bt = p.GetBigTile(tile.X / (2 * (Config.BigTileEdgeSize + 1)),
                                          (tile.Y / (2 * (Config.BigTileEdgeSize + 1)) + 1), true);
                bt.AddTileClone(tile);
            }

            foreach (MapObject obj in map.Objects)
            {
                BigTile bt = p.GetBigTile(obj.MapX / (2 * (Config.BigTileEdgeSize + 1)),
                                          (obj.MapY / (2 * (Config.BigTileEdgeSize + 1)) + 1), true);
                bt.AddObjectClone(obj);
            }

            cache.Add(name, p);
            return(true);
        }
Beispiel #2
0
        private void placeBigTile(FOMap m, BigTile bt, int tx, int ty)
        {
            ushort my = (ushort)ty;
            ushort mx = (ushort)(Width - tx - 1);

            m.Objects.AddRange(bt.GetClonedObjects(mx, my));
            m.Tiles.AddRange(bt.GetClonedTiles(mx, my));
        }
Beispiel #3
0
        private void compileEmpty(FOMap m, Preset p, int tx, int ty)
        {
            Tile    tile = tiles[tx, ty];
            BigTile bt   = p.GetBigTile(0, tile.Variant);

            if (bt == null)
            {
                throw new CompilerException(
                          String.Format("there is no empty tile with variant {0} to place on ({1},{2})", tile.Variant, tx, ty));
            }
            placeBigTile(m, bt, tx, ty);
        }
Beispiel #4
0
 /// <summary>
 /// Sets the big tile.
 /// </summary>
 /// <param name="num">Index of the tile</param>
 /// <param name="variant">Variant of that index</param>
 /// <param name="bt">Big tile to be added</param>
 public void AddBigTile(int num, int variant, BigTile bt)
 {
     bigTiles.Add(new Pair <int, int>(num, variant), bt);
     if (bigTilesCount.ContainsKey(num))
     {
         bigTilesCount[num]++;
     }
     else
     {
         bigTilesCount.Add(num, 1);
     }
 }
Beispiel #5
0
        private void compileWide(FOMap m, Preset p, int tx, int ty)
        {
            Tile tile = tiles[tx, ty];
            int  hash = GetTileHash(tile);
            int  num  = PresetsManager.GetWideNum(hash);

            if (num == -1)
            {
                throw new CompilerException(
                          String.Format("there is no tile for hash W{0,8} to place on ({1},{2})", Utils.HashCode(hash), tx, ty));
            }
            BigTile bt = p.GetBigTile(num, tile.Variant);

            if (bt == null)
            {
                throw new CompilerException(
                          String.Format("there is no tile W{0,8}/{1} to place on ({2},{3})", Utils.HashCode(hash), tile.Variant, tx, ty));
            }
            placeBigTile(m, bt, tx, ty);
        }
Beispiel #6
0
        private void compileAdapter(FOMap m, Preset p, int tx, int ty, int dir)
        {
            Tile tile = tiles[tx, ty];
            int  num  = PresetsManager.GetAdapterNum(dir);

            if (num == -1)
            {
                throw new CompilerException(
                          String.Format("there is no tile for adapter {0} to place on ({2},{3})",
                                        Directions.ToChar(dir), tx, ty));
            }
            BigTile bt = p.GetBigTile(num, tile.Variant);

            if (bt == null)
            {
                throw new CompilerException(
                          String.Format("there is no adapter tile {0}/{1} to place on ({2},{3})",
                                        Directions.ToChar(dir), tile.Variant, tx, ty));
            }
            placeBigTile(m, bt, tx, ty);
        }
Beispiel #7
0
 private void placeBigTile(FOMap m, BigTile bt, int tx, int ty)
 {
     ushort my = (ushort)ty;
     ushort mx = (ushort)(Width - tx - 1);
     m.Objects.AddRange(bt.GetClonedObjects(mx, my));
     m.Tiles.AddRange(bt.GetClonedTiles(mx, my));
 }
Beispiel #8
0
 /// <summary>
 /// Sets the big tile.
 /// </summary>
 /// <param name="num">Index of the tile</param>
 /// <param name="variant">Variant of that index</param>
 /// <param name="bt">Big tile to be added</param>
 public void AddBigTile(int num, int variant, BigTile bt)
 {
     bigTiles.Add(new Pair<int, int>(num, variant), bt);
     if (bigTilesCount.ContainsKey(num)) bigTilesCount[num]++;
     else bigTilesCount.Add(num, 1);
 }