ZhuanPanPanel.cs 16 KB

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