UseSkillShowFxMono.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using Core.Utility;
  2. using Fort23.Core;
  3. using Fort23.UTool;
  4. using UnityEngine;
  5. namespace Fort23.Mono
  6. {
  7. public class UseSkillShowFxMono : CObject
  8. {
  9. protected BesselPathGroup besselPathGroup;
  10. protected ParticleSystemPool gObjectPoolInterface;
  11. protected float _currTime;
  12. protected float _timeAdd;
  13. private float _speed = 0.5f;
  14. private ParticleSystemPool particleSystemEnd;
  15. private ParticleSystemPool particleSystemTar;
  16. private bool isEnd;
  17. public void Init(BesselPathGroup besselPathGroup, ParticleSystemPool gObjectPoolInterface,
  18. ParticleSystemPool particleSystemEnd, ParticleSystemPool particleSystemTar)
  19. {
  20. isEnd = false;
  21. besselPathGroup.Start();
  22. this.besselPathGroup = besselPathGroup;
  23. this.gObjectPoolInterface = gObjectPoolInterface;
  24. this.particleSystemEnd = particleSystemEnd;
  25. this.particleSystemTar = particleSystemTar;
  26. // gObjectPoolInterface.SetActive(true);
  27. _currTime = 0;
  28. _timeAdd = 1.0f / _speed;
  29. StaticUpdater.Instance.AddRenderUpdateCallBack(Update);
  30. }
  31. public void Update()
  32. {
  33. if (isEnd)
  34. {
  35. _currTime += Time.deltaTime;
  36. if (_currTime > 2)
  37. {
  38. CObjectPool.Instance.Recycle(this);
  39. }
  40. return;
  41. }
  42. _currTime += Time.deltaTime * _timeAdd;
  43. if (_currTime > 0.3f&&!particleSystemTar.own.activeSelf)
  44. {
  45. particleSystemTar.ActiveObj();
  46. }
  47. if (_currTime > 1)
  48. {
  49. _currTime = 1;
  50. }
  51. Vector3 pos = besselPathGroup.CalculatePoint(_currTime);
  52. gObjectPoolInterface.gameObject.transform.position = pos;
  53. if (_currTime >= 1 && !isEnd)
  54. {
  55. GObjectPool.Instance.Recycle(gObjectPoolInterface);
  56. particleSystemEnd.ActiveObj();
  57. _currTime = 0;
  58. isEnd = true;
  59. }
  60. }
  61. public override void ActiveObj()
  62. {
  63. }
  64. public override void DormancyObj()
  65. {
  66. besselPathGroup = null;
  67. gObjectPoolInterface = null;
  68. particleSystemEnd = null;
  69. particleSystemTar = null;
  70. StaticUpdater.Instance.RemoveRenderUpdateCallBack(Update);
  71. }
  72. }
  73. }