123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- 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<LangChaoDongHua> lcdh = new List<LangChaoDongHua>();
- 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<bool> 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();
- }
- }
- }
|