/// <summary> /// Processes a single command /// </summary> /// <returns> /// The command. /// </returns> /// <param name='cmd'> /// If set to <c>true</c> cmd. /// </param> public bool ProcessCommand(DFNetwork.Networking.PacketHandling.Packet cmd) { // Check if the packet is "LoadScene" if (cmd.CommandName == "LoadScene") { // Pop the event if (OnMasterInstructLoad != null) { OnMasterInstructLoad(); } // Set up the player registry foreach (short s in NetLayer.GetPlayerList()) { PlayersLoaded.Add(s, false); } // get the scene to load //UnityEngine.SceneManagement.SceneManager.LoadScene() Application.LoadLevelAdditive((string)cmd.Params[0]); // Now send a packet saying that it has been loaded NetLayer.SendPacket(NetLayer.GeneratePacket("SceneLoaded", (string)cmd.Params[0])); } else { // Means we got a packet for "scene loaded" PlayersLoaded[cmd.Owner] = true; } return(true); }
/// <summary> /// Raises the room joined event. /// </summary> private void OnRoomJoined() { // When a user joins the room, clear current states PlayersReady.Clear(); // Get a list of current players, add them to the state recorder, mark them as "not ready" // so, get the player list foreach (short p in NetLayer.GetPlayerList()) { // Make sure we have a current list of all the players if (!PlayersReady.ContainsKey(p)) { Debug.Log("Player Connected: " + p); PlayersReady.Add(p, false); } } }