LangChaoDongHua.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using DG.Tweening;
  5. using XRTool.Util;
  6. using System;
  7. public class LangChaoDongHua : MonoBehaviour
  8. {
  9. public List<LangChaoDongHua> lcdh = new List<LangChaoDongHua>();
  10. public GameObject go;
  11. public GameObject start;
  12. public GameObject end;
  13. public float timef = 1f;
  14. public int count=1;
  15. public float waitTime = 0f;
  16. int nowcount = 0;
  17. // Start is called before the first frame update
  18. void Start()
  19. {
  20. }
  21. public Action<bool> endCallBack;
  22. Timer t;
  23. Timer wt;
  24. public void startdonghua()
  25. {
  26. go.SetActive(true);
  27. go.transform.localPosition = start.transform.localPosition;
  28. go.transform.localEulerAngles = start.transform.localEulerAngles;
  29. go.transform.localScale = start.transform.localScale;
  30. if (start.transform.localPosition != end.transform.localPosition)
  31. go.transform.DOLocalMove(end.transform.localPosition, timef);
  32. if (start.transform.localEulerAngles != end.transform.localEulerAngles)
  33. go.transform.DOLocalRotate(end.transform.localEulerAngles, timef);
  34. if (start.transform.localScale != end.transform.localScale)
  35. go.transform.DOScale(end.transform.localScale, timef);
  36. if(timef==0)
  37. {
  38. wt = TimerMgr.Instance.CreateTimer(() => {
  39. for (int i = 0; i < lcdh.Count; i++)
  40. {
  41. lcdh[i].startdonghua();
  42. }
  43. go.SetActive(end.activeSelf);
  44. }, waitTime);
  45. }
  46. else
  47. {
  48. t = TimerMgr.Instance.CreateTimer(() => {
  49. if (count == -1)
  50. {
  51. startdonghua();
  52. }
  53. else
  54. {
  55. nowcount++;
  56. if (nowcount < count)
  57. {
  58. startdonghua();
  59. }
  60. else
  61. {
  62. wt = TimerMgr.Instance.CreateTimer(() => {
  63. for (int i = 0; i < lcdh.Count; i++)
  64. {
  65. lcdh[i].startdonghua();
  66. }
  67. go.SetActive(end.activeSelf);
  68. }, waitTime);
  69. }
  70. }
  71. }, timef);
  72. }
  73. }
  74. public void reset()
  75. {
  76. nowcount = 0;
  77. go.transform.DOKill();
  78. go.SetActive(start.activeSelf);
  79. go.transform.localPosition = start.transform.localPosition;
  80. go.transform.localEulerAngles = start.transform.localEulerAngles;
  81. go.transform.localScale = start.transform.localScale;
  82. TimerMgr.Instance.DestroyTimer(t);
  83. TimerMgr.Instance.DestroyTimer(wt);
  84. for (int i = 0; i < lcdh.Count; i++)
  85. {
  86. lcdh[i].reset();
  87. }
  88. }
  89. }