Changing
How do I use Changing
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
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
1394 /// ParameterCode.FindFriendsResponseRoomIdList = string[] of room names (empty string if not in a room)
1398 public override bool OpFindFriends(string[] friendsToFind)
1399 {
1400 if (this.isFetchingFriends)
1401 {
1402 return false; // fetching friends currently, so don't do it again (avoid changing the list while fetching friends)
1403 }
1404
1405 this.friendListRequested = friendsToFind;
1406 this.isFetchingFriends = true;
1407
1408 return base.OpFindFriends(friendsToFind);
1409 }
File name: OptionsScript.cs
Copy
168 void OnGUI() {
169 if (this.gameScript.gameView == "options") {
170 this.gameScript.mainCamera.transform.eulerAngles = new Vector3 (120, 23, 0);
171
172 GUI.skin = this.gameScript.currentGUISkin;
173
174 //check to see if any options changed
175 if (previous_use_0 != use_0) {
176 this.setOption ("use_0", this.use_0);
177 GameControllerScript.performRestart = true;
178 }
179
180 if (this.previous_board_type != this.board_type) {
181 this.setOption ("board_type", this.board_type);
182 GameControllerScript.performRestart = true;
183 }
184
185 if (previous_play_sounds != play_sounds) {
186 this.setOption ("play_sounds", this.play_sounds);
187 }
188
189 if (this.previous_timer_duration != this.timer_duration) {
190 this.setOption ("timer_duration", this.timer_duration);
191 GameControllerScript.performRestart = true;
192 }
193
194
195
196 //set the label
197 GUILayout.Label ("Options", "BigLabel");
198
199 scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(Screen.width), GUILayout.Height(Mathf.Ceil(Screen.height * .80f)));
200
201
202
203 //Sounds
204 GUILayout.BeginHorizontal ();
205 if (GUILayout.Toggle (this.play_sounds, "Play Sounds", currentGUISkin.toggle)) {
206 this.play_sounds = true;
207 }
208 else {
209 this.play_sounds = false;
210 }
211 GUILayout.Label ( "Play Sounds", "ToggleLabel");
212 GUILayout.EndHorizontal();
213
214
215 GUILayout.Label ("WARNING! Changing any of the following options will cause the game to reset!", "ToggleLabelWarning");
216
217 GUILayout.Label ("Game Board Type", "Subheader");
218 //Game Board Type
219 GUILayout.BeginHorizontal ();
220 if (GUILayout.Toggle (this.board_type == "Solid Cube", "Solid Cube", currentGUISkin.toggle)) {
221 this.board_type = "Solid Cube";
222 }
223 GUILayout.Label ( "Solid Cube (27 Blocks)", "ToggleLabel");
224 GUILayout.EndHorizontal();
225
226
227 GUILayout.BeginHorizontal ();
228 if (GUILayout.Toggle (this.board_type == "Hollow Cube", "Hollow Cube", currentGUISkin.toggle)) {
229 this.board_type = "Hollow Cube";
230 }
231 GUILayout.Label ( "Hollow Cube (26 Blocks)", "ToggleLabel");
232 GUILayout.EndHorizontal();
233
234
235 GUILayout.BeginHorizontal ();
236 if (GUILayout.Toggle (this.board_type == "Four Walls", "Four Walls", currentGUISkin.toggle)) {
237 this.board_type = "Four Walls";
238 }
239 GUILayout.Label ( "Four Walls (24 Blocks)", "ToggleLabel");
240 GUILayout.EndHorizontal();
241
242
243 GUILayout.BeginHorizontal ();
244 if (GUILayout.Toggle (this.board_type == "Box Outline", "Box Outline", currentGUISkin.toggle)) {
245 this.board_type = "Box Outline";
246 }
247 GUILayout.Label ( "Cube Outline (20 Blocks)", "ToggleLabel");
248 GUILayout.EndHorizontal();
249
250
251
252 GUILayout.BeginHorizontal ();
253 if (GUILayout.Toggle (this.board_type == "No Corners", "No Corners", currentGUISkin.toggle)) {
254 this.board_type = "No Corners";
255 }
256 GUILayout.Label ( "No Corners (19 Blocks)", "ToggleLabel");
257 GUILayout.EndHorizontal();
258
259
260 GUILayout.BeginHorizontal ();
261 if (GUILayout.Toggle (this.board_type == "No Corners/Center", "No Corners/Center", currentGUISkin.toggle)) {
262 this.board_type = "No Corners/Center";
263 }
264 GUILayout.Label ( "No Corners/Center (18 Blocks)", "ToggleLabel");
265 GUILayout.EndHorizontal();
266
267
268 //TIMER OPTIONS ####################################################
269 GUILayout.Label ("Timer", "Subheader");
270
271 foreach (int i in this.GetTimerDurationTimes())
272 {
273 GUILayout.BeginHorizontal ();
274 if (GUILayout.Toggle (this.timer_duration == i, "", currentGUISkin.toggle)) {
275 this.timer_duration = i;
276 }
277 GUILayout.Label (TimerDurationToString (i), "ToggleLabel");
278 GUILayout.EndHorizontal();
279 }
280
281
282
283
284 //Other OPTIONS ####################################################
285 GUILayout.Label ("Block Numbers", "Subheader");
286
287 //Use Zeros
288 GUILayout.BeginHorizontal ();
289 if (GUILayout.Toggle (use_0, "Use 0s (Note: Changing this will reset the current game!)", currentGUISkin.toggle)) {
290 use_0 = true;
291 }
292 else {
293 use_0 = false;
294 }
295 GUILayout.Label ( "Use Zeros", "ToggleLabel");
296 GUILayout.EndHorizontal();
297
298
299
300 foreach (Touch touch in Input.touches) {
301 if (touch.phase == TouchPhase.Moved)
302 {
303 // dragging
304 scrollPosition.y += touch.deltaPosition.y;
305 }
306 }
307
308 GUILayout.EndScrollView();
309
310 if (GUILayout.Button ("Return to Menu", "Button")) {
311 gameScript.gameView = "menu";
312 }
313 }
314 }
Changing 98 lượt xem
Gõ tìm kiếm nhanh...