73 lines
1.6 KiB
C#
73 lines
1.6 KiB
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
namespace BingoBrain.Core
|
||
|
|
{
|
||
|
|
public enum TimerTimeType : int
|
||
|
|
{
|
||
|
|
Null = -1,
|
||
|
|
|
||
|
|
|
||
|
|
Time = 0,
|
||
|
|
|
||
|
|
|
||
|
|
UnscaledTime = 1,
|
||
|
|
|
||
|
|
|
||
|
|
RealtimeSinceStartup = 2,
|
||
|
|
}
|
||
|
|
|
||
|
|
public sealed class TimerI : BaseUnity<TimerI>
|
||
|
|
{
|
||
|
|
private GameObject simpleTimersRoot;
|
||
|
|
private GameObject timersRoot;
|
||
|
|
private GameObject heavyTimersRoot;
|
||
|
|
|
||
|
|
private void InitTimersRoot()
|
||
|
|
{
|
||
|
|
simpleTimersRoot = new GameObject("SimpleTimers");
|
||
|
|
simpleTimersRoot.SetParent(gameObject);
|
||
|
|
|
||
|
|
timersRoot = new GameObject("Timers");
|
||
|
|
timersRoot.SetParent(gameObject);
|
||
|
|
|
||
|
|
heavyTimersRoot = new GameObject("HeavyTimers");
|
||
|
|
heavyTimersRoot.SetParent(gameObject);
|
||
|
|
}
|
||
|
|
|
||
|
|
public YFsa CreateSimpleTimer(string name, TimerTimeType type)
|
||
|
|
{
|
||
|
|
YFsa yFsa = simpleTimersRoot.AddComponent<YFsa>();
|
||
|
|
yFsa.SetTimer(name, type);
|
||
|
|
return yFsa;
|
||
|
|
}
|
||
|
|
|
||
|
|
public Psvsa CreateTimer(string name, TimerTimeType type)
|
||
|
|
{
|
||
|
|
Psvsa psvsa = timersRoot.AddComponent<Psvsa>();
|
||
|
|
psvsa.SetTimer(name, type);
|
||
|
|
return psvsa;
|
||
|
|
}
|
||
|
|
|
||
|
|
public UFdsa CreateHeavyTimer(string name, TimerTimeType type)
|
||
|
|
{
|
||
|
|
UFdsa uFdsa = heavyTimersRoot.AddComponent<UFdsa>();
|
||
|
|
uFdsa.SetTimer(name, type);
|
||
|
|
return uFdsa;
|
||
|
|
}
|
||
|
|
|
||
|
|
#region Mgr
|
||
|
|
|
||
|
|
public override void Init()
|
||
|
|
{
|
||
|
|
base.Init();
|
||
|
|
InitTimersRoot();
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnDestroy()
|
||
|
|
{
|
||
|
|
base.OnDestroy();
|
||
|
|
}
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
}
|
||
|
|
}
|