mycj_demo/mycj/Assets/Game/Scripts/Application/02View/Level/FBUICountDown.cs
2024-12-02 09:37:47 +08:00

104 lines
2.4 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Felix-BangFBUICountDown
//   へ     /|
//  /7    ∠_/
//  / │    
//  Z _,    /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │
//  / へ   / ノ<|
//  ヽ_ノ  (_  │//
//  7       |
//  ―r ̄ ̄`ー―_
// Describe关卡-倒计时
// Createtime2018/9/28
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FBFramework;
using UnityEngine.UI;
using System;
namespace FBApplication
{
public class FBUICountDown : FBView
{
#region
[SerializeField]
private Image imgCount;
[SerializeField]
private Sprite[] sptNumbers;
#endregion
#region
public override string Name
{
get { return FBConsts.V_CountDown; }
}
#endregion
#region
public override void RegisterEvents()
{
EventLists.Add(FBConsts.E_SceneEnter);
}
public override void HandleEvent(string eventName, object data = null)
{
switch (eventName)
{
case FBConsts.E_SceneEnter:
FBSceneArgs e = (FBSceneArgs)data;
if (e.Index == 3)
StartCountDown();
break;
default:
break;
}
}
#endregion
#region
private void Show()
{
gameObject.SetActive(true);
}
private void Hide()
{
gameObject.SetActive(false);
}
public void StartCountDown()
{
Show();
StartCoroutine("DisplayCount");
}
IEnumerator DisplayCount()
{
int count = 3;
while (count > 0)
{
imgCount.sprite = sptNumbers[count - 1];
count--;
yield return new WaitForSeconds(1f);
if (count <= 0)
break;
}
Hide();
SendEvent(FBConsts.E_CountDownComplete);
}
#endregion
}
}