public void BreedTest1() { string name = "John's plant"; GameObject newPlant = pmanager.MakePlant(name, "Jade"); GameObject newPlant2 = pmanager.MakePlant(name + "(2)", "Jade"); GameObject child = pmanager.Breed(newPlant, newPlant2, "child"); Assert.IsTrue(pmanager.plantCollection.Contains(child), String.Format("New child '{0}' was made but wasnt present in the collection", child.name)); Assert.AreEqual(pmanager.plantCollection.Count, 3, String.Format("New child '{0}' was made but wasnt present in the collection", child.name)); }
public void CrossBreed() { PlantManager plantManager = GameObject.Find("GameManager").GetComponent <PlantManager>(); //get plant manager object int index1 = plantDisplay1.GetComponent <PlantDisplay>().indexNum; //index of plants in collection int index2 = plantDisplay2.GetComponent <PlantDisplay>().indexNum; string name = inputField.GetComponent <TMP_InputField>().text; //user input field //handle errors - not enough plants in collection, crossbreeding same breed, invalid/existing name input string invMessage = ""; if (plantManager.plantCollection.Count <= 1) { invMessage = "There aren't a enough plants in the collection"; } else if (index1 == index2) { invMessage = "cannot crossbreed the same plant"; } else { try { plantManager.Breed(plantManager.plantCollection[index1], plantManager.plantCollection[index2], name); } catch (ArgumentException) { } } //show pop up panel to confirm/deny crossbreed status PopUpManager popUpManager = GameObject.Find("GameManager").GetComponent <PopUpManager>(); if (invMessage != "") { popUpManager.PopUpMessage(invMessage); } }