Exemplo n.º 1
0
    private void MarkOriginalWaterTiles(ref List <List <GameTile> > waterTilesSeperatedByArea)
    {
        //generates liquid in internal areas of the map that have been destoryed, basically generates liquid in blank spaces within the map
        //hands back a list of these water tiles seperated into their distinct areas
        board.UnMarkAllTiles();
        List <List <GameTile> > FloodFilledAreas        = new List <List <GameTile> >();
        List <GameTile>         FloodFillStartLocations = new List <GameTile>();
        GameTile destroyedTile;
        bool     containsMapEdge = false;

        do
        {
            Vector2 randomPoint = GetNextDestroyedUnMarkedPoint();
            destroyedTile = board.GetGrid()[(int)randomPoint.x][(int)randomPoint.y];
            board.GetGrid()[(int)randomPoint.x][(int)randomPoint.y].SetIsMarked(true);
            board.FloodFillDestroyedTiles(ref destroyedTile, ref FloodFilledAreas, ref containsMapEdge);
            if (!containsMapEdge)
            {
                FloodFillStartLocations.Add(board.GetGrid()[(int)randomPoint.x][(int)randomPoint.y]);
            }
        } while (HasUnmarkedDestroyedTiles());
        FloodFilledAreas.Clear();
        board.UnMarkAllTiles();
        for (int i = 0; i < FloodFillStartLocations.Count; i++)
        {
            destroyedTile = FloodFillStartLocations[i];
            destroyedTile.SetIsMarked(true);
            board.FloodFillDestroyedTiles(ref destroyedTile, ref FloodFilledAreas, ref containsMapEdge);
        }
        waterTilesSeperatedByArea = new List <List <GameTile> >(FloodFilledAreas);
    }