ZhuanPanPanel.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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. CTaskAwaitBuffer cTaskAwaitBuffer = new CTaskAwaitBuffer();
  25. cTaskAwaitBuffer.AddTask(
  26. GObjectPool.Instance.FetchAsync<ParticleSystemPool>("fx_ui_jin_tw", Prestore: true));
  27. cTaskAwaitBuffer.AddTask(
  28. GObjectPool.Instance.FetchAsync<ParticleSystemPool>("fx_ui_shui_tw", Prestore: true));
  29. cTaskAwaitBuffer.AddTask(
  30. GObjectPool.Instance.FetchAsync<ParticleSystemPool>("fx_ui_mu_tw", Prestore: true));
  31. cTaskAwaitBuffer.AddTask(
  32. GObjectPool.Instance.FetchAsync<ParticleSystemPool>("fx_ui_huo_tw", Prestore: true));
  33. cTaskAwaitBuffer.AddTask(
  34. GObjectPool.Instance.FetchAsync<ParticleSystemPool>("fx_ui_tu_tw", Prestore: true));
  35. await cTaskAwaitBuffer.WaitAll();
  36. cTaskAwaitBuffer.Dispose();
  37. for (_wuXingGongFaWidgets.Begin(); _wuXingGongFaWidgets.Next();)
  38. {
  39. UIManager.Instance.DormancyGComponent(_wuXingGongFaWidgets.Value);
  40. }
  41. _wuXingGongFaWidgets.Clear();
  42. for (int i = 0; i < 5; i++)
  43. {
  44. double hd = i * 72 * Math.PI / 180f;
  45. double a = Math.Cos(hd);
  46. double b = -Math.Sin(hd);
  47. double c = Math.Sin(hd);
  48. double d = a;
  49. double x = a * 0 + b * 103;
  50. double y = c * 0 + d * 103;
  51. int index = i;
  52. WuXingGongFaWidget widget = await UIManager.Instance.CreateGComponentForObject<WuXingGongFaWidget>(
  53. WuXingGongFaWidget, null, root: pan,
  54. isInstance: true);
  55. widget.transform.anchoredPosition = new Vector2((float)x, (float)y);
  56. widget.ShowWidget(index);
  57. _wuXingGongFaWidgets.Add(widget.huangDaoWuXingType, widget);
  58. }
  59. ExercisesAlter(null);
  60. }
  61. private async CTask SetSkillFxMovePlay(SkillSlots skillSlots)
  62. {
  63. WuXingType wuXingType = skillSlots.SkillBasic.wuXingType;
  64. Vector2 startPos = Vector2.zero;
  65. for (int i = 0; i < _gfWidgets.Count; i++)
  66. {
  67. if (_gfWidgets[i].SkillSlots == skillSlots)
  68. {
  69. startPos = _gfWidgets[i].transform.position;
  70. }
  71. }
  72. // double hd = skillSlots.angle * Math.PI / 180f;
  73. // double a = Math.Cos(hd);
  74. // double b = -Math.Sin(hd);
  75. // double c = Math.Sin(hd);
  76. // double d = a;
  77. // double x = a * 0 + b * 150;
  78. // double y = c * 0 + d * 150;
  79. Vector2 endPos = _wuXingGongFaWidgets[wuXingType].transform.position;
  80. Vector2 endPos2 = currUseSkillRoot.transform.position;
  81. BesselPath besselPath = new BesselPath();
  82. besselPath.controlPoints.Add(startPos);
  83. besselPath.controlPoints.Add(startPos);
  84. besselPath.controlPoints.Add(endPos2);
  85. besselPath.controlPoints.Add(endPos2);
  86. BesselPathGroup besselPathGroup = new BesselPathGroup();
  87. besselPathGroup.AddBesselPath(besselPath);
  88. // besselPathGroup.AddBesselPath(besselPath2);
  89. // GameObject fxObject = null;
  90. string fxName = null;
  91. string fxName_end = null;
  92. string fxName_tar = null;
  93. switch (wuXingType)
  94. {
  95. case WuXingType.Gold:
  96. // fxObject = fx_skill_jing;
  97. fxName = "fx_ui_jin_tw";
  98. fxName_end = "fx_ui_jin_end";
  99. fxName_tar = "fx_ui_jin_tar";
  100. break;
  101. case WuXingType.Water:
  102. // fxObject = fx_skill_shui;
  103. fxName = "fx_ui_shui_tw";
  104. fxName_end = "fx_ui_shui_end";
  105. fxName_tar = "fx_ui_shui_tar";
  106. break;
  107. case WuXingType.Wood:
  108. // fxObject = fx_skill_huo;
  109. fxName = "fx_ui_mu_tw";
  110. fxName_end = "fx_ui_mu_end";
  111. fxName_tar = "fx_ui_mu_tar";
  112. break;
  113. case WuXingType.Fire:
  114. // fxObject = fx_skill_huo;
  115. fxName = "fx_ui_huo_tw";
  116. fxName_end = "fx_ui_huo_end";
  117. fxName_tar = "fx_ui_huo_tar";
  118. break;
  119. case WuXingType.Earth:
  120. // fxObject = fx_skill_shui;
  121. fxName = "fx_ui_tu_tw";
  122. fxName_end = "fx_ui_tu_end";
  123. fxName_tar = "fx_ui_tu_tar";
  124. break;
  125. }
  126. UseSkillShowFxMono useSkillShowFxMono = CObjectPool.Instance.Fetch<UseSkillShowFxMono>();
  127. ParticleSystemPool particleSystemPool1 = null;
  128. ParticleSystemPool particleSystemPool2 = null;
  129. ParticleSystemPool particleSystemPool3 = null;
  130. using (CTaskAwaitBuffer cTaskAwaitBuffer = new CTaskAwaitBuffer())
  131. {
  132. cTaskAwaitBuffer.AddTask(
  133. GObjectPool.Instance.FetchAsync<ParticleSystemPool>(fxName,
  134. delegate(ParticleSystemPool pool)
  135. {
  136. particleSystemPool1 = pool;
  137. particleSystemPool1.SetParent(fxRoot);
  138. particleSystemPool1.transform.position = startPos;
  139. }));
  140. cTaskAwaitBuffer.AddTask(
  141. GObjectPool.Instance.FetchAsync<ParticleSystemPool>(fxName_end,
  142. delegate(ParticleSystemPool pool)
  143. {
  144. particleSystemPool2 = pool;
  145. particleSystemPool2.SetParent(fxRoot);
  146. particleSystemPool2.transform.position = endPos2;
  147. particleSystemPool2.SetActive(false);
  148. }));
  149. cTaskAwaitBuffer.AddTask(
  150. GObjectPool.Instance.FetchAsync<ParticleSystemPool>(fxName_tar,
  151. delegate(ParticleSystemPool pool)
  152. {
  153. particleSystemPool3 = pool;
  154. particleSystemPool3.SetParent(fxRoot);
  155. particleSystemPool3.transform.position =
  156. _wuXingGongFaWidgets[wuXingType].transform.position;
  157. particleSystemPool3.SetActive(false);
  158. }));
  159. await cTaskAwaitBuffer.WaitAll();
  160. }
  161. // particleSystemPool.transform.parent = fxObject.transform.parent;
  162. useSkillShowFxMono.Init(besselPathGroup, particleSystemPool1, particleSystemPool2, particleSystemPool3);
  163. }
  164. private void Init()
  165. {
  166. }
  167. public override void AddEvent()
  168. {
  169. StaticUpdater.Instance.AddLateUpdateCallBack(Update);
  170. CombatEventManager.Instance.AddEventListener(CombatEventType.ExercisesAlter, ExercisesAlter);
  171. CombatEventManager.Instance.AddEventListener(CombatEventType.TaoismSkillAlter, TaoismSkillAlter);
  172. CombatEventManager.Instance.AddEventListener(CombatEventType.AddUseGongFa, AddUseGongFa);
  173. CombatEventManager.Instance.AddEventListener(CombatEventType.UseSkill, UseSkill);
  174. CombatEventManager.Instance.AddEventListener(CombatEventType.UseSkillFinish, UseSkillFinish);
  175. }
  176. public override void DelEvent()
  177. {
  178. StaticUpdater.Instance.RemoveLateUpdateCallBack(Update);
  179. CombatEventManager.Instance.RemoveEventListener(CombatEventType.UseSkill, UseSkill);
  180. CombatEventManager.Instance.RemoveEventListener(CombatEventType.ExercisesAlter, ExercisesAlter);
  181. CombatEventManager.Instance.RemoveEventListener(CombatEventType.TaoismSkillAlter, TaoismSkillAlter);
  182. CombatEventManager.Instance.RemoveEventListener(CombatEventType.AddUseGongFa, AddUseGongFa);
  183. CombatEventManager.Instance.RemoveEventListener(CombatEventType.UseSkillFinish, UseSkillFinish);
  184. }
  185. private async void UseSkillFinish(IEventData ieveData)
  186. {
  187. UseSkillFinishEventData eventData = ieveData as UseSkillFinishEventData;
  188. if (eventData.SkillBasic.CombatHeroEntity.IsEnemy)
  189. {
  190. return;
  191. }
  192. CombatHeroSkillControl combatHeroSkillControl =
  193. eventData.SkillBasic.CombatHeroEntity.CombatHeroSkillControl.This<CombatHeroSkillControl>();
  194. if (combatHeroSkillControl.useSkillCount <= 0)
  195. {
  196. currUseSkillRoot.SetActive(false);
  197. }
  198. }
  199. private async void UseSkill(IEventData ieveData)
  200. {
  201. CombatUseSkillEventData eventData = ieveData as CombatUseSkillEventData;
  202. if (eventData.useSkill.CombatHeroEntity.IsEnemy)
  203. {
  204. return;
  205. }
  206. string fxName_end = "";
  207. switch (eventData.useSkill.wuXingType)
  208. {
  209. case WuXingType.Gold:
  210. // fxObject = fx_skill_jing;
  211. fxName_end = "fx_ui_jin_end";
  212. break;
  213. case WuXingType.Water:
  214. // fxObject = fx_skill_shui;
  215. fxName_end = "fx_ui_shui_end";
  216. break;
  217. case WuXingType.Wood:
  218. // fxObject = fx_skill_huo;
  219. fxName_end = "fx_ui_mu_end";
  220. break;
  221. case WuXingType.Fire:
  222. // fxObject = fx_skill_huo;
  223. fxName_end = "fx_ui_huo_end";
  224. break;
  225. case WuXingType.Earth:
  226. // fxObject = fx_skill_shui;
  227. fxName_end = "fx_ui_tu_end";
  228. break;
  229. }
  230. Vector2 endPos2 = currUseSkillRoot.transform.position;
  231. GObjectPool.Instance.FetchAsync<ParticleSystemPool>(fxName_end,
  232. delegate(ParticleSystemPool pool)
  233. {
  234. pool.SetParent(fxRoot);
  235. pool.transform.position = endPos2;
  236. });
  237. currUseSkillRoot.SetActive(true);
  238. currUseSkillIcon.icon_name = eventData.useSkill.SelfSkillConfig.icon;
  239. }
  240. private async void AddUseGongFa(IEventData ieveData)
  241. {
  242. AddUseGongFaEventData eventData = ieveData as AddUseGongFaEventData;
  243. SkillBasic skillBasic = eventData.SkillBasic;
  244. if (skillBasic.CombatHeroEntity.IsEnemy)
  245. {
  246. return;
  247. }
  248. SetSkillFxMovePlay(eventData.SkillSlots);
  249. CombatHeroSkillControl combatHeroSkillControl =
  250. skillBasic.CombatHeroEntity.CombatHeroSkillControl.This<CombatHeroSkillControl>();
  251. if (combatHeroSkillControl.useSkillCount > 1 || combatHeroSkillControl.currUseSkill != null)
  252. {
  253. UseQuqueSkill useQuqueSkill =
  254. await UIManager.Instance.CreateGComponentForObject<UseQuqueSkill>(UseQuqueSkill, null,
  255. UseQuqueSkillRoot, isInstance: true);
  256. useQuqueSkill.ShowWidget(skillBasic);
  257. useQuqueSkill.transform.SetAsLastSibling();
  258. }
  259. }
  260. public override void AddButtonEvent()
  261. {
  262. lanLiang_button.onClick.AddListener(() => { SkillSelectPanel.OpenSkillSelectPanel(); });
  263. }
  264. private void TaoismSkillAlter(IEventData iEventData)
  265. {
  266. }
  267. private async void ExercisesAlter(IEventData iEventData)
  268. {
  269. _gfWidgets.Clear();
  270. UIManager.Instance.DormancyAllGComponent<gf_widget>();
  271. CombatHeroSkillControl combatHeroSkillControl = CombatController.currActiveCombat
  272. .playerHeroEntity.CombatHeroSkillControl
  273. .This<CombatHeroSkillControl>();
  274. for (int i = 0; i < combatHeroSkillControl.SkillTurntable.allSkillSlots.Count; i++)
  275. {
  276. SkillSlots skillBasic = combatHeroSkillControl.SkillTurntable.allSkillSlots[i];
  277. if (skillBasic == null)
  278. {
  279. continue;
  280. }
  281. gf_widget gfWidget = await UIManager.Instance.CreateGComponentForObject<gf_widget>(this.gf_widget, null,
  282. Gf_root, isInstance: true);
  283. gfWidget.SkillSlots = skillBasic;
  284. gfWidget.InitWidget(skillBasic, CombatController.currActiveCombat
  285. .playerHeroEntity);
  286. _gfWidgets.Add(gfWidget);
  287. }
  288. }
  289. public void Update()
  290. {
  291. if (CombatController.currActiveCombat == null ||
  292. CombatController.currActiveCombat.CombatHeroController == null ||
  293. CombatController.currActiveCombat.playerHeroEntity == null || CombatController
  294. .currActiveCombat.playerHeroEntity.CombatHeroSkillControl == null)
  295. {
  296. return;
  297. }
  298. CombatHeroSkillControl combatHeroSkillControl = CombatController.currActiveCombat
  299. .playerHeroEntity.CombatHeroSkillControl
  300. .This<CombatHeroSkillControl>();
  301. if (combatHeroSkillControl.taoismSkillBasic != null)
  302. {
  303. DS60101 ds60101 = combatHeroSkillControl.taoismSkillBasic as DS60101;
  304. if (ds60101 != null)
  305. {
  306. lanLiang.fillAmount = ds60101.currEnergy / ds60101.SelfSkillConfig.effectValue[1];
  307. lanLiang.color = !ds60101._updateTime
  308. ? new Color(1f, 0.96f, 0f)
  309. : new Color(0.96f, 0f, 1f);
  310. }
  311. }
  312. for (int i = 0; i < _gfWidgets.Count; i++)
  313. {
  314. gf_widget gfWidget = _gfWidgets[i];
  315. gfWidget.Update();
  316. double hd = gfWidget.SkillSlots.angle * Math.PI / 180f;
  317. double a = Math.Cos(hd);
  318. double b = -Math.Sin(hd);
  319. double c = Math.Sin(hd);
  320. double d = a;
  321. double x = a * 0 + b * 150;
  322. double y = c * 0 + d * 150;
  323. gfWidget.transform.anchoredPosition = new Vector2((float)x, (float)y);
  324. }
  325. }
  326. }
  327. }