// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2021-04-12 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using TMPro; using UnityEngine; using UnityEngine.UI; namespace G.UI { /// /// /// public class BeautySkillPanel : KUIWidget { class SkillWidget : KUIWidget { #pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null [KUIFlag] Button _btnUpgrade; [KUIFlag] TextMeshProUGUI _tmpName; [KUIFlag] TextMeshProUGUI _tmpDescription; [KUIFlag] TextMeshProUGUI _tmpDescription2; [KUIFlag] TextMeshProUGUI _tmpDescription3; [KUIFlag] TextMeshProUGUI _tmpNumber; #pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null public override void Refresh() { if (this.data is ItemBeautySkill skill) { if (skill.isMax) { _tmpName.text = $"{skill.name} (Lv.max)"; _tmpDescription2.text = skill.currGradeText; _tmpDescription.text = ""; _tmpDescription3.text = ""; _btnUpgrade.gameObject.SetActive(false); } else if (skill.grade > 0) { _tmpName.text = $"{skill.name} (Lv.{skill.grade}/{skill.maxGrade})"; _tmpDescription.text = "";// skill.currGradeText; _tmpDescription2.text = skill.nextGradeText; _tmpDescription3.text = "升级所需:" + skill.upgradeText; _btnUpgrade.gameObject.SetActive(true); } else { _tmpName.text = skill.name; _tmpDescription.text = "解锁效果:" + skill.currGradeText; _tmpDescription2.text = ""; _tmpDescription3.text = "解锁条件:" + skill.unlockText; _btnUpgrade.gameObject.SetActive(false); } _tmpNumber.text = (this.index + 1).ToString(); } } private void OnUpgradeBtnClick() { if (_Instance.UpgradeSkill(this.data as ItemBeautySkill)) { Refresh(); } SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND); } private void Awake() { SetViewData(); _btnUpgrade.onClick.AddListener(this.OnUpgradeBtnClick); } } #region Field #pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null [KUIFlag] Button _btnClose; [KUIFlag] GameObject __goProp1; [KUIFlag] KUIList __listSkills; #pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null private MoneyWidget _propItem2; #endregion #region Method public override void Refresh() { if (this.data is BeautyProxy.BeautyInfo beauty) { _propItem2.SetMoney(Item.Id.kBeautyExp, beauty.exp); __listSkills.Clear(); for (int i = 0; i < beauty.skills.Length; i++) { __listSkills.GetItem().SetData(beauty.skills[i]); } } } private void RefreshMoney() { if (this.data is BeautyProxy.BeautyInfo beauty) { _propItem2.SetMoney(Item.Id.kBeautyExp, beauty.exp); } } private void OnCloseBtnClick() { this.Close(); SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND); } private bool UpgradeSkill(ItemBeautySkill skill) { var result = BeautyProxy.Instance.UpgradeBeautySkill(this.data as BeautyProxy.BeautyInfo, skill); if (result) { RefreshMoney(); ToastBox.ShowText("升级成功"); } else { ToastBox.ShowText("红颜经验不足."); } return result; } #endregion #region Unity private static BeautySkillPanel _Instance; /// /// /// private void Awake() { _Instance = this; SetViewData(); _btnClose.onClick.AddListener(this.OnCloseBtnClick); _propItem2 = __goProp1.AddComponent(); __listSkills.AddTemplate(true); } #endregion } }