public void MapObjectUnRegisterAll(MapObject mapObject) { List <RepresentHandle> handles; if (MapObjectRegisterDict.TryGetValue(mapObject, out handles)) { for (int index = 0; index < handles.Count; index++) { RepresentHandle handle = handles[index]; if (!DeleteMapObjectDict.ContainsKey(handle)) { DeleteMapObjectDict.Add(handle, new List <MapObject>()); } DeleteMapObjectDict[handle].Add(mapObject); } MapObjectRegisterDict.Remove(mapObject); } }
public void Update() { if (AddMapObjectDict.Count > 0) { Dictionary <RepresentHandle, List <MapObject> > .Enumerator enumerator = AddMapObjectDict.GetEnumerator(); while (enumerator.MoveNext()) { if (!ExecuteList.Contains(enumerator.Current.Key)) { ExecuteList.Add(enumerator.Current.Key); } List <MapObject> mapObjects; if (!HandleRegisterDict.TryGetValue(enumerator.Current.Key, out mapObjects)) { mapObjects = new List <MapObject>(); HandleRegisterDict.Add(enumerator.Current.Key, mapObjects); } for (int index = 0; index < enumerator.Current.Value.Count; index++) { mapObjects.Add(enumerator.Current.Value[index]); } } AddMapObjectDict.Clear(); ExecuteList.Sort((left, right) => { int leftOrder = (int)left.Order(); int rightOrder = (int)right.Order(); return(leftOrder.CompareTo(rightOrder)); }); } if (DeleteMapObjectDict.Count > 0) { Dictionary <RepresentHandle, List <MapObject> > .Enumerator enumerator = DeleteMapObjectDict.GetEnumerator(); while (enumerator.MoveNext()) { List <MapObject> mapObjects; if (HandleRegisterDict.TryGetValue(enumerator.Current.Key, out mapObjects)) { for (int index = 0; index < enumerator.Current.Value.Count; index++) { mapObjects.Remove(enumerator.Current.Value[index]); } if (mapObjects.Count == 0) { ExecuteList.Remove(enumerator.Current.Key); } } else { Debug.LogError("RepresentManager Delete Fail.Handle Type Is Empty. type:" + enumerator.Current.Key.GetType().Name); } } DeleteMapObjectDict.Clear(); } if (ExecuteList.Count > 0) { for (int index = 0; index < ExecuteList.Count; index++) { RepresentHandle handle = ExecuteList[index]; List <MapObject> mapObjects; if (!HandleRegisterDict.TryGetValue(handle, out mapObjects)) { Debug.LogError("RepresentManager Execute Fail.Handle Register Is Empty. type:" + handle.GetType().Name); continue; } if (mapObjects.Count != 0) { for (int i = 0; i < mapObjects.Count; i++) { handle.Execute(mapObjects[i]); } } else { Debug.LogError("RepresentManager Execute count is Empty. type:" + handle.GetType().Name); } } } }