using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine.SceneManagement; using UnityEngine; using Random = UnityEngine.Random; public class ClassGenerator : MonoBehaviour { //Lists public List<ClassBaseType> characterClasses; public List<TextMeshProUGUI> textList; private bool generated; // Start is called before the first frame update void Start() { generated = false; for (int i = 0; i < textList.Count; i++) { textList[i] = textList[i].GetComponent<TextMeshProUGUI>(); } } //This method will create an instance of the ScriptableObject of Mercenary Class //Method Called in OnClick() in the Mercenary Generate Button public void GenerateClasses() { foreach (ClassBaseType c in characterClasses) { if (c.dead) { c.hp = (uint)Random.Range(c.hpGen.minimumValue, c.hpGen.maximumValue); c.speedGround = Random.Range((int)c.speedGroundGen.minimumValue, (int)c.speedGroundGen.maximumValue); c.speedAir = Random.Range((int)c.speedAirGen.minimumValue, (int)c.speedAirGen.maximumValue); if (textList.Count > 0) UIHandler(); c.dead = false; } } } //This method displays the Generated Values of the instances created in the methods above public void UIHandler() { //Rogue if (characterClasses[0].dead) { textList[0].text = "HP: " + characterClasses[0].hp; textList[1].text = "Ground Speed: " + characterClasses[0].speedGround; textList[2].text = "Air Speed: " + characterClasses[0].speedAir; return; } //Merc if (characterClasses[1].dead) { textList[3].text = "HP: " + characterClasses[1].hp; textList[4].text = "Ground Speed: " + characterClasses[1].speedGround; textList[5].text = "Air Speed: " + characterClasses[1].speedAir; return; } } //Change to the Level Scene //Method Called in OnClick() in the Play Button public void ChangeScene() { foreach(ClassBaseType c in characterClasses) { if (c.dead) return; } SceneManager.LoadScene(2); generated = false; } }