using System.Collections.Generic; using UnityEngine; using Ability; using TMPro; using UnityEngine.UI; public class AddInGameAbilityDialog : BaseDialog { [SerializeField] TextMeshProUGUI m_headerText; [SerializeField] TextMeshProUGUI m_labelChoose; [SerializeField] TextMeshProUGUI m_labelLearned; [SerializeField] GameObject m_learnedAbilityHeader; List m_inGameAbTypes = new List(); List m_generatedAb = new List(); List m_learnedAbContainer = new List(); GameObject m_learnedAbObj; //----------------------------------------------------------------------------------------- void Start () { SoundsManager.Instance.PlaySound("level_up"); m_type = DialogType.ADD_IN_GAME_ABILITY_DIALOG; } //----------------------------------------------------------------------------------------- public void Init() { Transform learnedAbTrans = transform.Find("learned_abilities"); if (learnedAbTrans) m_learnedAbObj = learnedAbTrans.gameObject; else CommonFunctions.myassert(false); GenerateInGameAb(); InitAbIcons(); InitTexts(); InitLearnedAbilities(); } //----------------------------------------------------------------------------------------- void InitLearnedAbilities() { MainCharacter mainChar = GameBoard.Instance.MainCharacter; int idx = 0; if (mainChar.InGameAb.Count == 0) m_learnedAbilityHeader.SetActive(false); foreach (InGameAbType type in mainChar.InGameAb.Keys) { AddIconToLearnedAbField(type, idx); idx++; if (idx > 4) idx = 0; } } //----------------------------------------------------------------------------------------- string GetAbNameByType(InGameAbType type) { string abName = ""; if (type == InGameAbType.ADD_ATTACK_SPEED) abName = "attackspeed"; else if (type == InGameAbType.ADD_BULLET_45) abName = "bullet45"; else if (type == InGameAbType.ADD_BULLET_AFTER) abName = "bulletafter"; else if (type == InGameAbType.ADD_BULLET_PARALLEL) abName = "bulletparallel"; else if (type == InGameAbType.ADD_BULLET_RICOCHET) abName = "bulletricocket"; else if (type == InGameAbType.ADD_DAMAGE) abName = "damage"; else if (type == InGameAbType.ADD_DROP_GOLD) abName = "dropgold"; else if (type == InGameAbType.ADD_HEADSHOT) abName = "headshot"; else if (type == InGameAbType.ADD_HEALTH) abName = "health"; else if (type == InGameAbType.ADD_XP) abName = "exp"; else if (type == InGameAbType.ADD_MINOR_DAMAGE) abName = "minordamage"; else if (type == InGameAbType.ADD_MINOR_SPEED) abName = "minorattackspeed"; return abName; } //----------------------------------------------------------------------------------------- void AddIconToLearnedAbField(InGameAbType type, int idx) { string prefabName = "Prefabs/UI/InGameAbIcons/" + GetAbNameByType(type); GameObject iconObj = Instantiate(Resources.Load(prefabName) as GameObject); iconObj.transform.SetParent(m_learnedAbObj.transform); iconObj.transform.localScale = Vector3.one; iconObj.GetComponent().DisableAbName(); iconObj.GetComponent