예제 #1
0
        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);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
 /// <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);
 }