public void AddTimer(string name, TIMERTYPE type, float inval, TimerCallback cb, int counter = 0, float delay = 0.0f) { if (string.IsNullOrEmpty(name)) { Debug.LogError("Add Timer Name is Null"); } TimerData data = new TimerData(); data.timerName = name; data.timerType = type; data.timerInval = inval; data.timerEndTime = Time.realtimeSinceStartup + inval; data.timerCounter = counter; data.timerDelay = delay; data.timerCB = cb; if (timerAddDic.ContainsKey(name)) { Debug.LogError("Repeat Add Timer " + name); return; } timerAddDic.Add(name, data); }
public void Refresh(TIMERTYPE type) { switch (type) { case TIMERTYPE.FREEZE: counter = 0.0f; break; case TIMERTYPE.SPEEDUP: //speedup可以累积 counter -= 7.0f; break; } }
public void Setup(TIMERTYPE type, UnityAction action) { switch (type) { case TIMERTYPE.FREEZE: this.type = type; time = 10.0f; timesUp.AddListener(action); break; case TIMERTYPE.SPEEDUP: this.type = type; time = 7.0f; timesUp.AddListener(action); break; } }