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 Update() { // 将待加入动作加入dictionary执行 foreach (SSAction ac in waitingAddAction) { dictionary[ac.GetInstanceID()] = ac; } waitingAddAction.Clear(); // 判断waitingList中的动作对是否执行,如果要删除,加入要删除的list,否则更新 foreach (KeyValuePair <int, SSAction> dic in dictionary) { SSAction ac = dic.Value; if (ac.destory) { waitingDelete.Add(ac.GetInstanceID()); } else if (ac.enable) { ac.Update(); } } foreach (int id in waitingDelete) { SSAction ac = dictionary[id]; dictionary.Remove(id); DestroyObject(ac); } // 将deletelist中的动作删除 waitingDelete.Clear(); }
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(); }