using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace Snxxz.UI { public class TreasurePotentialBehaviour : MonoBehaviour { [SerializeField] Transform m_ContainerLock; [SerializeField] Transform m_ContainerUnlock; [SerializeField] Text m_PotentialName; [SerializeField] Text m_PotentialLevel; [SerializeField] Text m_PotentialLimit; [SerializeField] Text m_PotentialCondition; [SerializeField] Image m_PotentialIcon; [SerializeField] Button m_Func; [SerializeField] RedpointBehaviour m_Redpoint; [SerializeField] UIEffect m_UnlockEffect; int skillId = 0; TreasureSkillModel model { get { return ModelCenter.Instance.GetModel(); } } private void Awake() { m_Func.AddListener(OnFunc); } public void Display(int skillId) { this.skillId = skillId; bool isOpen = model.IsPotentialUnlock(skillId); m_ContainerLock.gameObject.SetActive(!isOpen); m_ContainerUnlock.gameObject.SetActive(isOpen); TreasurePotential potential; if (model.TryGetPotential(skillId, out potential)) { { var skillConfig = potential.GetSkillConfig(potential.level); m_PotentialName.text = skillConfig.SkillName; m_PotentialIcon.SetSprite(skillConfig.IconName); m_PotentialLimit.gameObject.SetActive(potential.level == 0); m_PotentialLevel.gameObject.SetActive(potential.level > 0); m_PotentialLevel.text = StringUtility.Contact("LV", potential.level); m_PotentialIcon.material = potential.level > 0 ? MaterialUtility.GetUIDefaultGraphicMaterial() : MaterialUtility.GetInstantiatedSpriteGrayMaterial(); } if (!isOpen) { var treasureSkillId = 0; if (model.ContainsSkill(skillId, out treasureSkillId)) { var skillConfig = SkillConfig.Get(treasureSkillId); m_PotentialCondition.text = Language.Get("TreasurePotentialUnlock", skillConfig.SkillName, potential.openLevel); } } m_Redpoint.redpointId = potential.levelUpRedpoint.id; } } public void StartUnlock() { m_UnlockEffect.Play(); } public void StopUnlock() { m_UnlockEffect.StopImediatly(); } private void OnFunc() { bool isOpen = model.IsPotentialUnlock(skillId); if (isOpen) { TreasurePotentialLevelUpWin.selectPotentialId = skillId; WindowCenter.Instance.Open(); } } } }