// Update is called once per frame void Update() { if (st.Connected) { if (st.receiveMessage.Count >= 2) { byte[] message = st.GetByte(2); string msg = parser.Parse(message); LogWriter.Log("Client: " + msg); Debug.Log("Client: " + msg); } st.Receive(); } }
private void Update() { if (st.receiveMessage != null) { Debug.Log(st.receiveMessage); foreach (char c in st.receiveMessage) { string s = System.Convert.ToString(c); if (inputCandidates.Contains(s)) { inputBuffer.Add(s); Debug.Log("Client:" + s); } } st.receiveMessage = null; } if (isSend == true) { StartCoroutine(delaySend()); //延遲發送訊息 } if (inputBuffer.Count() != 0) { string input = inputBuffer [0]; inputBuffer.RemoveAt(0); Debug.Log("Input:" + input); if (input == "d") { AA.SendMessage("OnInput", 4.0f); } if (input == "a") { AA.SendMessage("OnInput", 3.0f); } if (input == "s") { AA.SendMessage("OnInput", 2.0f); } if (input == "w") { Debug.Log("w"); AA.SendMessage("OnInput", 1.0f); } } st.Receive(); }
private void Update() { if (st.receiveMessage != null) { foreach (char c in st.receiveMessage) { string s = System.Convert.ToString(c); if (inputCandidates.Contains(s)) { inputBuffer.Add(s); Debug.Log("Client:" + s); } } st.receiveMessage = null; } if (isSend == true) { StartCoroutine(delaySend()); //延遲發送訊息 } if (inputBuffer.Count() != 0) { string input = inputBuffer [0]; inputBuffer.RemoveAt(0); Debug.Log("Input:" + input); if (input == "d") { transform.Translate(new Vector3(speed * Time.deltaTime, 0, 0)); } if (input == "a") { transform.Translate(new Vector3(-speed * Time.deltaTime, 0, 0)); } if (input == "s") { transform.Translate(new Vector3(0, -speed * Time.deltaTime, 0)); } if (input == "w") { transform.Translate(new Vector3(0, speed * Time.deltaTime, 0)); } } st.Receive(); }
private void Update() { if (st.receiveMessage != null) { // Ting PlayerParam.Client = JsonUtility.FromJson <GameData>(st.receiveMessage); Debug.Log("get: " + PlayerParam.Client.Player_Pos_X); Debug.Log("get: " + PlayerParam.Client.Player_Pos_Y); // rr = JsonUtility.FromJson<senddata>(st.receiveMessage); // Debug.Log("get: " + rr.a); // Debug.Log("get: " + rr.b); Debug.Log("Server: success"); PlayerParam.Status_Update = true; // Debug.Log("Client:" + st.receiveMessage); st.receiveMessage = null; } if (isSend == true) { StartCoroutine(delaySend());//延遲發送訊息 } st.Receive(); }