ShieldsBarrier.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using Core.Triiger;
  2. using Fort23.Common;
  3. using Fort23.Core;
  4. using Fort23.UTool;
  5. using GameLogic.Combat.CombatTool;
  6. using UnityEngine;
  7. namespace GameLogic.Combat.Hero
  8. {
  9. public class ShieldsBarrier : IBarrier
  10. {
  11. public ShowBaiscEntity Own { get; set; }
  12. public GameObjectPool ShieldsFx;
  13. private ParticleSystem[] allParticleSystem;
  14. public async CTask Init(ShowBaiscEntity combatHeroEntity)
  15. {
  16. Own = combatHeroEntity;
  17. GameObjectPool combatParticleSystemPool =
  18. await GObjectPool.Instance.FetchAsync<GameObjectPool>("fx_hudun", null);
  19. ShieldsFx = combatParticleSystemPool;
  20. BarrierEntityMono barrierEntityMono = combatParticleSystemPool.own.GetComponent<BarrierEntityMono>();
  21. if (barrierEntityMono == null)
  22. {
  23. barrierEntityMono =
  24. combatParticleSystemPool.own.AddComponent<BarrierEntityMono>();
  25. }
  26. barrierEntityMono.Barrier = this;
  27. SpecialDotInfo specialDotInfo =
  28. combatHeroEntity.GetMainHotPoin<CombatHeroHitPoint>(true).GetSpecialDotInfo("hitpos");
  29. ShieldsFx.own.transform.SetParent(specialDotInfo.targetTran);
  30. ShieldsFx.own.transform.localPosition = Vector3.zero;
  31. ShieldsFx.own.transform.localEulerAngles = Vector3.zero;
  32. ShieldsFx.own.transform.localScale = Vector3.one * 1.5f;
  33. ShieldsFx.SetActive(true);
  34. allParticleSystem = combatParticleSystemPool.own.transform.GetComponentsInChildren<ParticleSystem>();
  35. }
  36. public void Play()
  37. {
  38. ShieldsFx.ActiveObj();
  39. for (int i = 0; i < allParticleSystem.Length; i++)
  40. {
  41. allParticleSystem[i].Stop();
  42. allParticleSystem[i].Play();
  43. }
  44. }
  45. /// <summary>
  46. /// 破裂
  47. /// </summary>
  48. public async CTask Rupture()
  49. {
  50. ParticleSystemPool particleSystemPool =
  51. await GObjectPool.Instance.FetchAsync<ParticleSystemPool>("fx_hudun_po", null);
  52. particleSystemPool.gameObject.transform.position = ShieldsFx.own.transform.position;
  53. }
  54. public bool CollideTriiger(ITriggerEntity triggerEntity)
  55. {
  56. if (Own.CurrCombatHeroInfo.Shield > 0)
  57. {
  58. return false;
  59. }
  60. return true;
  61. }
  62. public void Harm(HarmReturnInfo harmReturnInfo)
  63. {
  64. Play();
  65. harmReturnInfo.target.combatHeroEntity.CurrCombatHeroInfo.Shield -= harmReturnInfo.att;
  66. if (harmReturnInfo.target.combatHeroEntity.CurrCombatHeroInfo.Shield <= 0)
  67. {
  68. Rupture();
  69. }
  70. }
  71. public void Dispose()
  72. {
  73. GObjectPool.Instance.Recycle(ShieldsFx);
  74. allParticleSystem = null;
  75. ShieldsFx = null;
  76. Own = null;
  77. }
  78. }
  79. }