ChangeLocalID









How do I use Change Local I D
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: NetworkingPeer.cs Copy
459     private void LeftRoomCleanup()
460     {
461         bool wasInRoom = mRoomToGetInto != null;
462         // when leaving a room, we clean up depending on that room's settings.
463         bool autoCleanupSettingOfRoom = (this.mRoomToGetInto != null) ? this.mRoomToGetInto.autoCleanUp : PhotonNetwork.autoCleanUpPlayerObjects;
464
465         this.hasSwitchedMC = false;
466         this.mRoomToGetInto = null;
467         this.mActors = new Dictionary();
468         this.mPlayerListCopy = new PhotonPlayer[0];
469         this.mOtherPlayerListCopy = new PhotonPlayer[0];
470         this.mMasterClient = null;
471         this.allowedReceivingGroups = new HashSet();
472         this.blockSendingGroups = new HashSet();
473         this.mGameList = new Dictionary();
474         this.mGameListCopy = new RoomInfo[0];
475         this.isFetchingFriends = false;
476
477         this.ChangeLocalID(-1);
478
479         // Cleanup all network objects (all spawned PhotonViews, local and remote)
480         if (autoCleanupSettingOfRoom)
481         {
482             this.LocalCleanupAnythingInstantiated(true);
483             PhotonNetwork.manuallyAllocatedViewIds = new List(); // filled and easier to replace completely
484         }
485
486         if (wasInRoom)
487         {
488             SendMonoMessage(PhotonNetworkingMessage.OnLeftRoom);
489         }
490     }
File name: NetworkingPeer.cs Copy
822     private void GameEnteredOnGameServer(OperationResponse operationResponse)
823     {
824         if (operationResponse.ReturnCode != 0)
825         {
826             switch (operationResponse.OperationCode)
827             {
828                 case OperationCode.CreateGame:
829                     if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
830                     {
831                         Debug.Log("Create failed on GameServer. Changing back to MasterServer. Msg: " + operationResponse.DebugMessage);
832                     }
833                     SendMonoMessage(PhotonNetworkingMessage.OnPhotonCreateRoomFailed, operationResponse.ReturnCode, operationResponse.DebugMessage);
834                     break;
835                 case OperationCode.JoinGame:
836                     if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
837                     {
838                         Debug.Log("Join failed on GameServer. Changing back to MasterServer. Msg: " + operationResponse.DebugMessage);
839                         if (operationResponse.ReturnCode == ErrorCode.GameDoesNotExist)
840                         {
841                             Debug.Log("Most likely the game became empty during the switch to GameServer.");
842                         }
843                     }
844                     SendMonoMessage(PhotonNetworkingMessage.OnPhotonJoinRoomFailed, operationResponse.ReturnCode, operationResponse.DebugMessage);
845                     break;
846                 case OperationCode.JoinRandomGame:
847                     if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
848                     {
849                         Debug.Log("Join failed on GameServer. Changing back to MasterServer. Msg: " + operationResponse.DebugMessage);
850                         if (operationResponse.ReturnCode == ErrorCode.GameDoesNotExist)
851                         {
852                             Debug.Log("Most likely the game became empty during the switch to GameServer.");
853                         }
854                     }
855                     SendMonoMessage(PhotonNetworkingMessage.OnPhotonRandomJoinFailed, operationResponse.ReturnCode, operationResponse.DebugMessage);
856                     break;
857             }
858
859             this.DisconnectToReconnect();
860             return;
861         }
862
863         this.State = global::PeerState.Joined;
864         this.mRoomToGetInto.isLocalClientInside = true;
865
866         Hashtable actorProperties = (Hashtable)operationResponse[ParameterCode.PlayerProperties];
867         Hashtable gameProperties = (Hashtable)operationResponse[ParameterCode.GameProperties];
868         this.ReadoutProperties(gameProperties, actorProperties, 0);
869
870         // the local player's actor-properties are not returned in join-result. add this player to the list
871         int localActorNr = (int)operationResponse[ParameterCode.ActorNr];
872
873         this.ChangeLocalID(localActorNr);
874         this.CheckMasterClient(-1);
875
876         if (this.mPlayernameHasToBeUpdated)
877         {
878             this.SendPlayerName();
879         }
880
881         switch (operationResponse.OperationCode)
882         {
883             case OperationCode.CreateGame:
884                 SendMonoMessage(PhotonNetworkingMessage.OnCreatedRoom);
885                 break;
886             case OperationCode.JoinGame:
887             case OperationCode.JoinRandomGame:
888                 // the mono message for this is sent at another place
889                 break;
890         }
891     }
File name: NetworkingPeer.cs Copy
905     public void ChangeLocalID(int newID)
906     {
907         if (this.mLocalActor == null)
908         {
909             Debug.LogWarning(
910                 string.Format(
911                     "Local actor is null or not in mActors! mLocalActor: {0} mActors==null: {1} newID: {2}",
912                     this.mLocalActor,
913                     this.mActors == null,
914                     newID));
915         }
916
917         if (this.mActors.ContainsKey(this.mLocalActor.ID))
918         {
919             this.mActors.Remove(this.mLocalActor.ID);
920         }
921
922         this.mLocalActor.InternalChangeLocalID(newID);
923         this.mActors[this.mLocalActor.ID] = this.mLocalActor;
924         this.RebuildPlayerListCopies();
925     }
File name: PhotonNetwork.cs Copy
402     {
403         get
404         {
405             return isOfflineMode;
406         }
407
408         set
409         {
410             if (value == isOfflineMode)
411             {
412                 return;
413             }
414
415             if (value && connected)
416             {
417                 Debug.LogError("Can't start OFFLINE mode while connected!");
418             }
419             else
420             {
421                 if (networkingPeer.PeerState != PeerStateValue.Disconnected)
422                 {
423                     networkingPeer.Disconnect(); // Cleanup (also calls OnLeftRoom to reset stuff)
424                 }
425                 isOfflineMode = value;
426                 if (isOfflineMode)
427                 {
428                     NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnConnectedToMaster);
429                     networkingPeer.ChangeLocalID(1);
430                     networkingPeer.mMasterClient = player;
431                 }
432                 else
433                 {
434                     offlineModeRoom = null;
435                     networkingPeer.ChangeLocalID(-1);
436                     networkingPeer.mMasterClient = null;
437                 }
438             }
439         }
440     }
File name: PhotonPlayer.cs Copy
138     internal void InternalChangeLocalID(int newID)
139     {
140         if (!this.isLocal)
141         {
142             Debug.LogError("ERROR You should never change PhotonPlayer IDs!");
143             return;
144         }
145
146         this.actorID = newID;
147     }

ChangeLocalID 88 lượt xem

Gõ tìm kiếm nhanh...