using System.Collections; using System.Collections.Generic; using UnityEngine; using DG.Tweening; using XRTool.Util; using System; public class LangChaoDongHua : MonoBehaviour { public YunWeiZhiDao yzd; public bool isTiaoGuo; public bool isClick = false; public List lcdh = new List(); public GameObject go; public GameObject start; public GameObject end; public float timef = 1f; public int count=1; public float waitTime = 0f; public GameObject showGo; int nowcount = 0; // Start is called before the first frame update void Start() { } public Action endCallBack; Timer t; Timer wt; public void startdonghua() { if (showGo) showGo.SetActive(true); go.SetActive(true); go.transform.localPosition = start.transform.localPosition; go.transform.localEulerAngles = start.transform.localEulerAngles; go.transform.localScale = start.transform.localScale; if (start.transform.localPosition != end.transform.localPosition) go.transform.DOLocalMove(end.transform.localPosition, timef); if (start.transform.localEulerAngles != end.transform.localEulerAngles) go.transform.DOLocalRotate(end.transform.localEulerAngles, timef); if (start.transform.localScale != end.transform.localScale) go.transform.DOScale(end.transform.localScale, timef); if(timef==0) { wt = TimerMgr.Instance.CreateTimer(() => { if (!isClick) { if (isTiaoGuo) { yzd.nextTask(); } for (int i = 0; i < lcdh.Count; i++) { lcdh[i].startdonghua(); } go.SetActive(end.activeSelf); if (showGo) showGo.SetActive(false); } }, waitTime); } else { t = TimerMgr.Instance.CreateTimer(() => { if (count == -1) { startdonghua(); } else { nowcount++; if (nowcount < count) { startdonghua(); } else { wt = TimerMgr.Instance.CreateTimer(() => { if(!isClick) { if(isTiaoGuo) { yzd.nextTask(); } for (int i = 0; i < lcdh.Count; i++) { lcdh[i].startdonghua(); } if (showGo) showGo.SetActive(false); go.SetActive(end.activeSelf); } }, waitTime); } } }, timef); } } public void Next() { for (int i = 0; i < lcdh.Count; i++) { lcdh[i].startdonghua(); } if (showGo) showGo.SetActive(false); go.SetActive(end.activeSelf); if (TimerMgr.Instance) { TimerMgr.Instance.DestroyTimer(t); TimerMgr.Instance.DestroyTimer(wt); } } public void reset() { if(showGo) showGo.SetActive(false); nowcount = 0; go.transform.DOKill(); go.SetActive(start.activeSelf); go.transform.localPosition = start.transform.localPosition; go.transform.localEulerAngles = start.transform.localEulerAngles; go.transform.localScale = start.transform.localScale; if(TimerMgr.Instance) { TimerMgr.Instance.DestroyTimer(t); TimerMgr.Instance.DestroyTimer(wt); } for (int i = 0; i < lcdh.Count; i++) { if(lcdh[i]) lcdh[i].reset(); } } }