//public bool isPreparing = false; public void PrepareLocalModel() { //if (isPreparing) // return; //isPreparing = true; RoomUI.Close(); ClearModels(); //GameRunUI.Show(); //GameLoadingUI.Show(); SendLoadProgress(20); UpdateRoomActor(); SendLoadProgress(50); BoxManager.instance.Init(); SendLoadProgress(100); //isPreparing = false; }
public void Update() { if (serverEventTCP.Count > 0) { MessageXieYi xieyi = serverEventTCP.Dequeue(); if (xieyi == null) { Debug.LogError("有事件操作的协议为空?"); return; } if ((MessageConvention)xieyi.XieYiFirstFlag == MessageConvention.login) { ErrorType error = ClassGroup.CheckIsError(xieyi); if (error != ErrorType.none) { ErrorShow(error); } else { SocketManager.instance.GetBeatTime(); } } if ((MessageConvention)xieyi.XieYiFirstFlag == MessageConvention.getHeartBeatTime) { ErrorType error = ClassGroup.CheckIsError(xieyi); if (error != ErrorType.none) { Debug.LogError(error); } else { SocketManager.instance.OpenHeartbeat(); // UILogin.Close(); HomeUI.Show(); // Debug.Log("自身检查是否需要重连。"); SocketManager.instance.SendSave((byte)MessageConvention.reConnectCheck, new byte[] { }, false); } } if ((MessageConvention)xieyi.XieYiFirstFlag == MessageConvention.reConnectCheck) { ErrorType error = ClassGroup.CheckIsError(xieyi); if (error != ErrorType.none) { Debug.LogError(error); } else { ReconnctInfo rcInfo = SerializeHelper.Deserialize <ReconnctInfo>(xieyi.MessageContent); if (rcInfo.isReconnect) { CurrentPlayType = FramePlayType.断线重连; ReConnectUI.Show(); } else { CurrentPlayType = FramePlayType.游戏未开始; } } } if ((MessageConvention)xieyi.XieYiFirstFlag == MessageConvention.quitRoom)//自己退出房间 { QuitInfo qInfo = SerializeHelper.Deserialize <QuitInfo>(xieyi.MessageContent); if (qInfo.isQuit) { UpdateMemberHide(); RoomUI.Close(); HomeUI.Show(); if (qInfo.userIndex != DataController.instance.MyLocateIndex) { UIManager.instance.ShowAlertTip("您被踢出房间。"); } } else { if (qInfo.userIndex == qInfo.quitUnique) { UIManager.instance.ShowAlertTip("退出房间失败。"); } } } if ((MessageConvention)xieyi.XieYiFirstFlag == MessageConvention.updateActorState) { ErrorType error = ClassGroup.CheckIsError(xieyi); if (error != ErrorType.none) { Debug.LogError(error); } else { CheckState(xieyi); } } if ((MessageConvention)xieyi.XieYiFirstFlag == MessageConvention.updateModelInfo) { GameModelData modelDate = SerializeHelper.Deserialize <GameModelData>(xieyi.MessageContent); SetPrepareData(modelDate); } if ((MessageConvention)xieyi.XieYiFirstFlag == MessageConvention.getPreGameData) { ErrorType error = ClassGroup.CheckIsError(xieyi); if (error != ErrorType.none) { Debug.LogError(error); } else { Debug.Log("验证本客户端收到游戏前准备数据。客户端响应已收到:" + xieyi.MessageContentLength); SendState(RoomActorState.WaitForStart); } } if ((MessageConvention)xieyi.XieYiFirstFlag == MessageConvention.startGaming) { ErrorType error = ClassGroup.CheckIsError(xieyi); if (error != ErrorType.none) { Debug.LogError(error); } else { StartGaming(); } } if ((MessageConvention)xieyi.XieYiFirstFlag == MessageConvention.endGaming) { ErrorType error = ClassGroup.CheckIsError(xieyi); if (error != ErrorType.none) { Debug.LogError(error); } else { EndGaming(xieyi); } } if ((MessageConvention)xieyi.XieYiFirstFlag == MessageConvention.frameData) { Debug.LogError("TCP收到整串操作数据"); UDPManager.instance.DealFrameData(xieyi); if (CurrentPlayType == FramePlayType.断线重连) { CurrentPlayType = FramePlayType.游戏中; } if (CurrentPlayType == FramePlayType.主动请求数据) { CurrentPlayType = FramePlayType.游戏中; } } } //UDP if (serverEventUDP.Count > 0) { MessageXieYi xieyi = serverEventUDP.Dequeue(); if (xieyi == null) { Debug.LogError("有UDP事件操作的协议为空?"); return; } if (xieyi.XieYiFirstFlag == (byte)MessageConvention.setUDP) { UDPManager.instance.IsConnect = true; Debug.LogError("用tcp 设置房间 udp"); //SocketManager.instance.SendSave((byte)MessageConvention.setUDP, xieyi.MessageContent, false); } } }