範例-倒數計時器
收到server回傳的alive值, 倒數完畢後做某些事情!
yield return NetManager.Send(req);
TimerEx.Countdown(req.Alive)
.OnCompleted(t => Debug.Log("do something"))
.Start();
新增需求: 要倒數給玩家看唷~
yield return NetManager.Send(req);
TimerEx.Countdown(req.Alive)
.On1Second(t => tx.text = ((int)t).ExFormatTimeMMSS()) // <--add
.OnCompleted(t => Debug.Log("do something"))
.Start();
新增需求: 每10秒撥個矯情的動畫唄~
yield return NetManager.Send(req);
TimerEx.Countdown(req.Alive)
.On1Second(t => tx.text = ((int)t).ExFormatTimeMMSS())
.OnInterval(10, t => PlayAnimation()) // <--add
.OnCompleted(t => Debug.Log("do something"))
.Start();
**註: 計時器用法一樣, Countdown換成Count就是了**