public void CreateObjects(OrderedPair <int> center) { Plant potato = GeneralPlant.Potato(80, 80); List <Plant> yuccaPlants = new List <Plant>(); Plant pineTree1 = GeneralPlant.PineTree(230, 400); List <Plant> appleTrees = new List <Plant> { new AppleTree(center.X + 50, center.Y + 120), new AppleTree(center.X + 180, center.Y + 50) }; for (int i = 0; i < 10; i++) { var p = Utilities.GetRandomPoint(); appleTrees.Add(new AppleTree(p.X, p.Y)); } for (int i = 0; i < 10; i++) { var p = Utilities.GetRandomPoint(); yuccaPlants.Add(GeneralPlant.Yucca(p.X, p.Y)); } List <Plant> plants = new List <Plant>() { potato, pineTree1 } .Concat(appleTrees) .Concat(yuccaPlants) .ToList(); // Spawn shrubs in random locations. for (int i = 0; i < 20; i++) { OrderedPair <int> position = Utilities.GetRandomPoint(); plants.Add(GeneralPlant.Shrub(position.X, position.Y)); } Plants = new List <Plant>(); foreach (Plant plant in plants) { AddPlant(plant); } }
private void SpawnRandomPlant() { Plant p; OrderedPair <int> randomPoint = Utilities.GetRandomPoint(); // TODO: Create a range of random values for different plants to generate. Then use the frequency selection method from UtilityDecider class // to pick the plant to spawn. if (Utilities.Rng.Next(0, 2) == 0) { p = GeneralPlant.PineTree(randomPoint.X, randomPoint.Y); } else { p = GeneralPlant.Yucca(randomPoint.X, randomPoint.Y); } AddPlant(p); }