/// <summary> /// Clear and repopulate the houses. /// </summary> public void Repopulate() { // Generate enough plants to fill the planter of each house with the // same type of plant. List <PortableItem> plants = new List <PortableItem>(); for (int h = 0; h < houses.Length; ++h) { PortableItem plant = planterFactory.CreateRandomItem(); for (int i = 0; i < houses[h].Planter.Capacity; ++i) { plants.Add(planterFactory.CreateItem(plant)); } } // All plants have been made, so shuffle the array. plants.Shuffle(); // Add the plants to the houses. foreach (SuburbHouseState house in this.houses) { house.Repopulate(plants); } // Repopulated and ready to be worked. this.done = false; }
/// <summary> /// Add a new batch of movies to the shelf. /// </summary> /// <param name="factory"> /// A factory describing items that can be generated on the shelf. /// </param> public void Repopulate(PortableItemFactory factory) { this.inventory.Clear(); int newItemCount = StaticRandom.Range(3, this.inventory.Capacity); for (int i = 0; i < newItemCount; ++i) { InventoryError err = this.inventory.Add(factory.CreateRandomItem()); if (err != InventoryError.NoError) { Debug.LogFormat("Could not add item to movie shelf: {0}", err); } } }