/// <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);
    }
Exemplo n.º 2
0
 /// <summary>
 /// Sends the ready packet
 /// </summary>
 /// <param name='ready'>
 /// Ready.
 /// </param>
 public void SendReady(bool ready)
 {
     // Generate and send the packet based on "ready" or not
     NetLayer.SendPacket(NetLayer.GeneratePacket("Ready", ready));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Sends the spawn object packet
 /// </summary>
 /// <param name="id">Identifier.</param>
 /// <param name="pos">Position.</param>
 /// <param name="rot">Rot.</param>
 public void SendSpawnObject(string prefabName, Vector3 pos, Quaternion rot, int viewID)
 {
     Debug.Log(NetLayer);
     Debug.Log(SimLayer.GetResourceID(prefabName));
     NetLayer.SendPacket(NetLayer.GeneratePacket("SpawnObjects", SimLayer.GetResourceID(prefabName), pos, rot, viewID));
 }