// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2020-09-12 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using TMPro; using UnityEngine; using UnityEngine.UI; namespace G.UI { partial class KungfuPanel { /// /// /// public class BookWidget : KUIWidget { #region Field #pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null [KUIFlag] Button _imgFrame; [KUIFlag] Image _imgIcon; [KUIFlag] TextMeshProUGUI _tmpName; [KUIFlag] TextMeshProUGUI _tmpGrade; [KUIFlag] GameObject _goMaxGrade; [KUIFlag] GameObject _goGrade; [KUIFlag] GameObject _goLocked; [KUIFlag] GameObject _goLight; [KUIFlag] GameObject _goStudyFx; #pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null #endregion #region Method public override void Refresh() { if (this.data is ItemKungfu kungfuBook) { _goLight.SetActive(false); _goStudyFx.SetActive(false); IconProxy.Instance.SetSprite(_imgIcon, kungfuBook.icon); _tmpName.text = kungfuBook.name; if (kungfuBook.grade > 0) { _goLocked.SetActive(false); _goGrade.SetActive(true); if (kungfuBook.isMaxGrade) { _goMaxGrade.SetActive(true); _tmpGrade.gameObject.SetActive(false); } else { _goMaxGrade.SetActive(false); _tmpGrade.gameObject.SetActive(true); _tmpGrade.text = $"{kungfuBook.grade}/{kungfuBook.gradeMax}"; } } else { _goGrade.SetActive(false); _goLocked.SetActive(true); } } } public void ShowHighlight(bool visible) { _goLight.SetActive(visible); } public void ShowStudyFx(bool visible) { _goStudyFx.SetActive(visible); } public void OnFrameBtnClick() { PostNotification(GlobalDefine.EVENT_KUNGFU_DETAIL, this.data); } #endregion #region Unity /// /// /// private void Awake() { SetViewData(); _imgFrame.onClick.AddListener(this.OnFrameBtnClick); } #endregion } } }