protected override void OnConnectServer(MobaPeerType type)
 {
     base.OnConnectServer(type);
     if (type == MobaPeerType.C2PvpServer)
     {
         PvpStartGameInfo loginInfo = Singleton <PvpManager> .Instance.LoginInfo;
         if (Singleton <PvpManager> .Instance.IsObserver)
         {
             PvpStateBase.LogState("send C2P_LoginAsViewer");
             SendMsgManager.Instance.SendPvpLoginMsgBase <C2PLoginAsViewer>(PvpCode.C2P_LoginAsViewer, new C2PLoginAsViewer
             {
                 newUid = int.Parse(ModelManager.Instance.Get_userData_X().UserId),
                 roomId = loginInfo.roomId
             }, loginInfo.roomId);
         }
         else
         {
             PvpStateBase.LogState("send C2P_LoginFight");
             SendMsgManager.Instance.SendPvpLoginMsgBase <C2PLoginFight>(PvpCode.C2P_LoginFight, new C2PLoginFight
             {
                 roomId = loginInfo.roomId,
                 newUid = loginInfo.newUid,
                 newkey = loginInfo.newKey
             }, loginInfo.roomId);
         }
     }
 }
        private void L2C_StartGame(MobaMessage msg)
        {
            OperationResponse operationResponse = msg.Param as OperationResponse;

            byte[]           array            = (byte[])operationResponse.Parameters[0];
            byte[]           buffer           = (byte[])operationResponse.Parameters[1];
            PvpStartGameInfo pvpStartGameInfo = SerializeHelper.Deserialize <PvpStartGameInfo>(array);
            BattleRoomInfo   battleRoomInfo   = SerializeHelper.Deserialize <BattleRoomInfo>(buffer);

            PvpStateBase.LogState("L2C_StartGame:" + (StringUtils.DumpObject(array) ?? "null"));
            if (pvpStartGameInfo != null && battleRoomInfo != null)
            {
                this._isGsConnected = false;
                NetWorkHelper.Instance.DisconnectFromGateServer(false);
                NetWorkHelper.Instance.DisconnectLobbyServer();
                Singleton <PvpManager> .Instance.LoginInfo            = pvpStartGameInfo;
                Singleton <PvpManager> .Instance.ServerBattleRoomInfo = battleRoomInfo;
                NetWorkHelper.Instance.ConnectToPvpServer();
                if (!string.IsNullOrEmpty(battleRoomInfo.roomVoiceID))
                {
                }
            }
            else
            {
                ClientLogger.Error("L2C_StartGame: PvpStartGameInfo is null");
                PvpStateManager.Instance.ChangeState(new PvpStateHome());
            }
        }
        private void P2C_BackLoadingInfo(MobaMessage msg)
        {
            InLoadingRuntimeInfo probufMsg = msg.GetProbufMsg <InLoadingRuntimeInfo>();

            PvpStateBase.LogState("receive P2C_BackLoadingInfo  " + StringUtils.DumpObject(probufMsg));
            Singleton <PvpManager> .Instance.RoomInfo.UpdateAllLoadProgress(probufMsg.loadProcessDic);
        }
示例#4
0
        protected override void P2C_LoginAsViewer(MobaMessage msg)
        {
            RetaMsg probufMsg = msg.GetProbufMsg <RetaMsg>();
            byte    retaCode  = probufMsg.retaCode;

            PvpStateBase.LogState("===>receive: P2C_LoginAsViewer:" + retaCode);
            if (retaCode == 0)
            {
                if (this._prevState == PvpStateCode.PveLoad)
                {
                    Singleton <PvpManager> .Instance.LoadPvpSceneBegin();

                    base.RecoverFinish(new PvpStateLoad());
                }
                else
                {
                    base.QueryPsPvpState();
                    base.RecoverFinish(new PvpStateStart(PvpStateCode.PvpStart));
                }
            }
            else
            {
                ClientLogger.Error("P2C_LoginAsViewer: failed for " + retaCode);
                Singleton <PvpManager> .Instance.AbandonGame(PvpErrorCode.UnknowError);
            }
        }
示例#5
0
        private void P2C_QueryInFightInfo(MobaMessage msg)
        {
            InBattleRuntimeInfo probufMsg = msg.GetProbufMsg <InBattleRuntimeInfo>();

            PvpStateBase.LogState("receive P2C_QueryInFightInfo " + StringUtils.DumpObject(probufMsg));
            this.SyncFightInfo(probufMsg);
        }
        private void P2C_QueryInFightInfo(MobaMessage msg)
        {
            InBattleRuntimeInfo probufMsg = msg.GetProbufMsg <InBattleRuntimeInfo>();

            PvpStateBase.LogState("receive P2C_QueryInFightInfo " + StringUtils.DumpObject(probufMsg));
            if (probufMsg == null)
            {
                PvpStateBase.LogState("no fight info");
            }
            else
            {
                GameManager.Instance.ReplayController.SaveReconnectSyncMsgForRecord(msg.Param);
                PvpProtocolTools.SyncFightInfo(probufMsg);
                if (probufMsg.roomState == 3)
                {
                    Singleton <PvpManager> .Instance.AbandonGame(PvpErrorCode.StateError);
                }
            }
            if (this.TargetState == PlayerState.InFight || probufMsg != null)
            {
                this.RecoverFinish(new PvpStateStart(PvpStateCode.PvpStart));
            }
            else
            {
                SendMsgManager.Instance.SendPvpMsg(PvpCode.C2P_LoadingOK, null);
                this.RecoverFinish(new PvpStateLoad());
            }
        }
示例#7
0
 private void TryStartObserving()
 {
     if (Singleton <PvpManager> .Instance.IsObserver)
     {
         PvpStateBase.LogState("observing is starting");
         PvpStateManager.Instance.ChangeState(new PvpStateStart(PvpStateCode.PvpStart));
     }
 }
        private void L2C_WaitForSkin(MobaMessage msg)
        {
            OperationResponse operationResponse = msg.Param as OperationResponse;
            int num = (int)operationResponse.Parameters[0];

            PvpStateBase.LogState("===>receive: L2C_WaitForSkin:" + num);
            this.GuardState(num);
        }
        private void L2C_RoomSelectHeroOK(MobaMessage msg)
        {
            OperationResponse operationResponse = msg.Param as OperationResponse;
            int  num  = (int)operationResponse.Parameters[0];
            bool flag = (bool)operationResponse.Parameters[1];

            PvpStateBase.LogState(string.Format("L2C_RoomSelectHeroOK user {0} ok={1}", num, flag));
            Singleton <PvpManager> .Instance.OnSelectHeroOk(num, flag);
        }
示例#10
0
        private void P2C_LoadingOK(MobaMessage msg)
        {
            InBattleRuntimeInfo probufMsg = msg.GetProbufMsg <InBattleRuntimeInfo>();

            PvpStateBase.LogState("receive P2C_LoadingOK " + StringUtils.DumpObject(probufMsg));
            Singleton <PvpManager> .Instance.HasRecvLoadingOk = true;
            Singleton <PvpManager> .Instance.GameStartTime    = new DateTime?(DateTime.Now);
            this.OnAfterLoadOk(probufMsg);
        }
        private void L2C_UserBack(MobaMessage msg)
        {
            OperationResponse operationResponse = msg.Param as OperationResponse;
            byte b = (byte)operationResponse.Parameters[0];

            byte[]      buffer      = operationResponse.Parameters[1] as byte[];
            PlayerState playerState = (PlayerState)b;

            PvpStateBase.LogState("receive L2C_UserBack " + playerState + " ");
            Singleton <PvpManager> .Instance.LoginInfo            = null;
            Singleton <PvpManager> .Instance.ServerBattleRoomInfo = null;
            this.TargetState = PlayerState.Free;
            switch (playerState)
            {
            case PlayerState.Free:
                this.RecoverFinish(new PvpStateHome());
                return;

            case PlayerState.CheckReady:
                ClientLogger.Error("Cannot be here anymore.");
                this.RecoverFinish(new PvpStateHome());
                return;

            case PlayerState.SelectHore:
            {
                CtrlManager.CloseWindow(WindowID.PvpWaitView);
                InSelectAllInfo inSelectAllInfo = SerializeHelper.Deserialize <InSelectAllInfo>(buffer);
                Singleton <PvpManager> .Instance.SetBattleInfoWithoutJoinType(inSelectAllInfo.roomInfo.battleId);

                Singleton <PvpManager> .Instance.SetRoomInfo(inSelectAllInfo.roomInfo, inSelectAllInfo.newUid, inSelectAllInfo.playerInfos, null);

                PvpMatchMgr.Instance.SelectHeroTime = new DateTime?(DateTime.Now - TimeSpan.FromTicks(inSelectAllInfo.useTime));
                this.RecoverViewsForSelectHero();
                this.RecoverFinish(new PvpStateSelectHero());
                return;
            }

            case PlayerState.Loading:
            {
                InBattleLobbyInfo inBattleLobbyInfo = SerializeHelper.Deserialize <InBattleLobbyInfo>(buffer);
                InBattleRoomInfo  inBattleRoomInfo  = SerializeHelper.Deserialize <InBattleRoomInfo>(inBattleLobbyInfo.InBattleRoomInfoBytes);
                this.RecoverFromLoadingState(inBattleRoomInfo.roomInfo, inBattleLobbyInfo.loginInfo, inBattleRoomInfo.playerInfos, false);
                this.TargetState = PlayerState.Loading;
                return;
            }

            case PlayerState.InFight:
            {
                InBattleLobbyInfo inBattleLobbyInfo2 = SerializeHelper.Deserialize <InBattleLobbyInfo>(buffer);
                InBattleRoomInfo  inBattleRoomInfo2  = SerializeHelper.Deserialize <InBattleRoomInfo>(inBattleLobbyInfo2.InBattleRoomInfoBytes);
                this.RecoverFromLoadingState(inBattleRoomInfo2.roomInfo, inBattleLobbyInfo2.loginInfo, inBattleRoomInfo2.playerInfos, true);
                this.TargetState = PlayerState.InFight;
                return;
            }
            }
            ClientLogger.Warn("L2C_UserBack: unknown state " + playerState);
        }
示例#12
0
        private void L2C_RoomSelectHero(MobaMessage msg)
        {
            OperationResponse operationResponse = msg.Param as OperationResponse;
            int num = (int)operationResponse.Parameters[0];

            byte[]   buffer   = operationResponse.Parameters[1] as byte[];
            HeroInfo heroInfo = SerializeHelper.Deserialize <HeroInfo>(buffer);

            PvpStateBase.LogState(string.Format("===>receive: L2C_RoomSelectHero user {0} select {1}", num, StringUtils.DumpObject(heroInfo)));
            Singleton <PvpManager> .Instance.OnSelectHero(num, heroInfo);
        }
        private void P2C_RefreshInFightInfo(MobaMessage msg)
        {
            PvpServer.LockScreen(false);
            InBattleRuntimeInfo probufMsg = msg.GetProbufMsg <InBattleRuntimeInfo>();

            PvpStateBase.LogState("receive P2C_RefreshInFightInfo  " + StringUtils.DumpObject(probufMsg));
            PvpProtocolTools.SyncFightInfo(probufMsg);
            if (probufMsg != null && probufMsg.roomState == 3)
            {
                Singleton <PvpManager> .Instance.AbandonGame(PvpErrorCode.StateError);
            }
            this.RecoverFinish(new PvpStateStart(PvpStateCode.PvpStart));
        }
示例#14
0
        private void L2C_SelectHeroSkin(MobaMessage msg)
        {
            OperationResponse operationResponse = msg.Param as OperationResponse;
            int    num  = (int)operationResponse.Parameters[0];
            string text = (string)operationResponse.Parameters[1];

            PvpStateBase.LogState(string.Concat(new object[]
            {
                "===>receive: C2L_SelectHeroSkin:",
                num,
                " ",
                text
            }));
            Singleton <PvpManager> .Instance.OnSelectHeroSkin(num, text);
        }
示例#15
0
        private void P2C_CaptionLobby(MobaMessage msg)
        {
            OperationResponse operationResponse = msg.Param as OperationResponse;
            string            text = (string)operationResponse.Parameters[1];

            PvpStateBase.LogState("===>receive: On_GetBarrage:" + text);
            if (text != string.Empty)
            {
                ModelManager.Instance.BarrageQueue_Enqueue(text);
            }
            else
            {
                ClientLogger.Error("P2C_Caption: null barrage content. ");
            }
        }
示例#16
0
 protected override void OnConnectServer(MobaPeerType type)
 {
     base.OnConnectServer(type);
     if (type == MobaPeerType.C2PvpServer)
     {
         PvpStartGameInfo loginInfo = Singleton <PvpManager> .Instance.LoginInfo;
         PvpStateBase.LogState("newbie send C2P_LoginFight");
         SendMsgManager.Instance.SendPvpLoginMsgBase <C2PLoginFight>(PvpCode.C2P_LoginFight, new C2PLoginFight
         {
             roomId = loginInfo.roomId,
             newUid = loginInfo.newUid,
             newkey = loginInfo.newKey
         }, loginInfo.roomId);
     }
 }
        private void L2C_QueryPvpState(MobaMessage msg)
        {
            OperationResponse operationResponse = msg.Param as OperationResponse;
            byte        b           = (byte)operationResponse.Parameters[0];
            PlayerState playerState = (PlayerState)b;

            PvpStateBase.LogState(string.Concat(new object[]
            {
                "receive L2C_QueryPvpState ",
                playerState,
                ", ",
                Time.frameCount
            }));
            this.OnL2CQueryPvpState(playerState);
        }
        private void P2C_Reconnect(MobaMessage msg)
        {
            PvpServer.LockScreen(false);
            RetaMsg      probufMsg    = msg.GetProbufMsg <RetaMsg>();
            byte         retaCode     = probufMsg.retaCode;
            PvpErrorCode pvpErrorCode = (PvpErrorCode)retaCode;

            PvpStateBase.LogState("receive P2C_Reconnect " + pvpErrorCode);
            if (pvpErrorCode != PvpErrorCode.OK)
            {
                NetWorkHelper.Instance.DisconnectPvpServer();
                PvpStateBase.LogState("P2C_Reconnect failed " + pvpErrorCode);
                this.ConfirmQuiting("游戏已经结束,戳确认退出", "游戏结束");
            }
        }
        private void P2C_BackGame(MobaMessage msg)
        {
            PvpServer.LockScreen(false);
            RetaMsg      probufMsg    = msg.GetProbufMsg <RetaMsg>();
            byte         retaCode     = probufMsg.retaCode;
            PvpErrorCode pvpErrorCode = (PvpErrorCode)retaCode;

            PvpStateBase.LogState("receive P2C_BackGame " + pvpErrorCode);
            GameManager.Instance.ReConnected();
            Singleton <PvpManager> .Instance.LoadPvpSceneBegin();

            this.OnP2CBackGame(pvpErrorCode);
            if (pvpErrorCode != PvpErrorCode.OK)
            {
                Singleton <PvpManager> .Instance.AbandonGame(pvpErrorCode);
            }
        }
示例#20
0
        private void P2C_LoginFight(MobaMessage msg)
        {
            RetaMsg probufMsg = msg.GetProbufMsg <RetaMsg>();
            byte    retaCode  = probufMsg.retaCode;

            PvpStateBase.LogState("===>receive: P2C_LoginFight:" + retaCode);
            if (retaCode == 0)
            {
                Singleton <PvpManager> .Instance.LoadPvpSceneBegin();

                PvpStateManager.Instance.ChangeState(new PvpStateLoad());
            }
            else
            {
                ClientLogger.Error("P2C_LoginFight: 别怕,帮助@liuchen定位问题,failed for " + (PvpErrorCode)retaCode);
                CtrlManager.ShowMsgBox("错误", "服务器错误码" + retaCode, new Action(PvpUtils.GoHome), PopViewType.PopOneButton, "确定", "取消", null);
            }
        }
示例#21
0
        private void P2C_LoginAsViewer(MobaMessage msg)
        {
            RetaMsg probufMsg = msg.GetProbufMsg <RetaMsg>();
            byte    retaCode  = probufMsg.retaCode;

            PvpStateBase.LogState("===>receive: P2C_LoginAsViewer:" + retaCode);
            if (retaCode == 0)
            {
                Singleton <PvpManager> .Instance.LoadPvpSceneBegin();

                PvpStateManager.Instance.ChangeState(new PvpStateLoad());
            }
            else
            {
                ClientLogger.Error("P2C_LoginAsViewer: 别怕,帮助@汪洋定位问题,failed for " + retaCode);
                CtrlManager.ShowMsgBox("观战失败", "观战失败,游戏已经结束或者没有观战的权限", new Action(PvpUtils.GoHome), PopViewType.PopOneButton, "确定", "取消", null);
            }
        }
        protected void SayHelloToPs(PvpCode code)
        {
            PvpStateBase.LogState("SayHelloToPs: send " + code);
            PvpStartGameInfo loginInfo = Singleton <PvpManager> .Instance.LoginInfo;
            object           probufObj = null;

            switch (code)
            {
            case PvpCode.C2P_Reconnect:
                probufObj = new C2PReconnect
                {
                    roomId = loginInfo.roomId,
                    newUid = loginInfo.newUid,
                    newkey = loginInfo.newKey
                };
                goto IL_F4;

            case PvpCode.P2C_Reconnect:
IL_39:
                if (code != PvpCode.C2P_LoginAsViewer)
                {
                    goto IL_F4;
                }
                probufObj = new C2PLoginAsViewer
                {
                    roomId = loginInfo.roomId,
                    newUid = int.Parse(ModelManager.Instance.Get_userData_X().UserId),
                    newkey = loginInfo.newKey
                };
                goto IL_F4;

            case PvpCode.C2P_BackGame:
                probufObj = new C2PBackGame
                {
                    roomId = loginInfo.roomId,
                    newUid = loginInfo.newUid,
                    newkey = loginInfo.newKey
                };
                goto IL_F4;
            }
            goto IL_39;
IL_F4:
            SendMsgManager.Instance.SendPvpLoginMsgBase <object>(code, probufObj, loginInfo.roomId);
        }
        protected virtual void P2C_LoginAsViewer(MobaMessage msg)
        {
            PvpServer.LockScreen(false);
            RetaMsg probufMsg = msg.GetProbufMsg <RetaMsg>();
            byte    retaCode  = probufMsg.retaCode;

            PvpStateBase.LogState("===>receive: P2C_LoginAsViewer:" + retaCode);
            if (retaCode == 0)
            {
                Singleton <PvpManager> .Instance.LoadPvpSceneBegin();

                this.RecoverFinish(new PvpStateLoad());
            }
            else
            {
                ClientLogger.Error("P2C_LoginAsViewer: failed for " + retaCode);
                CtrlManager.ShowMsgBox("观战失败", "观战失败,游戏已经结束或者没有观战的权限", new Action(PvpUtils.GoHome), PopViewType.PopOneButton, "确定", "取消", null);
            }
        }
        private void RecoverFromLoadingState(BattleRoomInfo roomInfo, PvpStartGameInfo loginInfo, ReadyPlayerSampleInfo[] playerInfos, bool isFighting)
        {
            PvpStateBase.LogState("RecoverFromLoadingState: " + StringUtils.DumpObject(roomInfo) + " " + StringUtils.DumpObject(loginInfo));
            Singleton <PvpManager> .Instance.SetBattleInfoWithoutJoinType(roomInfo.battleId);

            Singleton <PvpManager> .Instance.SetRoomInfo(roomInfo, loginInfo.newUid, playerInfos, null);

            Singleton <PvpManager> .Instance.LoginInfo = loginInfo;
            if (isFighting)
            {
                Singleton <PvpManager> .Instance.RoomInfo.UpdateAllLoadOk();
            }
            NetWorkHelper.Instance.DisconnectFromGateServer(false);
            NetWorkHelper.Instance.ConnectToPvpServer();
            this.CurrentLink = PvpStateRecoverBase.ActiveLink.PvpServer;
            if (!string.IsNullOrEmpty(roomInfo.roomVoiceID))
            {
            }
        }
示例#25
0
        private void P2C_LoginPve(MobaMessage msg)
        {
            PveLoginRetaMsg probufMsg = msg.GetProbufMsg <PveLoginRetaMsg>();

            byte[] data     = probufMsg.data;
            byte   retaCode = probufMsg.retaCode;

            PvpStateBase.LogState("receive P2C_LoginPve " + retaCode);
            if (retaCode == 0)
            {
                PveBattlePreloadInfo pveBattlePreloadInfo = SerializeHelper.Deserialize <PveBattlePreloadInfo>(data);
                PvpStateBase.LogState("receive P2C_LoginPve ok" + StringUtils.DumpObject(pveBattlePreloadInfo));
                Singleton <PveManager> .Instance.SetBattleInfo(pveBattlePreloadInfo);

                Singleton <PvpManager> .Instance.SetRoomInfoOnServerPve(Singleton <PveManager> .Instance.MyLobbyUserId);

                Singleton <PveManager> .Instance.LoadPvpSceneBegin();
            }
        }
示例#26
0
        private void P2C_LoadProcess(MobaMessage msg)
        {
            Shader.WarmupAllShaders();
            C2PLoadProcess probufMsg = msg.GetProbufMsg <C2PLoadProcess>();
            int            newUid    = probufMsg.newUid;
            byte           process   = probufMsg.process;

            PvpStateBase.LogState(string.Concat(new object[]
            {
                "===>receive: P2C_LoadProcess:",
                newUid,
                " ",
                process
            }));
            HeroExtraInRoom heroExtraByUserId = Singleton <PvpManager> .Instance.RoomInfo.GetHeroExtraByUserId(newUid);

            if (heroExtraByUserId != null)
            {
                heroExtraByUserId.LoadProgress = (int)process;
            }
            MobaMessageManager.DispatchMsg(ClientC2C.PvpLoadProcess, new ParamLoadProcess(newUid, process));
        }
示例#27
0
        private void SyncFightInfo(InBattleRuntimeInfo fightInfo)
        {
            if (Singleton <PvpManager> .Instance.LoadStatus != LoadSceneStatus.Finished)
            {
                return;
            }
            if (fightInfo == null)
            {
                this.TryStartObserving();
                PvpStateBase.LogState("no fight info");
                return;
            }
            RoomState roomState = (RoomState)fightInfo.roomState;

            PvpStateBase.LogState("roomstate " + roomState);
            switch (roomState)
            {
            case RoomState.Wait:
                this.TryStartObserving();
                break;

            case RoomState.Fighting:
            case RoomState.LogicStart:
                PvpProtocolTools.SyncFightInfo(fightInfo);
                this.TryStartObserving();
                PvpStateManager.Instance.ChangeState(new PvpStateStart(PvpStateCode.PvpStart));
                break;

            case RoomState.End:
                Singleton <PvpManager> .Instance.AbandonGame(PvpErrorCode.StateError);

                break;

            default:
                ClientLogger.Assert(false, "unknown roomstate " + roomState);
                break;
            }
        }
示例#28
0
        public void ChangeState(PvpStateBase state)
        {
            if (this._curState != null && this._curState.StateCode == PvpStateCode.PvpNewbieBegin && state != null && state.StateCode != PvpStateCode.PvpLoad)
            {
                return;
            }
            PvpStateCode stateCode = this.StateCode;

            this._nextState = null;
            if (this._curState != null)
            {
                this._curState.Exit();
            }
            this._curState = state;
            if (this._curState != null)
            {
                this._curState.Enter();
            }
            if (this.OnStateChanged != null)
            {
                this.OnStateChanged(stateCode, this.StateCode);
            }
        }
 protected void RecoverFinish(PvpStateBase state)
 {
     PvpStateBase.LogState("RecoverFinish to " + state.StateCode);
     PvpStateManager.Instance.ChangeState(state);
 }
 protected void SendUserBackToGs()
 {
     PvpStateBase.LogState("SendUserBackToGs: send C2L_UserBack");
     Singleton <PvpManager> .Instance.SendLobbyMsgEx(LobbyCode.C2L_UserBack, null, new object[0]);
 }