ShieldsBarrier.cs 2.6 KB

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