using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; public enum UpgradeType { Attack, Defense } [CreateAssetMenu(fileName = "New Upgrade", menuName = "CharacterUpgrades/UpgradeData")] public class UpgradeData : ScriptableObject { [SerializeField] private GameObject upgradeInfoPanelPrefab; [TextArea] public string upgradeDescription; public UpgradeType upgradeType; public int requiredLevel; public int goldAmount; public int upgradeIndex; public bool isUnlocked; public int attackBonus; // Optional: Use only if this upgrade impacts attack public int defenseBonus; // Optional: Use only if this upgrade impacts defense public GameObject Display(GameObject obj) { // Instantiate the panel GameObject panelInstance = Instantiate(upgradeInfoPanelPrefab, obj.transform); // Get references to the text components TextMeshProUGUI descriptionText = panelInstance.transform.Find("DescriptionText").GetComponent<TextMeshProUGUI>(); TextMeshProUGUI statusText = panelInstance.transform.Find("StatusText").GetComponent<TextMeshProUGUI>(); TextMeshProUGUI gold = panelInstance.transform.Find("Requirements") .Find("Gold") .Find("GoldAmount") .GetComponent<TextMeshProUGUI>(); TextMeshProUGUI level = panelInstance.transform.Find("Requirements") .Find("Level") .Find("LevelAmount") .GetComponent<TextMeshProUGUI>(); // Set the text values based on the UpgradeData descriptionText.text = upgradeDescription; gold.text = goldAmount.ToString(); level.text = requiredLevel.ToString(); statusText.text = isUnlocked ? "Locked" : "Unlocked"; return panelInstance; } }