12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using XGame.Database;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- // 属性比较枚举
- public enum eCompareType
- {
- None = 0,
- Low = 1, // 红色箭头(属性比原来低)
- Higth = 2, // 绿色向上箭头(属性比原来的高)
- New = 3, // 新的属性
- }
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class EquipAttrItemNestedCtrl : UIController<EquipAttrItemNestedVM>
- {
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres()
- {
- }
- private void RemoveUIListenres()
- {
- }
- #endregion
- public void ShowUI(EAttributeType attributeType, long attributeVal, eCompareType compareType, bool bShow)
- {
- VM.Show.selectedIndex = bShow ? 1 : 0;
- if (!bShow) return;
- VM.Compare.selectedIndex = (int)compareType;
- var attributeInfo = AttrDescTableRepo.Get((int)attributeType);
- VM.AttrLabel.text = GetAttributeDesc(attributeInfo, attributeVal, attributeType == EAttributeType.AtkSpeed);
- //bool bSpecialAttr = attributeType.IsItemSpecial();
- //VM.DescLabel.visible = bSpecialAttr;
- //if (bSpecialAttr)
- //{
- // VM.DescLabel.text = attributeInfo.ShowName;
- //}
- }
- private string GetAttributeDesc(AttrDescTable attributeInfo, long attrVal, bool bAtkSpeed)
- {
- bool bPercentage = bAtkSpeed || attributeInfo.Num_type == 1;
- string desc = bPercentage ? attrVal.ToRealDoublePercentage() : (attrVal == 0 ? "0" : attrVal.ToString());
- return $"{attributeInfo.ShowName} {desc}";
- }
- public void ResetUI()
- {
- VM.Compare.selectedIndex = 0;
- VM.AttrLabel.text = string.Empty;
- //VM.DescLabel.text = string.Empty;
- }
- }
- }
|