ZhuanPanPanel.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. }
  36. private void Init()
  37. {
  38. }
  39. public override void AddEvent()
  40. {
  41. StaticUpdater.Instance.AddLateUpdateCallBack(Update);
  42. CombatEventManager.Instance.AddEventListener(CombatEventType.ExercisesAlter, ExercisesAlter);
  43. CombatEventManager.Instance.AddEventListener(CombatEventType.TaoismSkillAlter, TaoismSkillAlter);
  44. }
  45. public override void DelEvent()
  46. {
  47. StaticUpdater.Instance.RemoveLateUpdateCallBack(Update);
  48. CombatEventManager.Instance.RemoveEventListener(CombatEventType.ExercisesAlter, ExercisesAlter);
  49. // CombatEventManager.Instance.RemoveEventListener(CombatEventType.AddUseGongFa, AddUseGongFa);
  50. CombatEventManager.Instance.RemoveEventListener(CombatEventType.TaoismSkillAlter, TaoismSkillAlter);
  51. }
  52. public override void AddButtonEvent()
  53. {
  54. lanLiang_button.onClick.AddListener(() => { SkillSelectPanel.OpenSkillSelectPanel(); });
  55. }
  56. private void TaoismSkillAlter(IEventData iEventData)
  57. {
  58. }
  59. private async void ExercisesAlter(IEventData iEventData)
  60. {
  61. _gfWidgets.Clear();
  62. UIManager.Instance.DormancyAllGComponent<gf_widget>();
  63. CombatHeroSkillControl combatHeroSkillControl = CombatController.currActiveCombat.CombatHeroController
  64. .playerHeroEntity.CombatHeroSkillControl
  65. .This<CombatHeroSkillControl>();
  66. for (int i = 0; i < combatHeroSkillControl.SkillTurntable.allSkillSlots.Count; i++)
  67. {
  68. SkillSlots skillBasic = combatHeroSkillControl.SkillTurntable.allSkillSlots[i];
  69. if (skillBasic == null)
  70. {
  71. continue;
  72. }
  73. gf_widget gfWidget = await UIManager.Instance.CreateGComponentForObject<gf_widget>(this.gf_widget, null,
  74. Gf_root, isInstance: true);
  75. gfWidget.SkillBasic = skillBasic;
  76. gfWidget.InitWidget(skillBasic);
  77. _gfWidgets.Add(gfWidget);
  78. }
  79. }
  80. public void Update()
  81. {
  82. if (CombatController.currActiveCombat == null ||
  83. CombatController.currActiveCombat.CombatHeroController == null ||
  84. CombatController.currActiveCombat.CombatHeroController.playerHeroEntity == null || CombatController
  85. .currActiveCombat.CombatHeroController.playerHeroEntity.CombatHeroSkillControl == null)
  86. {
  87. return;
  88. }
  89. CombatHeroSkillControl combatHeroSkillControl = CombatController.currActiveCombat.CombatHeroController
  90. .playerHeroEntity.CombatHeroSkillControl
  91. .This<CombatHeroSkillControl>();
  92. if (combatHeroSkillControl.taoismSkillBasic != null)
  93. {
  94. DS60101 ds60101 = combatHeroSkillControl.taoismSkillBasic as DS60101;
  95. if (ds60101 != null)
  96. {
  97. lanLiang.fillAmount = ds60101.currEnergy / ds60101.SelfSkillConfig.effectValue[1];
  98. lanLiang.color = !ds60101._updateTime
  99. ? new Color(1f, 0.96f, 0f)
  100. : new Color(0.96f, 0f, 1f);
  101. }
  102. }
  103. for (int i = 0; i < _gfWidgets.Count; i++)
  104. {
  105. gf_widget gfWidget = _gfWidgets[i];
  106. gfWidget.Update();
  107. double hd = gfWidget.SkillBasic.angle * Math.PI / 180f;
  108. double a = Math.Cos(hd);
  109. double b = -Math.Sin(hd);
  110. double c = Math.Sin(hd);
  111. double d = a;
  112. double x = a * 0 + b * 110;
  113. double y = c * 0 + d * 110;
  114. gfWidget.transform.anchoredPosition = new Vector2((float)x, (float)y);
  115. }
  116. }
  117. }
  118. }