public void RxDictObserve() { var dict = new ReactiveDictionary <string, int>(); var count = 0; DictionaryAddEvent <string, int> addE = null; DictionaryRemoveEvent <string, int> removeE = null; DictionaryReplaceEvent <string, int> replaceE = null; var resetCount = 0; dict.ObserveCountChanged().Subscribe(x => count = x); dict.ObserveAdd().Subscribe(x => addE = x); dict.ObserveRemove().Subscribe(x => removeE = x); dict.ObserveReplace().Subscribe(x => replaceE = x); dict.ObserveReset().Subscribe(x => resetCount += 1); dict.Add("a", 100); count.Is(1); addE.Key.Is("a"); addE.Value.Is(100); dict.Add("b", 200); count.Is(2); addE.Key.Is("b"); addE.Value.Is(200); count = -1; dict["a"] = 300; count.Is(-1); // not fired addE.Key.Is("b"); // not fired replaceE.Key.Is("a"); replaceE.OldValue.Is(100); replaceE.NewValue.Is(300); dict["c"] = 400; count.Is(3); replaceE.Key.Is("a"); // not fired addE.Key.Is("c"); addE.Value.Is(400); dict.Remove("b"); count.Is(2); removeE.Key.Is("b"); removeE.Value.Is(200); count = -1; dict.Remove("z"); count.Is(-1); // not fired removeE.Key.Is("b"); // not fired dict.Clear(); count.Is(0); resetCount.Is(1); count = -1; dict.Clear(); resetCount.Is(2); count.Is(-1); // not fired }
void SpawnObject(DictionaryAddEvent <int, string> addEvent) { var addEventvalue = addEvent.Value.Split(new [] { '/' }); if (gm.myRobotID == addEvent.Key) { //Instantiate my robot with isMine = true; MRPM_SyncedObject.Instantiate(_bulletPrefab, addEvent.Key, true, new Vector3(float.Parse(addEventvalue[0]), 0, float.Parse(addEventvalue[1])), Quaternion.Euler(0, float.Parse(addEventvalue[2]), 0), _syncObjParent); } else { MRPM_SyncedObject.Instantiate(_bulletPrefab, addEvent.Key, false, new Vector3(float.Parse(addEventvalue[0]), 0, float.Parse(addEventvalue[1])), Quaternion.Euler(0, float.Parse(addEventvalue[2]), 0), _syncObjParent); } }
void SpawnRobot(DictionaryAddEvent <int, string> addEvent) { var addEventvalue = addEvent.Value.Split(new [] { '/' }); if (gm.myRobotID == addEvent.Key) { //Instantiate my robot with isMine = true; var robot = MRPM_Player.Instantiate(_robotPrefab, addEvent.Key, true, new Vector3(float.Parse(addEventvalue[0]), 0, float.Parse(addEventvalue[1])), Quaternion.Euler(0, float.Parse(addEventvalue[2]), 0), _syncObjParent); //this is my robot so attach camera Camera.main.transform.parent = robot.transform; Camera.main.transform.localPosition = new Vector3(0, 0.5f, 0); Camera.main.transform.rotation = Quaternion.identity; } else { MRPM_Player.Instantiate(_robotPrefab, addEvent.Key, false, new Vector3(float.Parse(addEventvalue[0]), 0, float.Parse(addEventvalue[1])), Quaternion.Euler(0, float.Parse(addEventvalue[2]), 0), _syncObjParent); } }
void SpawnSyncedObject(DictionaryAddEvent <int, string> addEvent) { int keyInt = addEvent.Key; if (keyInt == 90) { //this is grobal info //Do nothing here } else if (keyInt % 10 == 0) { //this is robot's id SpawnRobot(addEvent); } else { //this is object's id SpawnObject(addEvent); } }
private void HandleAdd(DictionaryAddEvent <int, Player> player) { DistributePlayerInfo(player.Value); }
private void OnAnimalAdd(DictionaryAddEvent <long, AnimalRemoteDataModel> obj) { SpawnAnimal(obj.Value).Catch(exception => Debug.LogError(exception)); }
private void OnAddParameter(DictionaryAddEvent <string, Parameter> parameterAddEvent) { RegisterParameter(parameterAddEvent.Key, parameterAddEvent.Value); }
private void HandleAdd(DictionaryAddEvent <int, PlayerData> player) { SetText(); }
public virtual void OnAdd_DefaultDictionary2(DictionaryAddEvent <int, string> e) { }
public virtual void OnAdd_DefaultDictionary1(DictionaryAddEvent <string, string> e) { }
private void HandleAdd(DictionaryAddEvent <int, PlayerData> player) { PlayerObject playerObject = playerObjectFactory.Create(); playerObject.playerId = player.Key; }
public virtual void OnAdd_MyDictionary(DictionaryAddEvent <string, string> e) { }
public virtual void OnAdd_IntDictionary(DictionaryAddEvent <string, int> e) { }