ZhuanPanPanel.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. using System;
  2. using System.Collections.Generic;
  3. using Common.Utility.CombatEvent;
  4. using Core.Utility;
  5. using Fort23.Core;
  6. using Fort23.UTool;
  7. using GameLogic.Combat.CombatTool;
  8. using GameLogic.Combat.Hero;
  9. using GameLogic.Combat.Hero.Turntable;
  10. using GameLogic.Combat.Skill;
  11. using GameLogic.Player;
  12. using UnityEngine;
  13. using Utility;
  14. namespace Fort23.Mono
  15. {
  16. [UIBinding(prefab = "ZhuanPanPanel")]
  17. public partial class ZhuanPanPanel : UIComponent
  18. {
  19. private List<gf_widget> _gfWidgets = new List<gf_widget>();
  20. // List<WuXingGongFaWidget> _wuXingGongFaWidgets = new List<WuXingGongFaWidget>();
  21. private Map<WuXingType, WuXingGongFaWidget> _wuXingGongFaWidgets = new Map<WuXingType, WuXingGongFaWidget>();
  22. public async CTask ShowPanel()
  23. {
  24. for (_wuXingGongFaWidgets.Begin(); _wuXingGongFaWidgets.Next();)
  25. {
  26. UIManager.Instance.DormancyGComponent(_wuXingGongFaWidgets.Value);
  27. }
  28. _wuXingGongFaWidgets.Clear();
  29. for (int i = 0; i < 5; i++)
  30. {
  31. double hd = i * 72 * Math.PI / 180f;
  32. double a = Math.Cos(hd);
  33. double b = -Math.Sin(hd);
  34. double c = Math.Sin(hd);
  35. double d = a;
  36. double x = a * 0 + b * 103;
  37. double y = c * 0 + d * 103;
  38. int index = i;
  39. WuXingGongFaWidget widget = await UIManager.Instance.CreateGComponentForObject<WuXingGongFaWidget>(
  40. WuXingGongFaWidget, null, root: pan,
  41. isInstance: true);
  42. widget.transform.anchoredPosition = new Vector2((float)x, (float)y);
  43. widget.ShowWidget(index);
  44. _wuXingGongFaWidgets.Add(widget.huangDaoWuXingType, widget);
  45. }
  46. ExercisesAlter(null);
  47. }
  48. private void SetSkillFxMovePlay(SkillSlots skillSlots)
  49. {
  50. WuXingType wuXingType = skillSlots.SkillBasic.wuXingType;
  51. Vector2 startPos = Vector2.zero;
  52. for (int i = 0; i < _gfWidgets.Count; i++)
  53. {
  54. if (_gfWidgets[i].SkillSlots == skillSlots)
  55. {
  56. startPos= _gfWidgets[i].transform.position;
  57. }
  58. }
  59. // double hd = skillSlots.angle * Math.PI / 180f;
  60. // double a = Math.Cos(hd);
  61. // double b = -Math.Sin(hd);
  62. // double c = Math.Sin(hd);
  63. // double d = a;
  64. // double x = a * 0 + b * 150;
  65. // double y = c * 0 + d * 150;
  66. Vector2 endPos = _wuXingGongFaWidgets[wuXingType].transform.position;
  67. Vector2 center = endPos - startPos;
  68. center = startPos + (center * 0.5f);
  69. BesselPath besselPath = new BesselPath();
  70. besselPath.controlPoints.Add(startPos);
  71. besselPath.controlPoints.Add(new Vector3(center.x, center.y, -0.5f));
  72. besselPath.controlPoints.Add(endPos);
  73. besselPath.controlPoints.Add(endPos);
  74. Vector2 startPos2 = endPos;
  75. Vector2 endPos2 = currUseSkillRoot.transform.position;
  76. Vector2 center2 = endPos2 - startPos2;
  77. center2 = startPos2 + (center2 * 0.5f);
  78. BesselPath besselPath2 = new BesselPath();
  79. besselPath2.controlPoints.Add(startPos2);
  80. besselPath2.controlPoints.Add(new Vector3(center2.x, center2.y, -0.5f));
  81. besselPath2.controlPoints.Add(endPos2);
  82. besselPath2.controlPoints.Add(endPos2);
  83. BesselPathGroup besselPathGroup = new BesselPathGroup();
  84. besselPathGroup.AddBesselPath(besselPath);
  85. besselPathGroup.AddBesselPath(besselPath2);
  86. GameObject fxObject = null;
  87. switch (wuXingType)
  88. {
  89. case WuXingType.Gold:
  90. fxObject = fx_skill_jing;
  91. break;
  92. case WuXingType.Water:
  93. fxObject = fx_skill_shui;
  94. break;
  95. case WuXingType.Wood:
  96. fxObject = fx_skill_huo;
  97. break;
  98. case WuXingType.Fire:
  99. fxObject = fx_skill_huo;
  100. break;
  101. case WuXingType.Earth:
  102. fxObject = fx_skill_shui;
  103. break;
  104. }
  105. UseSkillShowFxMono useSkillShowFxMono = CObjectPool.Instance.Fetch<UseSkillShowFxMono>();
  106. ParticleSystemPool particleSystemPool =
  107. GObjectPool.Instance.FetchAsyncForGameObject<ParticleSystemPool>(fxObject, fxObject.name);
  108. particleSystemPool.transform.parent = fxObject.transform.parent;
  109. useSkillShowFxMono.Init(besselPathGroup, particleSystemPool);
  110. }
  111. private void Init()
  112. {
  113. }
  114. public override void AddEvent()
  115. {
  116. StaticUpdater.Instance.AddLateUpdateCallBack(Update);
  117. CombatEventManager.Instance.AddEventListener(CombatEventType.ExercisesAlter, ExercisesAlter);
  118. CombatEventManager.Instance.AddEventListener(CombatEventType.TaoismSkillAlter, TaoismSkillAlter);
  119. CombatEventManager.Instance.AddEventListener(CombatEventType.AddUseGongFa, AddUseGongFa);
  120. CombatEventManager.Instance.AddEventListener(CombatEventType.UseSkill, UseSkill);
  121. CombatEventManager.Instance.AddEventListener(CombatEventType.UseSkillFinish, UseSkillFinish);
  122. }
  123. public override void DelEvent()
  124. {
  125. StaticUpdater.Instance.RemoveLateUpdateCallBack(Update);
  126. CombatEventManager.Instance.RemoveEventListener(CombatEventType.ExercisesAlter, ExercisesAlter);
  127. CombatEventManager.Instance.RemoveEventListener(CombatEventType.TaoismSkillAlter, TaoismSkillAlter);
  128. CombatEventManager.Instance.RemoveEventListener(CombatEventType.AddUseGongFa, AddUseGongFa);
  129. CombatEventManager.Instance.RemoveEventListener(CombatEventType.UseSkillFinish, UseSkillFinish);
  130. }
  131. private async void UseSkillFinish(IEventData ieveData)
  132. {
  133. UseSkillFinishEventData eventData = ieveData as UseSkillFinishEventData;
  134. if (eventData.SkillBasic.CombatHeroEntity.IsEnemy)
  135. {
  136. return;
  137. }
  138. CombatHeroSkillControl combatHeroSkillControl =
  139. eventData.SkillBasic.CombatHeroEntity.CombatHeroSkillControl.This<CombatHeroSkillControl>();
  140. if (combatHeroSkillControl.useSkillCount <= 0)
  141. {
  142. currUseSkillRoot.SetActive(false);
  143. }
  144. }
  145. private async void UseSkill(IEventData ieveData)
  146. {
  147. CombatUseSkillEventData eventData = ieveData as CombatUseSkillEventData;
  148. if (eventData.useSkill.CombatHeroEntity.IsEnemy)
  149. {
  150. return;
  151. }
  152. currUseSkillRoot.SetActive(true);
  153. currUseSkillIcon.icon_name = eventData.useSkill.SelfSkillConfig.icon;
  154. }
  155. private async void AddUseGongFa(IEventData ieveData)
  156. {
  157. AddUseGongFaEventData eventData = ieveData as AddUseGongFaEventData;
  158. SkillBasic skillBasic = eventData.SkillBasic;
  159. if (skillBasic.CombatHeroEntity.IsEnemy)
  160. {
  161. return;
  162. }
  163. SetSkillFxMovePlay(eventData.SkillSlots);
  164. CombatHeroSkillControl combatHeroSkillControl =
  165. skillBasic.CombatHeroEntity.CombatHeroSkillControl.This<CombatHeroSkillControl>();
  166. if (combatHeroSkillControl.useSkillCount > 0 || combatHeroSkillControl.currUseSkill != null)
  167. {
  168. UseQuqueSkill useQuqueSkill =
  169. await UIManager.Instance.CreateGComponentForObject<UseQuqueSkill>(UseQuqueSkill, null,
  170. UseQuqueSkillRoot, isInstance: true);
  171. useQuqueSkill.ShowWidget(skillBasic);
  172. useQuqueSkill.transform.SetAsLastSibling();
  173. }
  174. }
  175. public override void AddButtonEvent()
  176. {
  177. lanLiang_button.onClick.AddListener(() => { SkillSelectPanel.OpenSkillSelectPanel(); });
  178. }
  179. private void TaoismSkillAlter(IEventData iEventData)
  180. {
  181. }
  182. private async void ExercisesAlter(IEventData iEventData)
  183. {
  184. _gfWidgets.Clear();
  185. UIManager.Instance.DormancyAllGComponent<gf_widget>();
  186. CombatHeroSkillControl combatHeroSkillControl = CombatController.currActiveCombat
  187. .playerHeroEntity.CombatHeroSkillControl
  188. .This<CombatHeroSkillControl>();
  189. for (int i = 0; i < combatHeroSkillControl.SkillTurntable.allSkillSlots.Count; i++)
  190. {
  191. SkillSlots skillBasic = combatHeroSkillControl.SkillTurntable.allSkillSlots[i];
  192. if (skillBasic == null)
  193. {
  194. continue;
  195. }
  196. gf_widget gfWidget = await UIManager.Instance.CreateGComponentForObject<gf_widget>(this.gf_widget, null,
  197. Gf_root, isInstance: true);
  198. gfWidget.SkillSlots = skillBasic;
  199. gfWidget.InitWidget(skillBasic, CombatController.currActiveCombat
  200. .playerHeroEntity);
  201. _gfWidgets.Add(gfWidget);
  202. }
  203. }
  204. public void Update()
  205. {
  206. if (CombatController.currActiveCombat == null ||
  207. CombatController.currActiveCombat.CombatHeroController == null ||
  208. CombatController.currActiveCombat.playerHeroEntity == null || CombatController
  209. .currActiveCombat.playerHeroEntity.CombatHeroSkillControl == null)
  210. {
  211. return;
  212. }
  213. CombatHeroSkillControl combatHeroSkillControl = CombatController.currActiveCombat
  214. .playerHeroEntity.CombatHeroSkillControl
  215. .This<CombatHeroSkillControl>();
  216. if (combatHeroSkillControl.taoismSkillBasic != null)
  217. {
  218. DS60101 ds60101 = combatHeroSkillControl.taoismSkillBasic as DS60101;
  219. if (ds60101 != null)
  220. {
  221. lanLiang.fillAmount = ds60101.currEnergy / ds60101.SelfSkillConfig.effectValue[1];
  222. lanLiang.color = !ds60101._updateTime
  223. ? new Color(1f, 0.96f, 0f)
  224. : new Color(0.96f, 0f, 1f);
  225. }
  226. }
  227. for (int i = 0; i < _gfWidgets.Count; i++)
  228. {
  229. gf_widget gfWidget = _gfWidgets[i];
  230. gfWidget.Update();
  231. double hd = gfWidget.SkillSlots.angle * Math.PI / 180f;
  232. double a = Math.Cos(hd);
  233. double b = -Math.Sin(hd);
  234. double c = Math.Sin(hd);
  235. double d = a;
  236. double x = a * 0 + b * 150;
  237. double y = c * 0 + d * 150;
  238. gfWidget.transform.anchoredPosition = new Vector2((float)x, (float)y);
  239. }
  240. }
  241. }
  242. }