TemporaryEquipEquipItemCtrl.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FairyGUI;
  7. using FL.Data;
  8. using FL.Data.Items;
  9. using XGame.Database;
  10. using XGame.Framework.UI;
  11. namespace FL.FGUI
  12. {
  13. /// <summary>
  14. /// UI逻辑处理类
  15. /// </summary>
  16. /// <typeparam name=""></typeparam>
  17. public partial class TemporaryEquipEquipItemCtrl : UIController<TemporaryEquipEquipItemVM>
  18. {
  19. protected override void OnEnable(object intent)
  20. {
  21. AddUIListenres();
  22. }
  23. protected override void OnDisable()
  24. {
  25. RemoveUIListenres();
  26. }
  27. #region UI事件
  28. private void AddUIListenres()
  29. {
  30. }
  31. private void RemoveUIListenres()
  32. {
  33. }
  34. #endregion
  35. public void OnRefresh(int index, EquipItem equipData)
  36. {
  37. UiParam _uiParam = new UiParam();
  38. _uiParam.bShowBtn = true;
  39. _uiParam.bShowName = false;
  40. _uiParam.bShowCount = false;
  41. _uiParam.bShowLevel = true;
  42. VM.ItemBtn.Ctrl.ShowUI(equipData, _uiParam);
  43. VM.EquipCtrl.selectedIndex = GetCompareValue(equipData);
  44. }
  45. /// <summary>
  46. /// 装备战力比较标识
  47. /// </summary>
  48. private int GetCompareValue(EquipItem equipData)
  49. {
  50. int compareFlag = 0;
  51. if (equipData?.Table?.Part > 0)
  52. {
  53. long compareFightingPower = equipData?.FightingPower ?? 0;
  54. var equipItem = EquipData.Instance.GetWearEquipData(equipData.Table.Part);
  55. long wearFightingPower = equipItem?.FightingPower ?? 0;
  56. if (compareFightingPower > wearFightingPower)
  57. compareFlag = 1;
  58. else if (compareFightingPower < wearFightingPower)
  59. compareFlag = 2;
  60. }
  61. return compareFlag;
  62. }
  63. }
  64. }