MountDevelopPanelCtrl.Advanced.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FL.Data;
  7. using System.Collections.Generic;
  8. using XGame.Database;
  9. using XGame.Framework.UI;
  10. namespace FL.FGUI
  11. {
  12. /// <summary>
  13. /// UI逻辑处理类 高级坐骑界面
  14. /// </summary>
  15. /// <typeparam name=""></typeparam>
  16. public partial class MountDevelopPanelCtrl : UIController<MountDevelopPanelVM>
  17. {
  18. private int _curAdvancedIndex; // 当前选择的高级坐骑索引
  19. private List<zuoqiBaseTable> _advancedMountsInfoList; // 高级坐骑信息列表数据
  20. private void GetAdvanceMountData()
  21. {
  22. var dataList = zuoqiBaseTableRepo.GetAll();
  23. foreach (var item in dataList)
  24. {
  25. if (item.Type == 2) // 高级坐骑
  26. {
  27. _advancedMountsInfoList.Add(item);
  28. }
  29. }
  30. }
  31. /// <summary>
  32. /// 显示高级坐骑界面UI
  33. /// </summary>
  34. private void ShowAdvancedMountUI()
  35. {
  36. VM.AdvancedMountList.BindDatas(_advancedMountsInfoList);
  37. }
  38. /// <summary>
  39. /// 高级坐骑的升级预览和启用技能按钮状态
  40. /// </summary>
  41. /// <param name="bSHow"></param>
  42. private void ShowAdvancedMountBtn(bool bShow)
  43. {
  44. VM.UpgradePreviewBtn.visible = bShow;
  45. VM.EnableSkillBtn.visible = bShow;
  46. }
  47. /// <summary>
  48. /// 选择的高级坐骑
  49. /// </summary>
  50. /// <param name="selectIndex"></param>
  51. private void ShowSelectAdvancedMount(int selectIndex)
  52. {
  53. _curAdvancedIndex = selectIndex;
  54. var advancedMountInfo = _advancedMountsInfoList[selectIndex];
  55. if (advancedMountInfo != null)
  56. {
  57. bool bUnlock = MountData.Instance.IsUnLock(advancedMountInfo.Id);
  58. int lv = MountData.Instance.GetAdvancedMountLv(advancedMountInfo.Id);
  59. ShowAttrUI(lv, advancedMountInfo.Id, bUnlock);
  60. if (bUnlock)
  61. {
  62. ShowRideUI(true, advancedMountInfo.Id == MountData.Instance.mountModelId);
  63. ShowEnableSkillBtn(true, advancedMountInfo.Id == MountData.Instance.useSkillMountId);
  64. }
  65. if (lv > 0) ShowMountStar(true);
  66. ShowAdvanceMountStarUI(lv);
  67. }
  68. }
  69. /// <summary>
  70. ///
  71. /// </summary>
  72. /// <param name="bShow"></param>
  73. private void ShowEnableSkillBtn(bool bShow, bool bEnable = false)
  74. {
  75. VM.EnableSkillBtn.visible = bShow;
  76. if (bShow)
  77. {
  78. VM.SkillCtrl.selectedIndex = bEnable ? 1 : 0;
  79. }
  80. }
  81. /// <summary>
  82. /// 是否显示高级坐骑升级预览
  83. /// </summary>
  84. /// <param name="bShow"></param>
  85. private void ShowUpgradePreviewBtn(bool bShow)
  86. {
  87. VM.UpgradePreviewBtn.visible = bShow;
  88. }
  89. /// <summary>
  90. /// 高级坐骑拥有的效果
  91. /// </summary>
  92. /// <param name="curLv"></param>
  93. /// <param name="mountId"></param>
  94. private void ShowAttrUI(int curLv, int mountId, bool bUnlock)
  95. {
  96. int attrType = 0;
  97. int attrVal = 0;
  98. if (curLv == 0)
  99. {
  100. var mountBaseInfo = zuoqiBaseTableRepo.Get(mountId);
  101. XGame.Framework.Assert.IsNotNull(mountBaseInfo,$"坐骑表zuoqiBase中不存在id:{mountId}");
  102. ShowCostUI(mountBaseInfo.Unlock);
  103. attrType = mountBaseInfo.StarOwnAttr[0];
  104. if (mountBaseInfo.StarOwnAttr.Length > 1)
  105. attrVal = mountBaseInfo.StarOwnAttr[1];
  106. }
  107. else
  108. {
  109. //1000*坐骑id+等级
  110. var mountStarInfo = zuoqiStarTableRepo.Get(mountId*1000 + curLv);
  111. XGame.Framework.Assert.IsNotNull(mountStarInfo, $"坐骑表zuoqiStar中不存在id:{mountId * 1000 + curLv}");
  112. ShowCostUI(mountStarInfo.StarUpCost);
  113. attrType = mountStarInfo.LevelOwnAttr[0];
  114. if (mountStarInfo.LevelOwnAttr.Length > 1)
  115. attrVal = mountStarInfo.LevelOwnAttr[1];
  116. }
  117. ShowCurAtrrDesc(attrType, attrVal);
  118. var nextMountStarInfo = zuoqiStarTableRepo.Get(mountId * 1000 + curLv+1);
  119. if (nextMountStarInfo?.LevelOwnAttr?.Length > 1)
  120. {
  121. VM.NextMountAttrDescLabel.text = TableUtils.ToRealDouble(nextMountStarInfo.LevelOwnAttr[1]).ToString("F3") + "%";
  122. }
  123. VM.AdvanceMountStateCtrl.selectedIndex = bUnlock ? (nextMountStarInfo == null ? 2 : 1) : 0;
  124. if (bUnlock)ShowUpgradePreviewBtn(nextMountStarInfo != null);
  125. }
  126. private void ShowCurAtrrDesc(int attrType, int attrValue)
  127. {
  128. var attributeInfo = AttrDescTableRepo.Get(attrType);
  129. if (attributeInfo != null)
  130. {
  131. VM.MountAttrDescLabel.text = attributeInfo.ShowName + TableUtils.ToRealDouble(attrValue).ToString("F3") + "%";
  132. }
  133. }
  134. /// <summary>
  135. /// 高级坐骑解锁|升级消耗UI
  136. /// </summary>
  137. /// <param name="cost"></param>
  138. private void ShowCostUI(int[] cost)
  139. {
  140. var item = ItemService.Instance.GetItemBase(cost[0], cost[1], 0);
  141. VM.UnlockMountItem.Ctrl.ShowUI(item);
  142. }
  143. /// <summary>
  144. /// 显示高级坐骑的星级
  145. /// </summary>
  146. /// <param name="starLv"></param>
  147. private void ShowAdvanceMountStarUI(int starLv)
  148. {
  149. VM.MountStar.GetController("StarLvCtrl").selectedIndex = starLv;
  150. }
  151. /// <summary>
  152. /// 选择某个高级坐骑
  153. /// </summary>
  154. /// <param name="index"></param>
  155. private void ClickAdvancedMountItem(int index)
  156. {
  157. ShowSelectAdvancedMount(index);
  158. var mountItemList = VM.AdvancedMountList.GetChildren();
  159. for (int i = 0; i < mountItemList.Length; i++)
  160. {
  161. if (mountItemList[i] == null)
  162. {
  163. (mountItemList[i].asCom).GetController("SelectCtrl").selectedIndex = i == index ? 1 : 0;
  164. }
  165. }
  166. }
  167. /// <summary>
  168. /// 解锁某个高级坐骑成功
  169. /// </summary>
  170. /// <param name="eventId"></param>
  171. /// <param name="args"></param>
  172. private void UnlockAdvancedMountSucessful(int eventId, object args)
  173. {
  174. ShowSelectAdvancedMount(_curAdvancedIndex);
  175. }
  176. /// <summary>
  177. /// 成功启用某个高级坐骑技能
  178. /// </summary>
  179. /// <param name="eventId"></param>
  180. /// <param name="args"></param>
  181. private void UseMountSkillSucessful(int eventId, object args)
  182. {
  183. ShowEnableSkillBtn(true, _advancedMountsInfoList[_curAdvancedIndex].Id == MountData.Instance.useSkillMountId);
  184. }
  185. /// <summary>
  186. /// 高级坐骑升级成功
  187. /// </summary>
  188. /// <param name="eventId"></param>
  189. /// <param name="args"></param>
  190. private void UpgradeAdvancedMountSucessful(int eventId, object args)
  191. {
  192. ShowSelectAdvancedMount(_curAdvancedIndex);
  193. }
  194. }
  195. }