ImageMove.cs 2.1 KB

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