ImageMove.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using CombatLibrary.CombatLibrary.CombatCore.Utility;
  4. using Fort23.Core;
  5. using Fort23.UTool;
  6. using UnityEngine;
  7. public class ImageMove: CObject
  8. {
  9. // public AnimationCurve ShowSizeCurve;
  10. public AnimationCurve SizeCurve;
  11. public AnimationCurve moveSpeed;
  12. public GameObjectPool GameObjectPool;
  13. public RectTransform transform;
  14. public ACurve currAcur;
  15. public float yanChi;
  16. private float currTime;
  17. public float speed;
  18. public bool isExp;
  19. public Vector3 moveStartPos;
  20. public int GroupIndex = 0;
  21. public System.Action<ImageMove> finishCallBack;
  22. public System.Action<ImageMove> targetPointSet;
  23. public bool Update()
  24. {
  25. if (currAcur.CurveInfos == null)
  26. {
  27. return true;
  28. }
  29. yanChi -= Time.deltaTime;
  30. if (yanChi > 0)
  31. {
  32. return false;
  33. }
  34. targetPointSet?.Invoke(this);
  35. GameObjectPool.own.gameObject.SetActive(true);
  36. currTime += Time.deltaTime * speed;
  37. float ms = currTime;
  38. if (moveSpeed != null)
  39. {
  40. ms = moveSpeed.Evaluate(currTime);
  41. }
  42. transform.anchoredPosition = currAcur.EvaluateForVector2(ms, ms);
  43. float s = currTime;
  44. if (SizeCurve != null)
  45. {
  46. s = SizeCurve.Evaluate(currTime);
  47. transform.localScale = Vector3.one * s;
  48. }
  49. if (currTime > 1)
  50. {
  51. currAcur.CurveInfos = null;
  52. finishCallBack?.Invoke(this);
  53. CObjectPool.Instance.Recycle(this);
  54. }
  55. return false;
  56. }
  57. public override void ActiveObj()
  58. {
  59. }
  60. public override void DormancyObj()
  61. {
  62. GObjectPool.Instance.Recycle(GameObjectPool);
  63. GameObjectPool = null;
  64. finishCallBack = null;
  65. yanChi = 0;
  66. currTime = 0;
  67. transform = null;
  68. moveSpeed = null;
  69. SizeCurve = null;
  70. currAcur.CurveInfos = null;
  71. targetPointSet = null;
  72. }
  73. }