CombatMonoBaisc.cs 7.2 KB

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