Beispiel #1
0
        private void floodfillStep(List <MECoord> a, MECoord tile)
        {
            if (a.Count == 0)
            {
                return;
            }

            int     dir = 0;
            MECoord p;
            int     len = a.Count;
            int     tmp;

            // remove current tile from the arrau
            for (int i = 0; i < a.Count; i++)
            {
                if (a[i].x == tile.x && a[i].y == tile.y)
                {
                    a.RemoveAt(i);
                    break;
                }
            }

            // search for neighbour tiles that are from same region and call recursively on them
            while (dir < 6 && len > 0)
            {
                p   = map.getNeighborTileCoor(tile.x, tile.y, dir);
                tmp = map.getNeighborTile(tile.x, tile.y, dir);
                if (map.getNeighborTile(tile.x, tile.y, dir) == Id)
                {
                    for (int i = 0; i < a.Count; i++)
                    {
                        if (a[i].x == p.x && a[i].y == p.y)
                        {
                            floodfillStep(a, p);
                            len = a.Count;
                            break;
                        }
                    }
                }
                dir++;
            }
        }