public static void RemoveLoopedTask(int _taskID) { if (LoopedTaskManager.instance.LoopedTasks.ContainsKey(_taskID)) { ClockManager.RemoveClock(LoopedTaskManager.instance.LoopedTasks[_taskID].ClockID); LoopedTaskManager.instance.LoopedTasks.Remove(_taskID); } }
public static void RemoveTask(int _taskID) { if (TaskManager.instance.Tasks.ContainsKey(_taskID)) { ClockManager.RemoveClock(TaskManager.instance.Tasks[_taskID].ClockID); TaskManager.instance.Tasks.Remove(_taskID); } }
private void Update() { foreach (KeyValuePair <int, Task> _keyValuePair in TaskManager.instance.Tasks.ToArray()) { if (ClockManager.ClockMet(_keyValuePair.Value.ClockID)) { RunTask(_keyValuePair.Key); RemoveTask(_keyValuePair.Key); } } }
public static int AddTask(Action _timedAction, double _delay) { int randomKey = TaskManager.instance.currentRandom.Next(-2147483648, 2147483647); while (TaskManager.instance.Tasks.ContainsKey(randomKey) || (randomKey == 0)) { randomKey = TaskManager.instance.currentRandom.Next(-2147483648, 2147483647); } TaskManager.instance.Tasks.Add(randomKey, new Task(_timedAction, ClockManager.AddClock(_delay))); return(randomKey); }
private static void RunLoopedTask(int _taskID) { if (LoopedTaskManager.instance.LoopedTasks[_taskID].ClockID == 0) { return; } try { LoopedTask loopedTask = LoopedTaskManager.instance.LoopedTasks[_taskID]; loopedTask.LoopedTaskAction(ClockManager.ClockRelativeTimeElapsed(loopedTask.ClockID)); } catch { Debug.LogError("TimeW.LoopedTimeManager.RunLoopedTask() Attempt to run task failed!"); } }
private void Update() { foreach (KeyValuePair <int, LoopedTask> _keyValuePair in LoopedTaskManager.instance.LoopedTasks.ToArray()) { if (!ClockManager.ClockStarted(_keyValuePair.Value.ClockID)) { continue; } if (ClockManager.ClockMet(_keyValuePair.Value.ClockID)) { RunLoopedTask(_keyValuePair.Key); RemoveLoopedTask(_keyValuePair.Key); } else { RunLoopedTask(_keyValuePair.Key); } } }
private void Awake() { lock (_lockobject) { _singleton = this; ClockManager[] _clockList = FindObjectsOfType <ClockManager>(); foreach (ClockManager clock in _clockList) { if (clock != this) { clock.gameObject.SetActive(false); Destroy(clock); Destroy(clock.gameObject); } } transform.gameObject.name = this.GetType().Name; } activationTime = DateTime.Now; }
public static int AddLoopedTask(Action <double> _timedAction, double _loopedTime) { int randomKey = LoopedTaskManager.instance.currentRandom.Next(-2147483648, 2147483647); while (LoopedTaskManager.instance.LoopedTasks.ContainsKey(randomKey) || (randomKey == 0)) { randomKey = LoopedTaskManager.instance.currentRandom.Next(-2147483648, 2147483647); } LoopedTaskManager.instance.LoopedTasks.Add(randomKey, new LoopedTask(_timedAction, ClockManager.AddClock(_loopedTime))); return(randomKey); }