FightingEffectBase.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4. namespace YLBattle
  5. {
  6. /// <summary>
  7. ///
  8. /// </summary>
  9. public class FightingEffectBase : GameBehavior
  10. {
  11. /// <summary>
  12. ///
  13. /// </summary>
  14. private float mStartTime = 0;
  15. /// <summary>
  16. ///
  17. /// </summary>
  18. private Action acEvent = null;
  19. /// <summary>
  20. /// 生命周期
  21. /// </summary>
  22. public float mLifeTime = 0;
  23. /// <summary>
  24. ///
  25. /// </summary>
  26. /// <param name="ac"></param>
  27. public void SetData(Action ac)
  28. {
  29. mStartTime = Time.realtimeSinceStartup;
  30. this.acEvent = ac;
  31. }
  32. void Update()
  33. {
  34. if (Time.realtimeSinceStartup - this.mStartTime >= this.mStartTime)
  35. {
  36. InvokeEvent();
  37. this.acEvent = null;
  38. }
  39. }
  40. /// <summary>
  41. ///
  42. /// </summary>
  43. public void InvokeEvent()
  44. {
  45. if (acEvent != null)
  46. {
  47. this.acEvent();
  48. }
  49. }
  50. }
  51. }