public void showUpgradeSelectUi(List <Upgrade> upgrades) { destroyUpgradeSelectUi(); upgradeSelect.SetActive(true); foreach (Upgrade upgrade in upgrades) { GameObject upgradeInstance = GameObject.Instantiate(upgradePrefab, new Vector3(0, 0, 0), Quaternion.identity); UpgradeGameObject upgradeGameObject = upgradeInstance.GetComponentInChildren <UpgradeGameObject>(); upgradeGameObject.initUpgrade(upgrade); upgrade.actions.onClickAction = () => { addUpgradeUi(upgrade); upgradeService.addUpgrade(upgradeGameObject); upgradeSelect.SetActive(false); destroyUpgradeSelectUi(); }; upgradeInstance.transform.SetParent(upgradeSelect.transform); } }
public void addUpgrade(UpgradeGameObject upgradeGameObjecte) { upgradeGameObjecte.upgrade.actions.onPickup(); gameData.upgradeGameData.heldUpgrades.Add(upgradeGameObjecte); gameData.upgradeGameData.upgradePool.Remove(upgradeGameObjecte.upgrade); }