PlayerPreviewItemNestedCtrl.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 Unity.Jobs.LowLevel.Unsafe;
  9. using XGame.Database;
  10. using XGame.Framework.UI;
  11. namespace FL.FGUI
  12. {
  13. public struct PreviewParam
  14. {
  15. public bool bSelectJob; // 是否转职路线
  16. public eAdvanceType[] advancedTypeArray; // 进阶职业分支类型
  17. public careerTable curJobInfo;
  18. public List<careerTable> preDataList; // 前置数据(初始职业和10级转职数据)
  19. public Dictionary<eAdvanceType, List<careerTable>> careerDataMap; // 进阶线路数据
  20. }
  21. /// <summary>
  22. /// UI逻辑处理类
  23. /// </summary>
  24. /// <typeparam name=""></typeparam>
  25. public partial class PlayerPreviewItemNestedCtrl : UIController<PlayerPreviewItemNestedVM>
  26. {
  27. protected override void OnEnable(object intent)
  28. {
  29. AddUIListenres();
  30. }
  31. protected override void OnDisable()
  32. {
  33. RemoveUIListenres();
  34. }
  35. #region UI事件
  36. private void AddUIListenres()
  37. {
  38. }
  39. private void RemoveUIListenres()
  40. {
  41. }
  42. #endregion
  43. public void ShowUI(PreviewParam param)
  44. {
  45. if (param.bSelectJob)
  46. {
  47. bool bTransferred = param.curJobInfo.Change_times > 0; // 已转职
  48. bool bAdvanced = param.curJobInfo.Change_times > 1; // 已转职并且进阶过
  49. VM.JobCtrl.selectedIndex = bTransferred ? (bAdvanced ? 2 : 1) : 0;
  50. if (bAdvanced)
  51. {
  52. eAdvanceType advancedType = (eAdvanceType)param.curJobInfo.Type;
  53. int advanceCount = param.curJobInfo.Change_times - 1; // 进阶的次数
  54. if (advancedType == eAdvanceType.ShieldWarrior || advancedType == eAdvanceType.CriticalShooter || advancedType == eAdvanceType.SpellMage)
  55. {
  56. VM.LowerCtrl.selectedIndex = 0;
  57. VM.UpperCtrl.selectedIndex = advanceCount;
  58. }
  59. else
  60. {
  61. VM.UpperCtrl.selectedIndex = 0;
  62. VM.LowerCtrl.selectedIndex = advanceCount;
  63. }
  64. }
  65. else
  66. {
  67. VM.UpperCtrl.selectedIndex = 0;
  68. VM.LowerCtrl.selectedIndex = 0;
  69. }
  70. }
  71. else
  72. {
  73. VM.JobCtrl.selectedIndex = 0;
  74. VM.UpperCtrl.selectedIndex = 0;
  75. VM.LowerCtrl.selectedIndex = 0;
  76. }
  77. ShowJobUI(param);
  78. }
  79. /// <summary>
  80. ///
  81. /// </summary>
  82. /// <param name="param"></param>
  83. private void ShowJobUI(PreviewParam param)
  84. {
  85. var upperDataList = param.careerDataMap[param.advancedTypeArray[0]];
  86. var lowerDataList = param.careerDataMap[param.advancedTypeArray[1]];
  87. bool bUpperCurStep = param.bSelectJob && param.curJobInfo.Type == (int)param.advancedTypeArray[0];
  88. bool bLowerCurStep = param.bSelectJob && param.curJobInfo.Type == (int)param.advancedTypeArray[1];
  89. // 转职次数
  90. int transferCount = param.curJobInfo.Change_times;
  91. VM.JobLv30.Ctrl.ShowUI(param.preDataList[upperDataList[0].Careertype], param.bSelectJob && transferCount == 1);
  92. VM.JobLv60_1.Ctrl.ShowUI(upperDataList[0], bUpperCurStep && transferCount == 2);
  93. VM.JobLv80_1.Ctrl.ShowUI(upperDataList[1], bUpperCurStep && transferCount == 3);
  94. VM.JobLv100_1.Ctrl.ShowUI(upperDataList[2], bUpperCurStep && transferCount == 4);
  95. VM.JobLv120_1.Ctrl.ShowUI(upperDataList[3], bUpperCurStep && transferCount == 5);
  96. VM.JobLv60_2.Ctrl.ShowUI(lowerDataList[0], bLowerCurStep && transferCount == 2);
  97. VM.JobLv80_2.Ctrl.ShowUI(lowerDataList[1], bLowerCurStep && transferCount == 3);
  98. VM.JobLv100_2.Ctrl.ShowUI(lowerDataList[2], bLowerCurStep && transferCount == 4);
  99. VM.JobLv120_2.Ctrl.ShowUI(lowerDataList[3], bLowerCurStep && transferCount == 5);
  100. }
  101. }
  102. }