MountUpgradeSuccessfulPanelCtrl.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using System.Collections.Generic;
  7. using XGame.Database;
  8. using XGame.Framework.UI;
  9. namespace FL.FGUI
  10. {
  11. public struct AdvancedMountParam
  12. {
  13. public int oldStarLv;
  14. public int curStarLv;
  15. public int attrType;
  16. public int oldAttrValue;
  17. public int curAttrValue;
  18. }
  19. /// <summary>
  20. /// UI逻辑处理类
  21. /// </summary>
  22. /// <typeparam name=""></typeparam>
  23. public partial class MountUpgradeSuccessfulPanelCtrl : UIController<MountUpgradeSuccessfulPanelVM>
  24. {
  25. protected override void OnEnable(object intent)
  26. {
  27. AddUIListenres();
  28. ShowUI();
  29. }
  30. protected override void OnDisable()
  31. {
  32. RemoveUIListenres();
  33. }
  34. #region UI事件
  35. private void AddUIListenres()
  36. {
  37. }
  38. private void RemoveUIListenres()
  39. {
  40. }
  41. #endregion
  42. private void ShowUI()
  43. {
  44. int mountId = MountService.Instance.upgradeMountId;
  45. int oldStarLv = MountService.Instance.mountStarLv;
  46. int curStarLv = MountData.Instance.GetAdvancedMountLv(mountId);
  47. var oldStarInfo = zuoqiStarTableRepo.Get(mountId * 10000 + oldStarLv);
  48. if (oldStarInfo == null)
  49. {
  50. XGame.Log.Error($"坐骑表zuoqiStar中不存在id:{mountId * 10000 + oldStarLv}");
  51. return;
  52. }
  53. int[] oldStarOwnAttr = oldStarInfo.LevelOwnAttr;
  54. var curStarInfo = zuoqiStarTableRepo.Get(mountId * 10000 + curStarLv);
  55. if (curStarInfo == null)
  56. {
  57. XGame.Log.Error($"坐骑表zuoqiStar中不存在id:{mountId * 10000 + curStarLv}");
  58. return;
  59. }
  60. ShowAttrUI(oldStarLv, curStarLv, oldStarOwnAttr, curStarInfo.LevelOwnAttr);
  61. }
  62. private void ShowAttrUI(int oldStarLv, int curStarLv, int[] oldStarOwnAttr, int[] curStarOwnAttr)
  63. {
  64. var attrDataList = new List<AdvancedMountParam>();
  65. for (int i = 0; i < curStarOwnAttr.Length; i+=2)
  66. {
  67. attrDataList.Add(new AdvancedMountParam()
  68. {
  69. oldStarLv = oldStarLv,
  70. curStarLv = curStarLv,
  71. attrType = curStarOwnAttr[i],
  72. oldAttrValue = oldStarOwnAttr[i+1],
  73. curAttrValue = curStarOwnAttr[i+1]
  74. });
  75. }
  76. VM.AttrList.BindDatas(attrDataList);
  77. }
  78. }
  79. }