LangChaoDongHua.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 YunWeiZhiDao yzd;
  10. public bool isTiaoGuo;
  11. public bool isClick = false;
  12. public List<LangChaoDongHua> lcdh = new List<LangChaoDongHua>();
  13. public GameObject go;
  14. public GameObject start;
  15. public GameObject end;
  16. public float timef = 1f;
  17. public int count=1;
  18. public float waitTime = 0f;
  19. public GameObject showGo;
  20. int nowcount = 0;
  21. // Start is called before the first frame update
  22. void Start()
  23. {
  24. }
  25. public Action<bool> endCallBack;
  26. Timer t;
  27. Timer wt;
  28. public void startdonghua()
  29. {
  30. if (showGo)
  31. showGo.SetActive(true);
  32. go.SetActive(true);
  33. go.transform.localPosition = start.transform.localPosition;
  34. go.transform.localEulerAngles = start.transform.localEulerAngles;
  35. go.transform.localScale = start.transform.localScale;
  36. if (start.transform.localPosition != end.transform.localPosition)
  37. go.transform.DOLocalMove(end.transform.localPosition, timef);
  38. if (start.transform.localEulerAngles != end.transform.localEulerAngles)
  39. go.transform.DOLocalRotate(end.transform.localEulerAngles, timef);
  40. if (start.transform.localScale != end.transform.localScale)
  41. go.transform.DOScale(end.transform.localScale, timef);
  42. if(timef==0)
  43. {
  44. wt = TimerMgr.Instance.CreateTimer(() => {
  45. if (!isClick)
  46. {
  47. if (isTiaoGuo)
  48. {
  49. yzd.nextTask();
  50. }
  51. for (int i = 0; i < lcdh.Count; i++)
  52. {
  53. lcdh[i].startdonghua();
  54. }
  55. go.SetActive(end.activeSelf);
  56. if (showGo)
  57. showGo.SetActive(false);
  58. }
  59. }, waitTime);
  60. }
  61. else
  62. {
  63. t = TimerMgr.Instance.CreateTimer(() => {
  64. if (count == -1)
  65. {
  66. startdonghua();
  67. }
  68. else
  69. {
  70. nowcount++;
  71. if (nowcount < count)
  72. {
  73. startdonghua();
  74. }
  75. else
  76. {
  77. wt = TimerMgr.Instance.CreateTimer(() => {
  78. if(!isClick)
  79. {
  80. if(isTiaoGuo)
  81. {
  82. yzd.nextTask();
  83. }
  84. for (int i = 0; i < lcdh.Count; i++)
  85. {
  86. lcdh[i].startdonghua();
  87. }
  88. if (showGo)
  89. showGo.SetActive(false);
  90. go.SetActive(end.activeSelf);
  91. }
  92. }, waitTime);
  93. }
  94. }
  95. }, timef);
  96. }
  97. }
  98. public void Next()
  99. {
  100. for (int i = 0; i < lcdh.Count; i++)
  101. {
  102. lcdh[i].startdonghua();
  103. }
  104. if (showGo)
  105. showGo.SetActive(false);
  106. go.SetActive(end.activeSelf);
  107. if (TimerMgr.Instance)
  108. {
  109. TimerMgr.Instance.DestroyTimer(t);
  110. TimerMgr.Instance.DestroyTimer(wt);
  111. }
  112. }
  113. public void reset()
  114. {
  115. if(showGo)
  116. showGo.SetActive(false);
  117. nowcount = 0;
  118. go.transform.DOKill();
  119. go.SetActive(start.activeSelf);
  120. go.transform.localPosition = start.transform.localPosition;
  121. go.transform.localEulerAngles = start.transform.localEulerAngles;
  122. go.transform.localScale = start.transform.localScale;
  123. if(TimerMgr.Instance)
  124. {
  125. TimerMgr.Instance.DestroyTimer(t);
  126. TimerMgr.Instance.DestroyTimer(wt);
  127. }
  128. for (int i = 0; i < lcdh.Count; i++)
  129. {
  130. if(lcdh[i])
  131. lcdh[i].reset();
  132. }
  133. }
  134. }