All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 7s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 11s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 10s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 7s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 5s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 38s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 3s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 4s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 17s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 19s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 3s
Plugin Library CI / publish (12.WeixinMinigame) (push) Successful in 1m2s
Plugin Library CI / publish (07.RKTools) (push) Successful in 3s
Plugin Library CI / publish (08.UniTask) (push) Successful in 3s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 4s
Plugin Library CI / publish (10.XNode) (push) Successful in 4s
56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
using System;
|
|
using Stary.Evo;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
namespace Stary.Evo
|
|
{
|
|
public class TimerController : MonoBehaviour, IController
|
|
{
|
|
public string TimerName => gameObject.name;
|
|
private bool isStart = false;
|
|
|
|
/// <summary>
|
|
/// 持续时间
|
|
/// </summary>
|
|
private float timeDuration;
|
|
|
|
|
|
/// <summary>
|
|
/// 时间到达的事件
|
|
/// </summary>
|
|
private Action onArrivalTimeComplete;
|
|
|
|
/// <summary>
|
|
/// 持续时间最大阈值
|
|
/// </summary>
|
|
public float timeDurationMax;
|
|
|
|
public void StartTimer(float timeDurationMax, Action onArrivalTimeComplete)
|
|
{
|
|
this.timeDurationMax = timeDurationMax;
|
|
this.onArrivalTimeComplete = onArrivalTimeComplete;
|
|
timeDuration = 0;
|
|
isStart = true;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (isStart)
|
|
{
|
|
timeDuration += Time.deltaTime;
|
|
if (timeDuration >= timeDurationMax)
|
|
{
|
|
onArrivalTimeComplete?.Invoke();
|
|
this.GetSystem<TimerSystem>().RemoveTimer(TimerName);
|
|
}
|
|
}
|
|
}
|
|
|
|
public IArchitecture GetArchitecture()
|
|
{
|
|
ITimerSystem system = this.GetSystem<TimerSystem>();
|
|
return system.GetArchitecture();
|
|
}
|
|
}
|
|
} |