/// <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> /// Processes the incomming packet. /// </summary> /// <param name='data'> /// Data. /// </param> public void ProcessIncommingPacket(byte[] data) { // Get the packet PacketHandling.Packet packet = PacketRegistry.DeserializePacket(data); // Let the engine know a new one arrived if (OnPacketArrived != null) { OnPacketArrived(packet); } }
/// <summary> /// Processes the outbound packet. /// </summary> /// <param name='packet'> /// Packet. /// </param> public byte[] ProcessOutboundPacket(PacketHandling.Packet packet) { // Let the engine know a packet is being sent if (OnPacketSent != null) { OnPacketSent(packet); } // Get the packet data return(PacketRegistry.SerializePacket(packet)); }
/// <summary> /// Processes a 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) { // Set the owners ready state if (!PlayersReady.ContainsKey(cmd.Owner)) { // Add the player to the list PlayersReady.Add(cmd.Owner, (bool)cmd.Params[0]); } else { // Player exists, set new state PlayersReady[cmd.Owner] = (bool)cmd.Params[0]; } return(AllPlayersReady); }
/// <summary> /// Processes one command, used for instant processing /// </summary> /// <returns>The command.</returns> /// <param name="cmd">Cmd.</param> public bool ProcessCommand(DFNetwork.Networking.PacketHandling.Packet cmd) { string prefab = SimLayer.GetResourcePrefab((short)cmd.Params[0]); // Create the object based on the ID. This should require a listing somewhere GameObject go = LoadResource(((short)cmd.Params[0]), ((Vector3)cmd.Params[1]), ((Quaternion)cmd.Params[2])); go.GetComponent <PhotonView>().viewID = (int)cmd.Params[3]; // Set parent if (_gc.WorldContainerObject) { go.transform.SetParent(_gc.WorldContainerObject.transform); go.transform.localScale = Vector3.one; } return(false); }
public bool ProcessCommand(DFNetwork.Networking.PacketHandling.Packet cmd) { return(false); }
public abstract void SendPacket(PacketHandling.Packet packet);
/// <summary> /// Processes the outbound packet. /// </summary> /// <returns> /// The outbound packet. /// </returns> /// <param name='packet'> /// Packet. /// </param> public override void SendPacket(DFNetwork.Networking.PacketHandling.Packet packet) { // Send the packet PhotonNetwork.RPC(PhotonView.Get(this), "RecievePacket", PhotonTargets.AllBuffered, false, base.ProcessOutboundPacket(packet)); }