SHARE
TWEET

Untitled

a guest Apr 21st, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5.  
  6. using Photon.Pun;
  7. using Photon.Realtime;
  8.  
  9. public class ManagerGame : MonoBehaviourPunCallbacks
  10. {
  11.     #region Photon Callbacks
  12.  
  13.     /// <summary>
  14.     /// Called when the local player left the room. we need to load the scene
  15.     /// </summary>
  16.     ///
  17.     public override void OnPlayerEnteredRoom(Player other)
  18.     {
  19.         Debug.LogFormat("OnPlayerEnteredRoom()");
  20.  
  21.         if(PhotonNetwork.IsMasterClient)
  22.         {
  23.             Debug.LogFormat("OnPlaerEnteredRoom IsMasterClient()");
  24.  
  25.             LoadTest();
  26.         }
  27.     }
  28.  
  29.     public override void OnPlayerLeftRoom(Player other)
  30.     {
  31.         Debug.LogFormat("OnPlayerLeftRoom()");
  32.  
  33.         if(PhotonNetwork.IsMasterClient)
  34.         {
  35.             Debug.LogFormat("OnPlayerLeftRoom IsMasterClient");
  36.  
  37.             LoadTest();
  38.         }
  39.     }
  40.  
  41.     public override void OnLeftRoom()
  42.     {
  43.         //SceneManager.LoadScene(0);
  44.         //This one needs to be send back to the zen mode situations^
  45.         Debug.Log("IM THE GREATEST");
  46.     }
  47.     #endregion
  48.  
  49.     #region Public Methods
  50.  
  51.     public void ExampleFunction()
  52.     {
  53.         PhotonNetwork.LeaveRoom();
  54.     }
  55.  
  56.     #endregion
  57.  
  58.     #region Private Methods
  59.     void LoadTest()
  60.     {
  61.         if(!PhotonNetwork.IsMasterClient)
  62.         {
  63.             Debug.Log("PhotonNetwork : trying to load a level/test but we are not MasterClient");
  64.         }
  65.         PhotonNetwork.LoadLevel("herewefuckingo");
  66.         //Down here should be the possibilities for the Masterclient to load the different test necessary.
  67.         //we will be using PhotonNetwork.LoadLevel and not Unity Directly because we want all the clients to
  68.         //load it on all connected clients, especially since we have enabled PhotonNetwork.AutomaticallySyncScene
  69.     }
  70.     #endregion
  71.  
  72. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top