/// <summary> /// Method called once at the beginning of a new game by game manager to create new treasures /// Creates a set number of treasure in a given number of tiers. /// </summary> /// <param name="pintTreasuresPerTier"></param> /// <param name="pintTierCount"></param> public void CreateNewTreasures(int pintTreasuresPerTier, int pintTierCount) { Treasure musTreasure; int intRetryCount = 0; // foreach tier for (int i = 0; i < GameManagerScript.MapTierCount; i++) { for (int j = 0; j < pintTreasuresPerTier; j++) { musTreasure = new Treasure(Treasure.GetRandomTreasureType()); intRetryCount = 0; // Attempt to place the treasure 100 times to avoid random position hitting other treasures while (!GameMap.PlaceTreasure(musTreasure, GameMap.CalculateRandomPositionInTier(i)) && intRetryCount < 100) { intRetryCount++; } // Hide treasure for higher tiers if (i > 0) { musTreasure.MapGameObject.SetActive(false); } } } }