Exemplo n.º 1
0
 public ProvisionalPortal(PortalTile portal) : base(portal.coord, 'a')
 {
     this.name = portal.name;
     foreach (var neighbour in portal.neighbours)
     {
         LinkTo(neighbour);
     }
 }
Exemplo n.º 2
0
        public void Parse(bool levelZero, bool recursive)
        {
            var allTiles       = new Dictionary <Coordinate, Tile>();
            var partialPortals = new List <PortalTile>();

            for (int y = 0; y < lines.Length; y++)
            {
                for (int x = 0; x < lines[y].Length; x++)
                {
                    var coord = new Coordinate(x, y);

                    Tile tile = null;
                    if (lines[y][x] == '.')
                    {
                        tile = new RegularTile(coord);
                    }
                    if (lines[y][x] >= 'A' && lines[y][x] <= 'Z')
                    {
                        var ptile = new PortalTile(coord, lines[y][x]);
                        partialPortals.Add(ptile);
                        tile = ptile;
                    }

                    Tile toTheLeft = null;
                    Tile up        = null;
                    allTiles.TryGetValue(new Coordinate(x - 1, y), out toTheLeft);
                    allTiles.TryGetValue(new Coordinate(x, y - 1), out up);

                    if (tile != null)
                    {
                        if (toTheLeft != null)
                        {
                            tile.LinkTo(toTheLeft);
                        }
                        if (up != null)
                        {
                            tile.LinkTo(up);
                        }
                    }

                    allTiles.Add(coord, tile);
                }
            }

            if (recursive)
            {
                ParseRecursePortals(partialPortals, levelZero);
            }
            else
            {
                ParseRegularPortals(partialPortals);
            }
        }