private void HandleRegisterLoginServerFeedback(byte[] data)
        {
            UILockManager.ResetGroupState(UIEventGroup.Middle);

            RegisterS2C feedback = ProtobufUtils.Deserialize <RegisterS2C>(data);

            if (feedback == null)
            {
                Utils.DebugUtils.LogError(Utils.DebugUtils.Type.Login, "HandleRegisterLoginServerFeedback - feedback is null");
                return;
            }

            if (feedback.result > 0)
            {
                Account account = datamanager.GetAccount();
                account.userID             = userID;
                account.password           = password;
                account.accountId          = feedback.accountId;
                ClientTcpMessage.sessionId = feedback.loginSessionId;

                PlayerPrefs.SetString("userID", userID);
                PlayerPrefs.SetString("userPW", password);

                Utils.DebugUtils.Log(Utils.DebugUtils.Type.Login, "HandleRegisterLoginServerFeedback");

                view.SetPlayerChoiceWindow(true);
            }
            else
            {
                view.FailedRegister(feedback.tipType);
            }
        }
        private void HandleInvationMatchFeedback( byte[] data )
        {
            UILockManager.ResetGroupState( UIEventGroup.Middle );

            InvitationMatchS2C feedback = ProtobufUtils.Deserialize<InvitationMatchS2C>( data );

            if ( feedback.result )
            {
                switch ( feedback.state )
                {
                    case InvitationState.AcceptInvitation:
                        view.OpenFightMatchView( matcherReadyDatas );
                        break;
                    case InvitationState.RefuseInvitation:
                    case InvitationState.DestroyInvitation:
                        view.CloseView();
                        break;
                    case InvitationState.FriendInBattle:
                        view.CloseView();
                        OpenPopUp( "提示", "您的好友已进入战斗" );
                        break;
                    case InvitationState.FriendInMatching:
                        view.CloseView();
                        OpenPopUp( "提示", "您的好友已在匹配中" );
                        break;
                }
            }
        }
        private void HandleChangeBattleConfigFeedback(byte[] data)
        {
            UILockManager.ResetGroupState(UIEventGroup.Middle);

            ChangeBattleConfigS2C feedback = ProtobufUtils.Deserialize <ChangeBattleConfigS2C>(data);

            if (feedback.result)
            {
                DataManager dataManager = DataManager.GetInstance();

                switch (feedback.configType)
                {
                case 1:    //1-army 2-rune 3-instituteSkill
                    dataManager.SetBattleConfigArmyIndex(feedback.config.battleType, feedback.config.labelPage);
                    break;

                case 2:    //1-army 2-rune 3-instituteSkill
                    dataManager.SetBattleConfigRuneIndex(feedback.config.battleType, feedback.config.labelPage);
                    break;

                case 3:    //1-army 2-rune 3-instituteSkill
                    dataManager.SetBattleConfigInstituteSkillIndex(feedback.config.battleType, feedback.config.labelPage);
                    break;
                }
            }
        }
        private void HandleBattleMessageFeedback(byte[] data)
        {
            UILockManager.ResetGroupState(UIEventGroup.Middle);

            BattleS2C feedback = ProtobufUtils.Deserialize <BattleS2C>(data);

            if (feedback.result)
            {
                DataManager dataManager = DataManager.GetInstance();
                if (feedback.battleId != 0)
                {
                    // receive this message second time
                    dataManager.SetBattleServerIp(feedback.serverIp);
                    dataManager.SetBattleServerPort(feedback.serverPort);
                    dataManager.SetBattleId(feedback.battleId);
                    dataManager.SetSeed(feedback.seed);

                    ConnectBattleServer();
                }
                else
                {
                    // receive this message first time
                    dataManager.SetBattlers(feedback.battlers);
                }
            }
            else
            {
                DebugUtils.LogError(DebugUtils.Type.Match, " HandleBattleMessage result = false, maybe some error occured! ");
            }
        }
        private void HandleJoinBattleListFeedback(byte[] data)
        {
            UILockManager.ResetGroupState(UIEventGroup.Middle);
            JoinArmyS2C feedback = ProtobufUtils.Deserialize <JoinArmyS2C>(data);

            if (feedback.result)
            {
            }
        }
        private void HandleLoginFeedback(byte[] data)
        {
            UILockManager.ResetGroupState(UIEventGroup.Middle);

            LoginS2C feedback = ProtobufUtils.Deserialize <LoginS2C>(data);

            if (feedback == null)
            {
                Utils.DebugUtils.LogError(Utils.DebugUtils.Type.Login, "HandleLoginFeedback - feedback is null");
                return;
            }

            if (feedback.result == 1)
            {
                Account account = datamanager.GetAccount();
                account.userID   = userID;
                account.password = password;
                datamanager.SetAccountId(feedback.accountId);
                ClientTcpMessage.sessionId = feedback.loginSessionId;

                if (feedback.playerId < 0)
                {
                    Utils.DebugUtils.Log(Utils.DebugUtils.Type.Login, "HandleLoginFeedback - need to chose avatar and username");
                    view.SetPlayerChoiceWindow(true);
                }
                else
                {
                    ClientTcpMessage.sessionId = feedback.loginSessionId;
                    datamanager.SetPlayerId(feedback.playerId);
                    datamanager.SetAccountId(feedback.accountId);
                    datamanager.SetGameServerIp(feedback.gameServerIp);
                    datamanager.SetGameServerPort(feedback.gameServerPort);
                    gameServerIP     = feedback.gameServerIp;
                    gameServerPort   = feedback.gameServerPort;
                    socialServerIP   = feedback.socialServerIp;
                    socialServerPort = feedback.socialServerPort;

                    PlayerPrefs.SetString("userID", userID);
                    PlayerPrefs.SetString("userPW", password);

                    Utils.DebugUtils.Log(Utils.DebugUtils.Type.Login, "HandleLoginFeedback");

                    DisconnectLoginServerAndConnectGameServer(feedback.gameServerIp, feedback.gameServerPort);
                    SwtichScene();
                }
            }
            else if (feedback.result == 2)
            {
                datamanager.SetAccountId(feedback.accountId);
                view.OpenPlayerChoiceWindow();
            }
            else
            {
                view.FailedLogin(feedback.tipType);
            }
        }
        private void HandleNoticeMessageFeedback(byte[] data)
        {
            UILockManager.ResetGroupState(UIEventGroup.Middle);

            NoticeS2C feedback = ProtobufUtils.Deserialize <NoticeS2C>(data);

            if (feedback.type == NoticeType.BattleBegin)
            {
                view.currentUIType = FightMatchView.FightMatchUIType.None;
                view.OnExit(true);
            }
        }
        private void HandleChangeScienceSkillFeedback(byte[] data)
        {
            UILockManager.ResetGroupState(UIEventGroup.Middle);
            ChangeScienceSkillS2C feedback = ProtobufUtils.Deserialize <ChangeScienceSkillS2C>(data);

            if (feedback.result)
            {
                DataManager.GetInstance().SetPlayerSetedPackageInstituteSkills(feedback.pageId, feedback.scienceSkillIds);

                view.RefreshInstituteItem();
            }
        }
        private void HandleApplyRoomFeedback(byte[] data)
        {
            UILockManager.ResetGroupState(UIEventGroup.Middle);

            ApplyRoomS2C feedback = ProtobufUtils.Deserialize <ApplyRoomS2C>(data);

            if (feedback.result)
            {
                NetworkManager.Shutdown(() => MatchLobbyServer(feedback.lobbyServerIp, feedback.lobbyServerPort));

                DataManager.GetInstance().SetLobbyServerIp(feedback.lobbyServerIp);
                DataManager.GetInstance().SetLobbyServerPort(feedback.lobbyServerPort);
            }
        }
        private void HandleBuySkillArrributeFeedback(byte[] data)
        {
            UILockManager.ResetGroupState(UIEventGroup.Middle);
            BuySciencePageS2C feedback = ProtobufUtils.Deserialize <BuySciencePageS2C>(data);

            if (feedback.result)
            {
                DataManager manager = DataManager.GetInstance();

                if (feedback.pageId == 1)
                {
                    view.SetSecondSkillDeck(true);
                }
                else if (currentUnlockSkillDeckIndex == 2)
                {
                    view.SetThirdSkillDeck(true);
                }

                manager.SetPlayerSetedPackageInstituteSkills(feedback.pageId, feedback.scienceSkillIds);
            }
        }
Beispiel #11
0
        /// <summary>
        /// Exit current view
        /// </summary>
        /// <param name="isGoBack"> true: Exit current view and return to top view, false, Just exit current view </param>
        public virtual void OnExit(bool isGoBack)
        {
            if (_viewStack != null)
            {
                _viewStack.Pop();
                UIManager.Instance.RecycleUI(this);

                if (isGoBack)
                {
                    ExitTransition(uiTransitionMode);
                }

                if (this._controller != null)
                {
                    this._controller.OnPause();
                }

                openState = false;
                UILockManager.ResetGroupState(UIEventGroup.Middle);
            }
        }
        private void HandleMatchFeedback(byte[] data)
        {
            UILockManager.ResetGroupState(UIEventGroup.Middle);

            MatchS2C feedback = ProtobufUtils.Deserialize <MatchS2C>(data);

            switch (feedback.result)
            {
            case MatchServerMessageType.RoomCreatedSucceed:
                DebugUtils.Log(DebugUtils.Type.Match, "Room Created Succeed~");
                //view.timeLeft_room = feedback.matchTime / 1000;

                view.OpenMatchingUI();
                break;

            case MatchServerMessageType.RoomCreatedFail:
                DebugUtils.Log(DebugUtils.Type.Match, "Match Room Created Fail~");
                break;

            case MatchServerMessageType.RoomFound:
                DebugUtils.Log(DebugUtils.Type.Match, "Room Found~");

                break;

            case MatchServerMessageType.RoomReady:
                DebugUtils.Log(DebugUtils.Type.Match, "Room Ready~");
                view.OpenMatchSucceedUI();
                view.timeLeft_matchSucceed = feedback.matchTime / 1000;
                MatchSucceedUIData(feedback.matchers);
                break;

            case MatchServerMessageType.Cancelled:
            case MatchServerMessageType.MatchingTimeout:
                DebugUtils.Log(DebugUtils.Type.Match, feedback.result.ToString() + "~");

                isTimeOut = false;
                ConnectGameServer(feedback);
                matcherReadyDatas.Remove(matcherReadyDatas.Find(p => p.playerId != DataManager.GetInstance().GetPlayerId()));
                view.SetFriendUI(false);
                view.beInvited    = false;
                currentFriendItem = null;
                currentFriendId   = 0;
                view.OpenMatchUI();
                view.SetStartMatchState(false);
                break;

            case MatchServerMessageType.CancelFailed:
                DebugUtils.Log(DebugUtils.Type.Match, "Match Cancel Failed~");
                break;

            case MatchServerMessageType.MatcherFound:
                DebugUtils.Log(DebugUtils.Type.Match, "Matcher Found~");

                break;

            case MatchServerMessageType.MatcherCancelled:
                DebugUtils.Log(DebugUtils.Type.Match, "Matcher Cancelled~");
                MatcherCancelledUIData(feedback.matchers);
                //view.timeLeft_room = feedback.matchTime / 1000;
                //TODO: if the friend cancelled  ,  need do something

                break;

            case MatchServerMessageType.MatcherReady:
                DebugUtils.Log(DebugUtils.Type.Match, "Matcher Ready~");
                MatchSucceedUIData(feedback.matchers);
                break;

            default:
                DebugUtils.Log(DebugUtils.Type.Match, "Match result is wrong~");
                break;
            }
        }