2021-09-28 17:51:58 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
|
using DG.Tweening;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
public class CountDownAnimation : PFUIPanel
|
|
|
|
|
|
{
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
|
void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-09-30 15:23:40 +08:00
|
|
|
|
public void StartTime(UnityAction action,UnityAction action2)
|
2021-09-28 17:51:58 +08:00
|
|
|
|
{
|
2021-09-30 15:23:40 +08:00
|
|
|
|
HandleAnimation("5", action, action2);
|
2021-09-28 17:51:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-09-30 15:23:40 +08:00
|
|
|
|
void HandleAnimation(string s, UnityAction action, UnityAction action2)
|
2021-09-28 17:51:58 +08:00
|
|
|
|
{
|
2021-09-28 20:35:05 +08:00
|
|
|
|
var text = transform.Find("Text");
|
|
|
|
|
|
text.GetComponent<Text>().text = s;
|
|
|
|
|
|
text.transform.GetComponent<RectTransform>().DOScale(Vector3.one * 2, 0.5f).onComplete = () =>
|
2021-09-28 17:51:58 +08:00
|
|
|
|
{
|
2021-09-28 20:35:05 +08:00
|
|
|
|
text.GetComponent<RectTransform>().DOScale(Vector3.one * 0.5f, 0.5f).onComplete = ()=>
|
2021-09-28 17:51:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (s == "Go")
|
|
|
|
|
|
{
|
|
|
|
|
|
action.Invoke();
|
|
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
var flag = int.TryParse(s,out int a);
|
2022-03-10 18:10:34 +08:00
|
|
|
|
Debug.Log(a);
|
2021-09-28 17:51:58 +08:00
|
|
|
|
if (flag)
|
|
|
|
|
|
{
|
2022-03-10 18:10:34 +08:00
|
|
|
|
if (a == 1 && action2 != null)
|
2021-09-30 15:23:40 +08:00
|
|
|
|
{
|
|
|
|
|
|
action2.Invoke();
|
|
|
|
|
|
}
|
2021-09-28 17:51:58 +08:00
|
|
|
|
if (a - 1 == 0)
|
|
|
|
|
|
{
|
2021-09-30 15:23:40 +08:00
|
|
|
|
HandleAnimation("Go", action, action2);
|
2021-09-28 17:51:58 +08:00
|
|
|
|
}
|
2021-09-30 15:23:40 +08:00
|
|
|
|
else
|
2021-09-28 17:51:58 +08:00
|
|
|
|
{
|
2021-09-30 15:23:40 +08:00
|
|
|
|
HandleAnimation((a - 1).ToString(), action, action2);
|
2021-09-28 17:51:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|