ZhuanPanPanel.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. using System;
  2. using System.Collections.Generic;
  3. using Common.Utility.CombatEvent;
  4. using Fort23.Core;
  5. using GameLogic.Combat.CombatTool;
  6. using GameLogic.Combat.Hero;
  7. using GameLogic.Combat.Hero.Turntable;
  8. using GameLogic.Combat.Skill;
  9. using UnityEngine;
  10. namespace Fort23.Mono
  11. {
  12. [UIBinding(prefab = "ZhuanPanPanel")]
  13. public partial class ZhuanPanPanel : UIComponent
  14. {
  15. private List<gf_widget> _gfWidgets = new List<gf_widget>();
  16. public async CTask ShowPanel()
  17. {
  18. UIManager.Instance.DormancyAllGComponent<WuXingGongFaWidget>();
  19. for (int i = 0; i < 5; i++)
  20. {
  21. double hd = i * 72 * Math.PI / 180f;
  22. double a = Math.Cos(hd);
  23. double b = -Math.Sin(hd);
  24. double c = Math.Sin(hd);
  25. double d = a;
  26. double x = a * 0 + b * 57;
  27. double y = c * 0 + d * 57;
  28. int index = i;
  29. WuXingGongFaWidget widget = await UIManager.Instance.CreateGComponentForObject<WuXingGongFaWidget>(
  30. WuXingGongFaWidget, null, root: pan,
  31. isInstance: true);
  32. widget.transform.anchoredPosition = new Vector2((float)x, (float)y);
  33. widget.ShowWidget(index);
  34. }
  35. ExercisesAlter(null);
  36. }
  37. private void Init()
  38. {
  39. }
  40. public override void AddEvent()
  41. {
  42. StaticUpdater.Instance.AddLateUpdateCallBack(Update);
  43. CombatEventManager.Instance.AddEventListener(CombatEventType.ExercisesAlter, ExercisesAlter);
  44. CombatEventManager.Instance.AddEventListener(CombatEventType.TaoismSkillAlter, TaoismSkillAlter);
  45. }
  46. public override void DelEvent()
  47. {
  48. StaticUpdater.Instance.RemoveLateUpdateCallBack(Update);
  49. CombatEventManager.Instance.RemoveEventListener(CombatEventType.ExercisesAlter, ExercisesAlter);
  50. // CombatEventManager.Instance.RemoveEventListener(CombatEventType.AddUseGongFa, AddUseGongFa);
  51. CombatEventManager.Instance.RemoveEventListener(CombatEventType.TaoismSkillAlter, TaoismSkillAlter);
  52. }
  53. public override void AddButtonEvent()
  54. {
  55. lanLiang_button.onClick.AddListener(() => { SkillSelectPanel.OpenSkillSelectPanel(); });
  56. }
  57. private void TaoismSkillAlter(IEventData iEventData)
  58. {
  59. }
  60. private async void ExercisesAlter(IEventData iEventData)
  61. {
  62. _gfWidgets.Clear();
  63. UIManager.Instance.DormancyAllGComponent<gf_widget>();
  64. CombatHeroSkillControl combatHeroSkillControl = CombatController.currActiveCombat.CombatHeroController
  65. .playerHeroEntity.CombatHeroSkillControl
  66. .This<CombatHeroSkillControl>();
  67. for (int i = 0; i < combatHeroSkillControl.SkillTurntable.allSkillSlots.Count; i++)
  68. {
  69. SkillSlots skillBasic = combatHeroSkillControl.SkillTurntable.allSkillSlots[i];
  70. if (skillBasic == null)
  71. {
  72. continue;
  73. }
  74. gf_widget gfWidget = await UIManager.Instance.CreateGComponentForObject<gf_widget>(this.gf_widget, null,
  75. Gf_root, isInstance: true);
  76. gfWidget.SkillSlots = skillBasic;
  77. gfWidget.InitWidget(skillBasic,CombatController.currActiveCombat.CombatHeroController
  78. .playerHeroEntity);
  79. _gfWidgets.Add(gfWidget);
  80. }
  81. }
  82. public void Update()
  83. {
  84. if (CombatController.currActiveCombat == null ||
  85. CombatController.currActiveCombat.CombatHeroController == null ||
  86. CombatController.currActiveCombat.CombatHeroController.playerHeroEntity == null || CombatController
  87. .currActiveCombat.CombatHeroController.playerHeroEntity.CombatHeroSkillControl == null)
  88. {
  89. return;
  90. }
  91. CombatHeroSkillControl combatHeroSkillControl = CombatController.currActiveCombat.CombatHeroController
  92. .playerHeroEntity.CombatHeroSkillControl
  93. .This<CombatHeroSkillControl>();
  94. if (combatHeroSkillControl.taoismSkillBasic != null)
  95. {
  96. DS60101 ds60101 = combatHeroSkillControl.taoismSkillBasic as DS60101;
  97. if (ds60101 != null)
  98. {
  99. lanLiang.fillAmount = ds60101.currEnergy / ds60101.SelfSkillConfig.effectValue[1];
  100. lanLiang.color = !ds60101._updateTime
  101. ? new Color(1f, 0.96f, 0f)
  102. : new Color(0.96f, 0f, 1f);
  103. }
  104. }
  105. for (int i = 0; i < _gfWidgets.Count; i++)
  106. {
  107. gf_widget gfWidget = _gfWidgets[i];
  108. gfWidget.Update();
  109. double hd = gfWidget.SkillSlots.angle * Math.PI / 180f;
  110. double a = Math.Cos(hd);
  111. double b = -Math.Sin(hd);
  112. double c = Math.Sin(hd);
  113. double d = a;
  114. double x = a * 0 + b * 122;
  115. double y = c * 0 + d * 122;
  116. gfWidget.transform.anchoredPosition = new Vector2((float)x, (float)y);
  117. }
  118. }
  119. }
  120. }