/// #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, // 新的属性
}
///
/// UI逻辑处理类
///
///
public partial class EquipAttrItemNestedCtrl : UIController
{
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)
{
string desc = attributeInfo.Num_type == 1 ? TableUtils.ToRealDouble(attrVal).ToString("F3") + "%" :
(bAtkSpeed ? TableUtils.ToRealDouble(attrVal).ToString("F1") : attrVal.ToString());
return $"{attributeInfo.ShowName} {desc}";
}
public void ResetUI()
{
VM.Compare.selectedIndex = 0;
VM.AttrLabel.text = string.Empty;
//VM.DescLabel.text = string.Empty;
}
}
}