private void Update() { if (!isstarted) { return; } if ((LocalFrameNum - PassedFrameNum) < 5) { if (!RToggle.isOn) { RToggle.isOn = true; } LocalCurrentLength += Time.unscaledDeltaTime; } else { RToggle.isOn = false; LocalCurrentLength += Time.unscaledDeltaTime / 4; } while (LocalCurrentLength >= LocalFrameLength) { Data2S Fd2s = new Data2S(); Fd2s.frameNum = LocalFrameNum; Fd2s.clientNum = Sender.clientNum; Fd2s.clickDatas = L2S; Bond.IO.Safe.OutputBuffer ob = new Bond.IO.Safe.OutputBuffer(64); Bond.Protocols.FastBinaryWriter <Bond.IO.Safe.OutputBuffer> bof = new Bond.Protocols.FastBinaryWriter <Bond.IO.Safe.OutputBuffer>(ob); Serialize.To(bof, Fd2s); ///NetworkTransport.Send(Sender.HSID, Sender.CNID, channelID, ob.Data.Array, ob.Data.Array.Length, out error); byte[] sendBytes = new byte[ob.Data.Array.Length + 1]; sendBytes[0] = (byte)0; ob.Data.Array.CopyTo(sendBytes, 1); for (int i = 0; i < Sender.TOmb.Length; i++) { if (i != Sender.clientNum) { SteamNetworking.SendP2PPacket(Sender.TOmb[i], sendBytes, (uint)sendBytes.Length, EP2PSend.k_EP2PSendReliable); } } int a = LocalFrameNum - PassedFrameNum - 1; theLL.addat(a, Sender.clientNum, L2S); //Debug.Log("吃!"); if (Sender.isTesting) { theLL.addat(a, 1, L2S); } if (Time.timeScale < 0.6 && theLL.Numready(3)) { //isstarted = false; Time.timeScale = 1; Debug.Log("TimeScale set to 1 by Update"); } // L2S.Clear(); //buffer2s = new byte[1024]; LocalCurrentLength -= LocalFrameLength; //Debug.Log("Wey: " + LocalFrameNum); LocalFrameNum++; } }
Data2S bondbfd(byte[] bRC) { Bond.IO.Safe.InputBuffer ib = new Bond.IO.Safe.InputBuffer(bRC); Bond.Protocols.FastBinaryReader <Bond.IO.Safe.InputBuffer> fbr = new Bond.Protocols.FastBinaryReader <Bond.IO.Safe.InputBuffer>(ib); Data2S datarc = Deserialize <Data2S> .From(fbr); return(datarc); }
public void Eat(byte[] bRC) { Data2S datarc = bondbfd(bRC);//ttt ReceivedFrameNum = datarc.frameNum; int a = ReceivedFrameNum - PassedFrameNum - 1; theLL.addat(a, datarc.clientNum, datarc.clickDatas); if (Time.timeScale < 0.6 && theLL.Numready(1)) { //isstarted = false; Time.timeScale = 1; Debug.Log("TimeScale set to 1 by Eat"); } //Debug.Log("Ate"); }