Esempio n. 1
0
    private List <GameTile> GetTilesWithinRangeOfWater()
    {
        //return a list of floor tiles that are within 3 tiles of a waters edge, this means these tiles are valid for spawning live grass
        int validRangeFromWater = 3;         //TODO: public facing

        board.UnMarkAllTiles();
        List <GameTile> waterTiles      = new List <GameTile>();
        List <GameTile> edgeWaterTiles  = new List <GameTile>();
        List <GameTile> validFloorTiles = new List <GameTile>();

        for (int x = 0; x < board.GetCols(); x++)
        {
            for (int y = 0; y < board.GetRows(); y++)
            {
                if (board.GetGrid()[x][y].GetObject() != null && board.GetGrid()[x][y].GetObject().GetComponent <WaterTile>() != null)
                {
                    waterTiles.Add(board.GetGrid()[x][y]);
                }
            }
        }
        foreach (GameTile tile in waterTiles)
        {
            List <GameTile> possibleFloorTiles = board.GetTileCardinalNeighbours(tile);
            foreach (GameTile possibleFloortile in possibleFloorTiles)
            {
                if (possibleFloortile.OpenForPlacement())
                {
                    edgeWaterTiles.Add(possibleFloortile);
                }
            }
        }
        foreach (GameTile tile in edgeWaterTiles)
        {
            List <GameTile> possibleValidFloorTiles = board.GetAllTilesInRange(tile, validRangeFromWater);
            foreach (GameTile possibleValidFloorTile in possibleValidFloorTiles)
            {
                if (possibleValidFloorTile.OpenForPlacement())
                {
                    validFloorTiles.Add(possibleValidFloorTile);
                }
            }
        }
        board.UnMarkAllTiles();
        return(validFloorTiles);
    }
Esempio n. 2
0
 private Vector2 GetNextDestroyedUnMarkedPoint()
 {
     //return a destoryed unmarked point, helper function for Generate Liquid, should only be called when HasUnMarkedDestoryedTiles() has ensured a return
     for (int x = 0; x < board.GetCols(); x++)
     {
         for (int y = 0; y < board.GetRows(); y++)
         {
             if ((!board.GetGrid()[x][y].IsMarked()) && (board.GetGrid()[x][y].IsDestroyed()))
             {
                 board.GetGrid()[x][y].SetIsMarked(true);
                 return(new Vector2(board.GetGrid()[x][y].GetX(), board.GetGrid()[x][y].GetY()));
             }
         }
     }
     Debug.Log("No tile was found MAJOR ERROR AT WATER GENERATION");
     return(new Vector2(-99.0f, -99.0f));        //error value will cause out of bound exception
 }