// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2021-03-26 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using TMPro; using UnityEngine; using UnityEngine.UI; namespace G.UI { partial class PetWindow { public class SkillWidget : KUIWidget { #region Field #pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null [KUIFlag] Image _imgIcon; [KUIFlag] GameObject _goLock; [KUIFlag] TextMeshProUGUI _tmpLock; [KUIFlag] Button _imgFrame; [KUIFlag] Toggle _tgRecastLock; #pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null #endregion #region Method public override void Refresh() { if (this.data is PetProxy.PetSkillInfo petSkill) { IconProxy.Instance.SetSprite(_imgIcon, petSkill.item.icon); if (_goLock) { _goLock.SetActive(petSkill.grade > 0); if (_tmpLock) _tmpLock.text = $"{petSkill.grade}级"; } if (_tgRecastLock) _tgRecastLock.gameObject.SetActive(true); } else { _imgIcon.overrideSprite = null; if (_goLock) { _goLock.SetActive(true); } if (_tgRecastLock) _tgRecastLock.gameObject.SetActive(false); } } public bool IsRecastLocked() { if (_tgRecastLock) return _tgRecastLock.isOn; return false; } public void SetRecastLock(bool isOn) { if (_tgRecastLock) _tgRecastLock.isOn = isOn; } private void OnFrameBtnClick() { if (this.data is PetProxy.PetSkillInfo petSkill) { GetWindow().ShowSkillDetail(petSkill); } } private void OnLockValueChanged(bool value) { var result = GetWindow().LockSkill(this); if (value && !result) { SetRecastLock(false); ToastBox.ShowText("无法锁定全部技能"); } } #endregion #region Unity /// /// /// private void Awake() { SetViewData(); _imgFrame.onClick.AddListener(this.OnFrameBtnClick); if (_tgRecastLock) _tgRecastLock.onValueChanged.AddListener(this.OnLockValueChanged); } #endregion } } }