protected void Update() { foreach (SSAction ac in AddAction) { diction[ac.GetInstanceID()] = ac; } AddAction.Clear(); //将要进行的动作加入到执行的字典中 //将要删除的加到删除列表中 foreach (KeyValuePair <int, SSAction> dic in diction) { SSAction ac = dic.Value; if (ac.destory == true) { DeleteAction.Add(ac.GetInstanceID()); } else if (ac.enable == true) { ac.Update(); } } //将删除列表中的元素进行删除 foreach (int id in DeleteAction) { SSAction ac = diction[id]; diction.Remove(id); DestroyObject(ac); } DeleteAction.Clear(); }
protected void FixedUpdate() { foreach (SSAction ac in watingAddAction) { dictionary[ac.GetInstanceID()] = ac; } watingAddAction.Clear(); // 将待加入动作加入dictionary执行 foreach (KeyValuePair <int, SSAction> dic in dictionary) { SSAction ac = dic.Value; if (ac.destory) { watingDelete.Add(ac.GetInstanceID()); } else if (ac.enable) { ac.FixedUpdate(); } } // 如果要删除,加入要删除的list,否则更新 foreach (int id in watingDelete) { SSAction ac = dictionary[id]; dictionary.Remove(id); DestroyObject(ac); } watingDelete.Clear(); // 将deletelist中的动作删除 }
protected void Update() { foreach (SSAction ac in watingAddAction) { dictionary[ac.GetInstanceID()] = ac; } watingAddAction.Clear(); foreach (KeyValuePair <int, SSAction> dic in dictionary) { SSAction ac = dic.Value; if (ac.destory) { watingDelete.Add(ac.GetInstanceID()); } else if (ac.enable) { ac.Update(); } } foreach (int id in watingDelete) { SSAction ac = dictionary[id]; dictionary.Remove(id); DestroyObject(ac); } watingDelete.Clear(); }