Ejemplo n.º 1
0
 public void SpawnFungi(Hexagon hex)
 {
     //get all the surrounding hexagons that contains a tree
     List<Hexagon> treesTiles = GetAccessibleTiles(hex);
     //If there's one or more tile with a tree on it
     if (treesTiles.Count > MinimumSpawnTrees)
     {
         hex.addTileInfectingFungi();
     } else
     {
         //Browsing all the hexagons to get at least "MinimumSpawnTrees"
         for (int i = 0; i < Hexagons.Length; i++)
         {
             //Get the surroundings tiles for hex
             treesTiles = GetAccessibleTiles(Hexagons[i]);
             if (treesTiles.Count > MinimumSpawnTrees)
             {
                 if (Hexagons[i].HexState == HexagonState.Empty)
                 {
                     Hexagons[i].PlantTree(TreeType.SmallTree);
                 }
                 Hexagons[i].addTileInfectingFungi();
                 return;
             }
         }
         //Spawn a new tree
         List<Hexagon> surroundingTiles = GetSurroundingTiles(hex);
         hex.addTileInfectingFungi();
         int count = MinimumSpawnTrees - treesTiles.Count;
         for (int i = 0; i < surroundingTiles.Count; i ++)
         {
             if (surroundingTiles[i].HexTree == null)
             {
                 TreeGenerator.SpawnSapling(surroundingTiles[i]);
                 count--;
                 if (count == 0)
                     return;
             }
         }
     }
 }
Ejemplo n.º 2
0
 public void EndDrag(Hexagon endHexagon)
 {
     endHexagon.addTileInfectingFungi();
     startHexChildScript.reset();
 }