/// #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; } /// /// UI逻辑处理类 /// /// public partial class PlayerAttributeItemCtrl : UIController { 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]"; } } /// /// 固值显示 /// /// private string GetFixedValue(long attrValue) { return attrValue == 0 ? "0" : attrValue.ToString(); } } }