/// <summary> /// Instantiates a new game object with an attached Troop script. /// Returns the Troop object in that script. /// </summary> public List <Troop> GenerateTroop(TroopClassification classification, Allegiance allegiance) { /// Increment the Allegiance's troop count troopCounts[allegiance][classification] = troopCounts[allegiance][classification] + 1; // Create an empty troop game object Troop troop = GameObject.Instantiate(emptyUnitPrefab).AddComponent <Troop>(); troop.unitName = $"{Utilities.instance.CountToOrdinal(troopCounts[allegiance][classification])}" + $" {Utilities.instance.UppercaseFirstLetter(allegiance.ToString())}" + $" {Utilities.instance.UppercaseFirstLetter(classification.ToString())}"; troop.InitializeTroop(classification, allegiance); return(new List <Troop>() { troop }); }
private void CreateButtonFromSpawnClass(City city) { purchaseButton.GetComponentInChildren <Text>().text = Utilities.instance.UppercaseFirstLetter(classification.ToString()); // Deactivate purchase button if the player doesn't have enough gold to buy the troop // or if the city has already performed an action if (GameManager.instance.GetPlayerLeader().gold < TroopStats.statLedger[classification][Stat.COST]) { purchaseButton.interactable = false; } else { purchaseButton.onClick.AddListener(() => { GameManager.instance.GetPlayerLeader().PurchaseTroop(classification, city); }); purchaseButton.interactable = city.hasAction; } }