123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using XGame.Database;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- public class AttributeParam
- {
- public EAttributeType attributeType;
- public long attributeValue;
- }
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class PlayerAttributeItemCtrl : UIController<PlayerAttributeItemVM>
- {
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres()
- {
- }
- private void RemoveUIListenres()
- {
- }
- #endregion
- public void OnRefresh(int index, AttributeParam attrParam)
- {
- var attributeInfo = AttrDescTableRepo.Get((int)attrParam.attributeType);
- if (attributeInfo != null)
- {
- //生命属性 [color=#33CCFF]123456789[/color]
- // 0_固定值(攻击速度比较特殊用万分比形式展示) 1_万分比
- bool bPercentage = attrParam.attributeType == EAttributeType.AtkSpeed || attributeInfo.Num_type == 1;
- string desc = bPercentage ? attrParam.attributeValue.ToRealDoublePercentage() : GetFixedValue(attrParam.attributeValue);
- VM.AttributeLabel.text = $"{attributeInfo.ShowName} [color=#6699CC]{desc}[/color]";
- }
- }
- /// <summary>
- /// 固值显示
- /// </summary>
- /// <returns></returns>
- private string GetFixedValue(long attrValue)
- {
- return attrValue == 0 ? "0" : attrValue.ToString();
- }
- }
- }
|