ZhuanPanPanel.cs 16 KB

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