private static void MessageHandle(Coder coder, byte[] Message) { switch (coder) { case Coder.STAT: { NetWorkScript.client.ConnectToIp(NetWorkScript.server.GetClientAddress(), NetWorkScript.Clientport); Debug.Log("Connected!"); NetWorkScript.isConnected = true; break; } case Coder.MOVE: { player2.inputAxis = new Vector2(BitConverter.ToSingle(Message, 0), BitConverter.ToSingle(Message, 4)); player2.Position = new Vector2(BitConverter.ToSingle(Message, 8), BitConverter.ToSingle(Message, 12)); player2.moveSpeed = BitConverter.ToSingle(Message, 16); break; } case Coder.PING: { ClQueue.ReadyForSend(EnCoder.RpinMessage()); break; } case Coder.RPIN: { ShowPingInfo.CalculatePing(); break; } } }
// void OnGUI () { // if(isShow) GUI.TextArea(PingRect,((int)ping).ToString(),0,GUIStyle.none); // } private void SendPingMessage(object state) { if (NetWorkScript.isConnected && isShow) { Timetemp = CloFunc.GetTimeNow(); ClQueue.ReadyForSend(EnCoder.PingMessage()); } }
public void FixedUpdate() { inputAxis = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); //netWorkTest.client.Transmission(EnCoder.MoveMessage(inputAxis)); ClQueue.ReadyForSend(EnCoder.MoveMessage(inputAxis.normalized, this.transform.position, moveSpeed)); }