예제 #1
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);
 }
예제 #2
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;
        }
예제 #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);
 }
예제 #4
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);
 }
예제 #5
0
        private void compileTile(FOMap m, Preset p, int tx, int ty)
        {
            Tile tile = tiles[tx, ty];

            if (!tile.Filled) compileEmpty(m, p, tx, ty);
            else if (tile.Wide) compileWide(m, p, tx, ty);
            else
            {
                bool compilen = false;
                for (int dir = Directions.North; dir <= Directions.West; dir++)
                {
                    if (tile.IsPath(dir) && tile.GetNeighbour(dir).Wide)
                    {
                        compileAdapter(m, p, tx, ty, dir);
                        compilen = true;
                        break;
                    }
                }
                if (!compilen) compileNormalCorridor(m, p, tx, ty);
            }
        }