EquipAttrItemNestedCtrl.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using XGame.Database;
  7. using XGame.Framework.UI;
  8. namespace FL.FGUI
  9. {
  10. // 属性比较枚举
  11. public enum eCompareType
  12. {
  13. None = 0,
  14. Low = 1, // 红色箭头(属性比原来低)
  15. Higth = 2, // 绿色向上箭头(属性比原来的高)
  16. New = 3, // 新的属性
  17. }
  18. /// <summary>
  19. /// UI逻辑处理类
  20. /// </summary>
  21. /// <typeparam name=""></typeparam>
  22. public partial class EquipAttrItemNestedCtrl : UIController<EquipAttrItemNestedVM>
  23. {
  24. protected override void OnEnable(object intent)
  25. {
  26. AddUIListenres();
  27. }
  28. protected override void OnDisable()
  29. {
  30. RemoveUIListenres();
  31. }
  32. #region UI事件
  33. private void AddUIListenres()
  34. {
  35. }
  36. private void RemoveUIListenres()
  37. {
  38. }
  39. #endregion
  40. public void ShowUI(EAttributeType attributeType, long attributeVal, eCompareType compareType, bool bShow)
  41. {
  42. VM.Show.selectedIndex = bShow ? 1 : 0;
  43. if (!bShow) return;
  44. VM.Compare.selectedIndex = (int)compareType;
  45. var attributeInfo = AttrDescTableRepo.Get((int)attributeType);
  46. VM.AttrLabel.text = GetAttributeDesc(attributeInfo, attributeVal, attributeType == EAttributeType.AtkSpeed);
  47. bool bSpecialAttr = attributeType.IsItemSpecial();
  48. VM.DescLabel.visible = bSpecialAttr;
  49. if (bSpecialAttr)
  50. {
  51. VM.DescLabel.text = attributeInfo.ShowName;
  52. }
  53. }
  54. private string GetAttributeDesc(AttrDescTable attributeInfo, long attrVal, bool bAtkSpeed)
  55. {
  56. string desc = attributeInfo.Num_type == 1 ? TableUtils.ToRealDouble(attrVal).ToString("F3") + "%" :
  57. (bAtkSpeed ? TableUtils.ToRealDouble(attrVal).ToString("F1") : attrVal.ToString());
  58. return $"{attributeInfo.ShowName} {desc}";
  59. }
  60. public void ResetUI()
  61. {
  62. VM.Compare.selectedIndex = 0;
  63. VM.AttrLabel.text = string.Empty;
  64. VM.DescLabel.text = string.Empty;
  65. }
  66. }
  67. }