PlayerAttributeItemCtrl.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. public class AttributeParam
  11. {
  12. public EAttributeType attributeType;
  13. public long attributeValue;
  14. }
  15. /// <summary>
  16. /// UI逻辑处理类
  17. /// </summary>
  18. /// <typeparam name=""></typeparam>
  19. public partial class PlayerAttributeItemCtrl : UIController<PlayerAttributeItemVM>
  20. {
  21. protected override void OnEnable(object intent)
  22. {
  23. AddUIListenres();
  24. }
  25. protected override void OnDisable()
  26. {
  27. RemoveUIListenres();
  28. }
  29. #region UI事件
  30. private void AddUIListenres()
  31. {
  32. }
  33. private void RemoveUIListenres()
  34. {
  35. }
  36. #endregion
  37. public void OnRefresh(int index, AttributeParam attrParam)
  38. {
  39. var attributeInfo = AttrDescTableRepo.Get((int)attrParam.attributeType);
  40. if (attributeInfo != null)
  41. {
  42. //生命属性 [color=#33CCFF]123456789[/color]
  43. string format = attrParam.attributeValue > 0 ? "F3" : "F0";
  44. string desc = attributeInfo.Num_type == 1 ? TableUtils.ToRealDouble(attrParam.attributeValue).ToString(format) + "%" :
  45. (attrParam.attributeType == EAttributeType.AtkSpeed ? TableUtils.ToRealDouble(attrParam.attributeValue).ToString("F1") : attrParam.attributeValue.ToString());
  46. VM.AttributeLabel.text = $"{attributeInfo.ShowName} [color=#6699CC]{desc}[/color]";
  47. }
  48. }
  49. }
  50. }