ImageMove.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 bool Update()
  22. {
  23. if (currAcur.CurveInfos == null)
  24. {
  25. return true;
  26. }
  27. yanChi -= Time.deltaTime;
  28. if (yanChi > 0)
  29. {
  30. return false;
  31. }
  32. GameObjectPool.own.gameObject.SetActive(true);
  33. if (isShowSize)
  34. {
  35. currTime += Time.deltaTime * showSizeSpeed;
  36. float ss = currTime;
  37. if (ShowSizeCurve != null)
  38. {
  39. ss = ShowSizeCurve.Evaluate(currTime);
  40. transform.localScale = Vector3.one * ss;
  41. }
  42. Vector3 p = Vector3.Lerp(moveStartPos, moveTargetPos, ss);
  43. transform.anchoredPosition = p;
  44. if (currTime >= 1)
  45. {
  46. isShowSize = false;
  47. currTime = 0;
  48. }
  49. return false;
  50. }
  51. currTime += Time.deltaTime * speed;
  52. float ms = currTime;
  53. if (moveSpeed != null)
  54. {
  55. ms = moveSpeed.Evaluate(currTime);
  56. }
  57. transform.anchoredPosition = currAcur.EvaluateForVector2(ms);
  58. float s = currTime;
  59. if (SizeCurve != null)
  60. {
  61. s = SizeCurve.Evaluate(currTime);
  62. transform.localScale = Vector3.one * s;
  63. }
  64. if (currTime > 1)
  65. {
  66. currAcur.CurveInfos = null;
  67. }
  68. return false;
  69. }
  70. }