void Update() { if (list == null) { list = new List <myTimer>(); } bool delete = false; // Copies the current list to another one to allows the timers // to modify the tasks list (for instance : adding new tasks) List <myTimer> currentList = new List <myTimer>(list); foreach (myTimer t in currentList) { delete = delete || UpdateTimer(t); } if (delete) { int l = list.Count; for (int i = 0; i < l; i++) { myTimer t = list[i]; if (t.callback == null) { list.Remove(t); i--; l--; } } } }
public static void AddTimer(float time, CallBack callback) { myTimer t = new myTimer(); t.remainingTime = time; t.callback = callback; if(list == null) list = new List<myTimer>(); list.Add(t); }
public static void AddTimer(float time, CallBack callback) { myTimer t = new myTimer(); t.remainingTime = time; t.callback = callback; if (list == null) { list = new List <myTimer>(); } list.Add(t); }
private bool UpdateTimer(myTimer t) { t.remainingTime -= Time.deltaTime; if (t.remainingTime <= 0) { if (t.callback != null) t.callback(); t.callback = null; return true; } return false; }
private bool UpdateTimer(myTimer t) { t.remainingTime -= Time.deltaTime; if (t.remainingTime <= 0) { if (t.callback != null) { t.callback(); } t.callback = null; return(true); } return(false); }
// Use this for initialization void Awake() { this.animator = this.GetComponent<Animator> (); this.YakukoController = Yakuko.GetComponent<Script_SpriteStudio_PartsRoot> (); this.YakukoController.AnimationPlay (4, 0, 1, 1.0f); this.PlayerState = YakukoState.Sageru; this.timer = new myTimer (); }