public static void Welcome(Packet packet) { string msg = packet.ReadString(); int myId = packet.ReadInt(); Debug.Log($"Message from server: {msg}"); Client.instance.myId = myId; ClientSend.WelcomeReceived(); // Now that we have the client's id, connect UDP Client.instance.udp.Connect(((IPEndPoint)Client.instance.tcp.socket.Client.LocalEndPoint).Port); }
/// <summary>Sends player input to the server.</summary> private void SendInputToServer() { bool[] _inputs = new bool[] { Input.GetKey(KeyCode.W), Input.GetKey(KeyCode.S), Input.GetKey(KeyCode.A), Input.GetKey(KeyCode.D), Input.GetKey(KeyCode.Space) }; ClientSend.PlayerMovement(_inputs); }
/// <summary>Messages the server entity (basically calls a function by name)</summary> /// <param name="msg">The name of the function to call</param> /// <param name="args">Arguments to pass on to the function</param> public virtual void Message(string msg, object args = null) { ClientSend.MessageEntity(this, msg, args); }