using Thousandto.Code.Logic; using Thousandto.Plugins.Common; using UnityEngine; namespace Thousandto.GameUI.Form { /// /// 玩家等级的标签组件 /// public class UIPlayerLevelLabel : MonoCacheBase { #region //UI控件 private GameObject _levelGo; private UILabel _levelLbl; private UILabel _dflevelLbl; private UISprite _dfLevelIcon; private GameObject _dflevelGo; #endregion public void OnFirstShow() { //基础的等级展示 var trans = transform.Find("Level"); if (trans != null) { _levelGo = trans.gameObject; _levelLbl = _levelGo.GetComponent(); } //巅峰的等级展示 trans = transform.Find("DFLevel"); if (trans != null) { _dflevelGo = trans.gameObject; var tmpTrans = _dflevelGo.transform.Find("Text"); if (tmpTrans != null) { _dflevelLbl = tmpTrans.GetComponent(); } tmpTrans = _dflevelGo.transform.Find("Icon"); if (tmpTrans != null) { _dfLevelIcon = tmpTrans.GetComponent(); } } } //直接设置文本--不显示标记. public void SetLabelText(string text) { if (_levelGo != null && !_levelGo.activeSelf) { _levelGo.SetActive(true); } if (_dflevelGo != null && _dflevelGo.activeSelf) { _dflevelGo.SetActive(false); } if (_levelLbl != null) _levelLbl.text = text; } //设置等级到标签,显示巅峰标记 public void SetLevel(int level) { int dfLevel; if (CommonUtils.TryGetDFLevel(level, out dfLevel)) { if (_levelGo != null) _levelGo.SetActive(false); if(_dflevelGo != null) _dflevelGo.SetActive(true); if (_dflevelLbl != null) _dflevelLbl.text = dfLevel.ToString(); } else { if(_levelGo != null) _levelGo.SetActive(true); if (_dflevelGo != null) _dflevelGo.SetActive(false); if (_levelLbl != null) _levelLbl.text = string.Format(Thousandto.Cfg.Data.DeclareMessageString.Get(Thousandto.Cfg.Data.DeclareMessageString.C_UI_LEVELLV), dfLevel); } } //设置等级到标签,不过不带有任何巅峰的标记 public void SetLevelOutFlag(int level) { int dfLevel; CommonUtils.TryGetDFLevel(level, out dfLevel); if (_levelGo != null && !_levelGo.activeSelf) { _levelGo.SetActive(true); } if (_dflevelGo != null && _dflevelGo.activeSelf) { _dflevelGo.SetActive(false); } if (_levelLbl != null) _levelLbl.text = dfLevel.ToString(); } public void SetColor(Color color) { if (_dflevelLbl != null) _dflevelLbl.color = color; if (_levelLbl != null) _levelLbl.color = color; } public void SetIconIsGray(bool isGray) { if (_dfLevelIcon != null) _dfLevelIcon.IsGray = isGray; } } }