ITimerCircle介面
var timer = TimerEx.Count();
timer是實作ITimerCircle介面的實例
以下是ITimerCircle的屬性/方法/事件介紹
屬性
/// <summary>
/// 是否暫停計時器
/// </summary>
bool pause { get; set; }
/// <summary>
/// 計時器是否啟動了
/// </summary>
bool isStarted { get; }
/// <summary>
/// 計時器是否停止了
/// </summary>
bool isStopped { get; }
方法
/// <summary>
/// 每幾秒一個循環
/// </summary>
/// <param name="sec"></param>
/// <returns></returns>
ITimer Circle(float sec);
/// <summary>
/// 啟動計時器
/// </summary>
/// <param name="delaySec">延時幾秒啟動</param>
ITimer Start(float delaySec = 0);
/// <summary>
/// 移除計時器
/// </summary>
void Remove();
/// <summary>
/// 移除事件
/// </summary>
void RemoveEvent(Action<float> callback);
事件
/// <summary>
/// 每秒回呼
/// </summary>
/// <param name="callback">回傳當下數到的秒數(以總時間為基準)</param>
/// <returns></returns>
ITimer On1Second(Action<float> callback);
/// <summary>
/// 間隔幾秒回呼
/// </summary>
/// <param name="time">間隔秒數</param>
/// <param name="callback">回傳當下數到的秒數(以總時間為基準)</param>
/// <returns></returns>
ITimer OnInterval(float sec, Action<float> callback);
/// <summary>
/// 計時完畢時回呼
/// </summary>
/// <param name="callback">回傳總經過秒數(延遲的時間也會算入)</param>
/// <returns></returns>
ITimer OnCompleted(Action<float> callback);
/// <summary>
/// 循環中的每秒回呼
/// </summary>
/// <param name="callback">回傳當下數到的秒數(以循環時間為基準)</param>
/// <returns></returns>
ITimer OnCircle1Second(Action<float> callback);
/// <summary>
/// 循環中的間隔幾秒回呼
/// </summary>
/// <param name="time">間隔秒數</param>
/// <param name="callback">回傳當下數到的秒數(以循環時間為基準)</param>
/// <returns></returns>
ITimer OnCircleInterval(float sec, Action<float> callback);
/// <summary>
/// 一個循環完成時回呼
/// </summary>
/// <param name="callback">回傳當下經過了幾次的循環, 沒延遲的話通常都是1</param>
/// <returns></returns>
ITimer OnCircleCompleted(Action<float> callback);
**註: 一個計時器可以串多個事件**