private void LockUpdate(bool inLoop = false) { if (this.online && this.frame + 1 == WAITTING_INTERVAL && this.playDataList.Count == 0) { return; } if (this.online) { this.frame++; if (this.frame == WAITTING_INTERVAL) { var data = this.playDataList[0]; this.playDataList.RemoveAt(0); if (Judge.IsRunning && data.addrs != null) { for (int i = 0; i < data.addrs.Length; i++) { Judge.Input(data.addrs[i], data.inputs[i]); } } this.playFrame++; this.frame = 0; if (!inLoop || (inLoop && this.sendInLoop)) { var input = new Datas.Input() { data = new InputData() { movingValue = Networkmgr.MovingValue, willElaste = Networkmgr.WillElaste }, frame = this.playFrame }; this.sendInLoop = false; Networkmgr.WillElaste = false; this.client.Send(EventCode.Input, input); } if (this.playFrame > LEAST_COMPARE_FRAME) { var comparison = new Datas.Comparison() { playFrame = this.playFrame, content = Judge.Comparison }; this.client.Send(EventCode.Comparison, comparison); } } } Networkmgr.UpdateEvent(); Networkmgr.LateUpdateEvent(); }
protected void Awake() { INSTANCE = this; this.playDataList = new List <PlayData>(); this.client = new Client(this.serverAddress, this.serverPort); this.client.RegisterEvent(EventCode.Connect, this.OnConnect); this.client.RegisterEvent(EventCode.Disconnect, this.OnDisconnect); this.client.RegisterEvent(EventCode.Start, this.OnStart); this.client.RegisterEvent(EventCode.Input, this.OnReceivePlayData); DOTween.defaultUpdateType = UpdateType.Manual; DOTween.Init(); Networkmgr.LateUpdateEvent += () => DOTween.ManualUpdate(STDDT, STDDT); }
private void OnConnect(byte id, string data) { var obj = JsonUtility.FromJson <Datas.Connect>(data); if (obj.version != this.version || obj.isFull) { byte exitCode = obj.isFull ? ExitCode.Full : ExitCode.Version; Networkmgr.Disconnect(exitCode); } else { this.client.Send(EventCode.Handshake, new Datas.Handshake() { deviceModel = SystemInfo.deviceModel }); } this.addr = obj.addr; print("Connected"); }