CombatMonoBaisc.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. using System.Collections.Generic;
  2. using CombatLibrary.CombatLibrary.CombatCore.Utility;
  3. using Common.Utility.CombatEvent;
  4. using Core.Audio;
  5. using Fort23.Core;
  6. using Fort23.Mono;
  7. using Fort23.UTool;
  8. using GameLogic.Bag;
  9. using GameLogic.Combat.CombatTool;
  10. using GameLogic.Combat.CombatType;
  11. using UnityEngine;
  12. using UnityEngine.UI;
  13. using Utility.UITool;
  14. namespace GameUI.Combat
  15. {
  16. /// <summary>
  17. /// 战斗和mono层的桥接
  18. /// </summary>
  19. public class CombatMonoBaisc
  20. {
  21. private CombatController combatController;
  22. private ShowItemMoveToTargetPanel _showItemMoveToTargetPanel;
  23. public async CTask Init(CombatController combatController)
  24. {
  25. this.combatController = combatController;
  26. _showItemMoveToTargetPanel = await ShowItemMoveToTargetPanel.OpenShowItemMoveToTargetPanel();
  27. AddEvent();
  28. }
  29. protected void AddEvent()
  30. {
  31. EventManager.Instance.AddEventListener(CustomEventType.Combat_ItemShow, Combat_ItemShow);
  32. CombatEventManager.Instance.AddEventListener(CombatEventType.HeroDieFinish, HeroDie);
  33. }
  34. protected void HeroDie(IEventData iEventData)
  35. {
  36. HeroDieEventData heroDieEventData= iEventData as HeroDieEventData;
  37. if (heroDieEventData.combatHeroEntity.IsEnemy)
  38. {
  39. return;
  40. }
  41. BetterList<CombatHeroEntity> myHero = combatController.CombatHeroController.GetHeroList(false);
  42. if (myHero.Count <= 0)
  43. {
  44. CombatHeroDiePanel.OpenCombatHeroDiePanel();
  45. }
  46. }
  47. protected void Combat_ItemShow(IEventData iEventData)
  48. {
  49. Vector2 target = _showItemMoveToTargetPanel.moveTarget.GetComponent<RectTransform>().anchoredPosition;
  50. CombatItemShowEventData combatItemShowEventData = iEventData as CombatItemShowEventData;
  51. CombatItemShowEventData.ShowType showType = combatItemShowEventData.showType;
  52. if (showType == CombatItemShowEventData.ShowType.LevelExp)
  53. {
  54. MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
  55. Vector3 pos = mainUIPanel.expPoint.position;
  56. target = _showItemMoveToTargetPanel.transform.worldToLocalMatrix * pos;
  57. }
  58. else if (showType == CombatItemShowEventData.ShowType.HeroExp)
  59. {
  60. MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
  61. Vector3 pos = mainUIPanel.Icon_HeroExp.transform.position;
  62. target = _showItemMoveToTargetPanel.transform.worldToLocalMatrix * pos;
  63. } else if (showType == CombatItemShowEventData.ShowType.MonsterGold)
  64. {
  65. MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
  66. Vector3 pos = mainUIPanel.Icon_Coin.transform.position;
  67. target = _showItemMoveToTargetPanel.transform.worldToLocalMatrix * pos;
  68. }
  69. Vector3 p = UIManager.Instance.CurrCustomCameraStack.camera.WorldToScreenPoint(
  70. combatItemShowEventData.startPos_WorldPos);
  71. Vector3 p2 = UIManager.Instance.UICamera.ScreenToWorldPoint(p);
  72. Vector3 startPos = _showItemMoveToTargetPanel.transform.worldToLocalMatrix * p2;
  73. int maxCount = combatItemShowEventData.count;
  74. int addValue = combatItemShowEventData.addValue / maxCount;
  75. int finishVale = combatItemShowEventData.addValue % maxCount;
  76. _showItemMoveToTargetPanel.ShowPanel(startPos, target, maxCount, combatItemShowEventData.showName,
  77. delegate(ImageMove imageMove)
  78. {
  79. MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
  80. if (mainUIPanel == null)
  81. {
  82. return;
  83. }
  84. int currAddValue = addValue;
  85. if (imageMove.GroupIndex == maxCount - 1)
  86. {
  87. currAddValue += finishVale;
  88. }
  89. if ((CombatItemShowEventData.ShowType)imageMove.data == CombatItemShowEventData.ShowType.LevelExp)
  90. {
  91. if (mainUIPanel != null)
  92. {
  93. ParticleSystemPool particleSystemPool =
  94. GObjectPool.Instance.FetchAsyncForGameObject<ParticleSystemPool>(mainUIPanel.fx_ui_exp,
  95. "fx_ui_exp");
  96. particleSystemPool.transform.SetParent(mainUIPanel.expPoint.transform);
  97. particleSystemPool.transform.localPosition = Vector3.zero;
  98. particleSystemPool.transform.localScale = Vector3.one;
  99. LevelBattleCombatType levelBattleCombatType =
  100. CombatController.currActiveCombat.CombatTypeBasic as LevelBattleCombatType;
  101. if (levelBattleCombatType != null)
  102. {
  103. levelBattleCombatType.exp += currAddValue;
  104. }
  105. }
  106. }
  107. else if ((CombatItemShowEventData.ShowType)imageMove.data ==
  108. CombatItemShowEventData.ShowType.HeroExp)
  109. {
  110. if (mainUIPanel != null)
  111. {
  112. ParticleSystemPool particleSystemPool =
  113. GObjectPool.Instance.FetchAsyncForGameObject<ParticleSystemPool>(mainUIPanel.fx_ui_coin,
  114. "fx_ui_coin");
  115. particleSystemPool.transform.SetParent(mainUIPanel.Icon_HeroExp.transform);
  116. particleSystemPool.transform.localPosition = Vector3.zero;
  117. particleSystemPool.transform.localScale = Vector3.one;
  118. BagController.Instance.AddHeroExp(currAddValue);
  119. // particleSystemPool.transform.
  120. }
  121. } else if ((CombatItemShowEventData.ShowType)imageMove.data ==
  122. CombatItemShowEventData.ShowType.MonsterGold)
  123. {
  124. if (mainUIPanel != null)
  125. {
  126. ParticleSystemPool particleSystemPool =
  127. GObjectPool.Instance.FetchAsyncForGameObject<ParticleSystemPool>(mainUIPanel.fx_ui_coin,
  128. "fx_ui_coin");
  129. particleSystemPool.transform.SetParent(mainUIPanel.Icon_Coin.transform);
  130. particleSystemPool.transform.localPosition = Vector3.zero;
  131. particleSystemPool.transform.localScale = Vector3.one;
  132. BagController.Instance.AddCoin(currAddValue);
  133. // AudioManager.Instance.PlayAudio("jingbi.wav");
  134. // particleSystemPool.transform.
  135. }
  136. }
  137. }, SetTargetPoint, showType);
  138. }
  139. private void SetTargetPoint(ImageMove imageMove)
  140. {
  141. if ((CombatItemShowEventData.ShowType)imageMove.data == CombatItemShowEventData.ShowType.LevelExp)
  142. {
  143. MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
  144. Vector3 pos = mainUIPanel.expPoint.position;
  145. Vector3 target = _showItemMoveToTargetPanel.transform.worldToLocalMatrix * pos;
  146. CurveInfo curveInfo = imageMove.currAcur.CurveInfos[1];
  147. curveInfo.t = target.x;
  148. curveInfo.v = target.y;
  149. imageMove.currAcur.CurveInfos[1] = curveInfo;
  150. }
  151. }
  152. public void Update(float t)
  153. {
  154. }
  155. }
  156. }