57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
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()
|
|
{
|
|
|
|
}
|
|
public void StartTime(UnityAction action)
|
|
{
|
|
HandleAnimation("5", action);
|
|
}
|
|
|
|
void HandleAnimation(string s, UnityAction action)
|
|
{
|
|
var text = transform.Find("Text");
|
|
text.GetComponent<Text>().text = s;
|
|
text.transform.GetComponent<RectTransform>().DOScale(Vector3.one * 2, 0.5f).onComplete = () =>
|
|
{
|
|
text.GetComponent<RectTransform>().DOScale(Vector3.one * 0.5f, 0.5f).onComplete = ()=>
|
|
{
|
|
if (s == "Go")
|
|
{
|
|
action.Invoke();
|
|
gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
var flag = int.TryParse(s,out int a);
|
|
if (flag)
|
|
{
|
|
if (a - 1 == 0)
|
|
{
|
|
HandleAnimation("Go", action);
|
|
}
|
|
else
|
|
{
|
|
HandleAnimation((a - 1).ToString(), action);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|