public void onRemoteUpdateMove(RemoteEventBase theEvent) { Logger.firebase("Humanoid onRemoteUpdate +" + " " + theEvent.getEventId()); lock (unitlock) { toUpdateList.Add(theEvent); } }
public void onRemoteCreate(RemoteEventBase theEvent) { Logger.firebase("Humanoid onRemoteCreate +" + " " + theEvent.getEventId()); lock (mylock) { toCreateList.Add(theEvent); } }
// Update is called once per frame void FixedUpdate() { lock (mylock) { foreach (System.Object o in toCreateList) { copyToCreateList.Add(o); } toCreateList.Clear(); } foreach (System.Object o in copyToCreateList) { RemoteEventBase todoEvent = (RemoteEventBase)o; Debug.Log("Humanoid onRemoteCreate +" + " " + todoEvent.getEventId() + " " + todoEvent.getCurrentLocation().y); onCreateUnit(todoEvent); } copyToCreateList.Clear(); lock (unitlock) { foreach (System.Object o in toUpdateList) { copyToUpdateList.Add(o); } toUpdateList.Clear(); } foreach (System.Object o in copyToUpdateList) { RemoteEventBase todoEvent = (RemoteEventBase)o; BaseUnit result = null; if (unitInstances.TryGetValue(todoEvent.getActorId(), out result)) { Logger.firebase("Humanoid onRemoteUpdate find " + todoEvent.getActorId() + ", " + todoEvent.getCurrentLocation().y + ", " + gameObject.transform.localPosition.y + ", " + todoEvent.getTargetLocation().y); onMoveUnit(todoEvent, result); } else { Logger.firebase("Humanoid onRemoteUpdate not find " + todoEvent.getActorId()); onCreateUnit(todoEvent); } } copyToUpdateList.Clear(); onFixedUPdate(); }