public void RemoveCdFinishedandler(string taskName, CDTask.OnFinish onFinishedHandler) { CDTask task = GetCdTask(taskName); if (task != null) { task.OnFinished -= onFinishedHandler; } }
/// <summary> /// 倒计时 /// </summary> /// <param name="taskName"></param> /// <param name="totalTime"></param> /// <param name="onUpdate"></param> /// <param name="onFinished"></param> /// <param name="updateFrequence"></param> /// <param name="timeScale"></param> /// <returns></returns> public CDTask SetupCoolDown(string taskName, float totalTime, CDTask.OnUpdate onUpdate, CDTask.OnFinish onFinished, float updateFrequence = 0.1f, bool timeScale = false) { if (string.IsNullOrEmpty(taskName)) { return(null); } if (totalTime <= 0) { if (onFinished != null) { onFinished(); } return(null); } CDTask cdTask = GetCdTask(taskName); if (cdTask != null) { cdTask.Reset(totalTime, onUpdate, onFinished, updateFrequence, timeScale); } else { cdTask = new CDTask(taskName, totalTime, onUpdate, onFinished, updateFrequence, timeScale); } return(cdTask); }