using System.Collections; using System.Collections.Generic; using UnityEngine; public class RewardsControl : MonoBehaviour { //take the stat blocks from the reward units and add them to the reserve list in the singleton. //generate 4 random units to populate the rewards screen [SerializeField] private GameObject gruntPrefab, warriorPrefab, soldierPrefab; [SerializeField] private Transform rewardsListParent; private List<UnitStatBlock> rewardUnitStats = new List<UnitStatBlock>(); private void Awake() { CreateVictoryRewards(); } public void CreateVictoryRewards() { for (int i = 0; i < 4; i++) { int randomUnitType = Random.Range(0, 4); switch (randomUnitType) { case 0: rewardUnitStats.Add(Instantiate(gruntPrefab, rewardsListParent).GetComponent<UnitIconControl>().UnitStats); break; case 1: rewardUnitStats.Add(Instantiate(warriorPrefab, rewardsListParent).GetComponent<UnitIconControl>().UnitStats); break; case 2: rewardUnitStats.Add(Instantiate(soldierPrefab, rewardsListParent).GetComponent<UnitIconControl>().UnitStats); break; default: break; } } } public void AddAllUnitsToReserve() //called when returning to unit select scene { Singleton.Instance.ReserveUnitRoster.units.AddRange(rewardUnitStats); Singleton.Instance.ReserveUnitRoster.units.AddRange(Singleton.Instance.UnitRoster.units); Singleton.Instance.UnitRoster.units.Clear(); } }