MountUpgradePreviewPanelCtrl.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using UnityEngine;
  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 MountUpgradePreviewPanelCtrl : UIController<MountUpgradePreviewPanelVM>
  18. {
  19. protected override void OnEnable(object intent)
  20. {
  21. AddUIListenres();
  22. if (intent != null)
  23. {
  24. ShowUI(intent as List<UpgradePreviewParam>);
  25. }
  26. }
  27. protected override void OnDisable()
  28. {
  29. RemoveUIListenres();
  30. }
  31. #region UI事件
  32. private void AddUIListenres()
  33. {
  34. }
  35. private void RemoveUIListenres()
  36. {
  37. }
  38. #endregion
  39. private void ShowUI(List<UpgradePreviewParam> upgradePreviewList)
  40. {
  41. if (upgradePreviewList.Count > 0)
  42. {
  43. int mountId = upgradePreviewList[0].mountId;
  44. int curLv = MountData.Instance.GetAdvancedMountLv(mountId);
  45. int nextSkillId = 0;
  46. for (int i = 0; i < upgradePreviewList.Count; i++)
  47. {
  48. if (upgradePreviewList[i].level > curLv)
  49. {
  50. nextSkillId = upgradePreviewList[i].skillId;
  51. ShowUnlockStarUI(upgradePreviewList[i].level);
  52. break;
  53. }
  54. }
  55. //10000*坐骑id+1
  56. var curStarInfo = zuoqiStarTableRepo.Get(mountId * 10000 + curLv);
  57. if (curStarInfo == null)
  58. {
  59. XGame.Log.Error($"坐骑zuoqiStar表不存在id:{mountId * 10000 + curLv}");
  60. return;
  61. }
  62. ShowCurSkillUI(curStarInfo.StarSkill);
  63. ShowNextSkillUI(nextSkillId);
  64. }
  65. }
  66. private void ShowCurSkillUI(int skillId)
  67. {
  68. var curSkillInfo = SkillTableRepo.Get(skillId);
  69. if (curSkillInfo == null)
  70. {
  71. XGame.Log.Error($"技能表不存在skillId:{skillId}");
  72. return;
  73. }
  74. VM.SkillNameLabel.text = curSkillInfo.Name;
  75. VM.SkillDescLabel.text = curSkillInfo.Desc;
  76. }
  77. private void ShowNextSkillUI(int skillId)
  78. {
  79. var skillInfo = SkillTableRepo.Get(skillId);
  80. if (skillInfo == null)
  81. {
  82. XGame.Log.Error($"技能表不存在skillId:{skillId}");
  83. return;
  84. }
  85. VM.NextSkillNameLabel.text = skillInfo.Name;
  86. VM.NextSkillDescLabel.text = skillInfo.Desc;
  87. }
  88. private void ShowUnlockStarUI(int starLevel)
  89. {
  90. int starNum = starLevel == 0 ? 0 : starLevel % MountData.MaxStarNum;
  91. if (starLevel > 0 && starNum == 0)
  92. starNum = MountData.MaxStarNum;
  93. // 获取星星的色阶
  94. int starStep = Mathf.FloorToInt((starLevel - 1) / MountData.MaxStarNum) + 1;
  95. int[] array = Enumerable.Repeat(starStep, starNum).ToArray();
  96. VM.UnLockStar.BindDatas(array);
  97. }
  98. }
  99. }