SendPlayerName
How do I use Send Player Name
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
73 | this.SendPlayerName(); | 1 |
800 | private void SendPlayerName() | 2 |
878 | this.SendPlayerName(); | 3 |
File name: NetworkingPeer.cs
Copy
51 {
52 get
53 {
54 return this.playername;
55 }
56
57 set
58 {
59 if (string.IsNullOrEmpty(value) || value.Equals(this.playername))
60 {
61 return;
62 }
63
64 if (this.mLocalActor != null)
65 {
66 this.mLocalActor.name = value;
67 }
68
69 this.playername = value;
70 if (this.mCurrentGame != null)
71 {
72 // Only when in a room
73 this.SendPlayerName();
74 }
75 }
76 }
File name: NetworkingPeer.cs
Copy
800 private void SendPlayerName()
801 {
802 if (this.State == global::PeerState.Joining)
803 {
804 // this means, the join on the gameServer is sent (with an outdated name). send the new when in game
805 this.mPlayernameHasToBeUpdated = true;
806 return;
807 }
808
809 if (this.mLocalActor != null)
810 {
811 this.mLocalActor.name = this.PlayerName;
812 Hashtable properties = new Hashtable();
813 properties[ActorProperties.PlayerName] = this.PlayerName;
814 if (this.mLocalActor.ID > 0)
815 {
816 this.OpSetPropertiesOfActor(this.mLocalActor.ID, properties, true, (byte)0);
817 this.mPlayernameHasToBeUpdated = false;
818 }
819 }
820 }
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 }
SendPlayerName 122 lượt xem
Gõ tìm kiếm nhanh...