ShieldsBarrier.cs 3.0 KB

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