Exemple #1
0
    override public void OnEnter(AIState lastState)
    {
        m_player.moveDirection = IM.Vector3.zero;

        match = m_match as GameMatch_Practise;
        practise_behaviour = match.practise_behaviour as PractiseBehaviourRule;
    }
    public void EnterGame()
    {
        if (respInfo == null)
        {
            Debug.LogError("Enter game failed with empty info");
            return;
        }

        MainPlayer.Instance.AccountID  = respInfo.acc_id;
        MainPlayer.Instance.CreateStep = respInfo.create_step;
        MainPlayer.Instance.SetBaseInfo(respInfo.info);

        Debug.Log("EnterGame, create_step:" + respInfo.create_step);
        Debug.Log("EnterGame, loadedLevel:" + Application.loadedLevel);
        if (Application.loadedLevelName == GlobalConst.SCENE_STARTUP)   // scene startup
        {
            GameSystem.Instance.mClient.Reset();
            if (respInfo.create_step == 1)              //进入基础操作练习
            {
                PractiseData practise = GameSystem.Instance.PractiseConfig.GetConfig(20001);
                GameSystem.Instance.mClient.CreateMatch(practise, 0ul);
                GameMatch_Practise match = GameSystem.Instance.mClient.mCurMatch as GameMatch_Practise;
                match.onBehaviourCreated = () =>
                {
                    PractiseBehaviourGuide behaviour = match.practise_behaviour as PractiseBehaviourGuide;
                    behaviour.onOver = () =>
                    {
                        CreateStepIn req = new CreateStepIn();
                        req.acc_id = respInfo.acc_id;
                        GameSystem.Instance.mNetworkManager.m_platConn.SendPack(0, req, MsgID.CreateStepInID);
                    };
                };
            }
            else
            {
                MainPlayer.Instance.HpRestoreTime = DateTime.Now + new TimeSpan(0, 0, (int)respInfo.hp_restore_remain);

                //老玩家,进入大厅界面
                LuaTable tScene = LuaScriptMgr.Instance.GetLuaTable("Scene");
                tScene.Set("targetUI", "UIHall");
                tScene.Set("subID", null);
                tScene.Set("params", null);
                SceneManager.Instance.ChangeScene(GlobalConst.SCENE_HALL);
            }
        }
        else
        {
            GameMatch curMatch = GameSystem.Instance.mClient.mCurMatch;
            if (curMatch == null)
            {
                GameSystem.Instance.mClient.Reset();
            }
            else                // In match, resend EnterGameReq
            {
                Debug.Log("EnterGame, Curr league type:" + curMatch.GetConfig().leagueType);
                if (curMatch.GetConfig().leagueType == GameMatch.LeagueType.eQualifying)
                {
                    GameSystem.Instance.mClient.Reset();
                    LuaTable tScene = LuaScriptMgr.Instance.GetLuaTable("Scene");
                    tScene.Set("targetUI", "UIQualifying");
                    tScene.Set("subID", null);
                    tScene.Set("params", null);
                    SceneManager.Instance.ChangeScene(GlobalConst.SCENE_MATCH);
                }
                else if (curMatch.GetConfig().leagueType == GameMatch.LeagueType.ePVP)
                {
                    LuaScriptMgr.Instance.CallLuaFunction("jumpToUI", new object[] { "UIHall", null, null });
                }
                else if (curMatch.GetConfig().leagueType == GameMatch.LeagueType.eQualifyingNewer)
                {
                    LuaTable tQualifyingNewer = LuaScriptMgr.Instance.GetLuaTable("QualifyingNewer");
                    tQualifyingNewer.Set("inBackToLadder", false);
                    tQualifyingNewer.Set("isJoinLadder", false);
                    tQualifyingNewer.Set("isWinShowIncStarAnim", false);


                    LuaScriptMgr.Instance.CallLuaFunction("jumpToUI", new object[] { "UIHall", null, null });
                }
                else if (curMatch.leagueType == GameMatch.LeagueType.eRegular1V1 ||
                         curMatch.leagueType == GameMatch.LeagueType.eQualifyingNew ||
                         curMatch.leagueType == GameMatch.LeagueType.ePractise1vs1)
                {
                    MatchStateOver over = curMatch.m_stateMachine.m_curState as MatchStateOver;
                    if (over == null)
                    {
                        GameSystem.Instance.mClient.Reset();
                        if (curMatch.leagueType == GameMatch.LeagueType.eRegular1V1)
                        {
                            SceneManager.Instance.ChangeScene(GlobalConst.SCENE_HALL);
                        }
                        else if (curMatch.leagueType == GameMatch.LeagueType.eQualifyingNew)
                        {
                            LuaScriptMgr.Instance.CallLuaFunction("jumpToUI", new object[] { "UIHall", null, null });
                        }
                    }
                    else
                    {
                        if (curMatch.m_stateMachine.m_curState.m_eState != MatchState.State.eOver ||
                            (over != null && !over.matchResultSent)
                            )
                        {
                            Debug.Log("Resend cached EnterGameReq from new");
                            MatchType type = GameMatch_PVP.ToMatchType(curMatch.leagueType, curMatch.m_config.type);
                            if (curMatch.leagueType == GameMatch.LeagueType.ePractise1vs1)
                            {
                                EnterGameReq req = new EnterGameReq();
                                req.acc_id                            = MainPlayer.Instance.AccountID;
                                req.type                              = type;
                                req.game_mode                         = fogs.proto.msg.GameMode.GM_Practice1On1;
                                req.practice_pve                      = new BeginPracticePve();
                                req.practice_pve.id                   = 1;
                                req.practice_pve.fight_list           = new FightRoleInfo();
                                req.practice_pve.fight_list.game_mode = fogs.proto.msg.GameMode.GM_Practice1On1;
                                FightRole fr = new FightRole();
                                fr.role_id = curMatch.mainRole.m_id;
                                fr.status  = FightStatus.FS_MAIN;
                                req.practice_pve.fight_list.fighters.Add(fr);
                                over.SendEnterGamePractise1vs1(req);
                            }
                            else
                            {
                                over.SendEnterGame(type);
                            }
                        }
                    }
                }
                else if (PlatNetwork.Instance.cachedEnterGameReq != null)
                {
                    if (curMatch.m_stateMachine.m_curState.m_eState != MatchState.State.eOver ||
                        !(curMatch.m_stateMachine.m_curState as MatchStateOver).matchResultSent)
                    {
                        Debug.Log("Resend cached EnterGameReq");
                        LuaHelper.SendPlatMsgFromLua((uint)MsgID.EnterGameReqID, PlatNetwork.Instance.cachedEnterGameReq);
                    }
                }
            }
        }

        if (respInfo.create_step >= GameSystem.Instance.CommonConfig.GetUInt("gMaxCreateStep"))
        {
            // after renaming step( the last step), mark as login.
            MainPlayer.Instance.AddCreateNewRoleLog(true);
        }
        else
        {
            MainPlayer.Instance.AddCreateNewRoleLog(false);
        }
    }
Exemple #3
0
    public bool CreateNewMatch(GameMatch.Config config)
    {
        if (mPlayerManager != null)
        {
            mPlayerManager.RemoveAllPlayers();
        }

        if (mCurMatch != null)
        {
            mCurMatch = null;
        }

        //涂鸦数据
        GameMatch.Config.TeamMember mainRole = config.MainRole;
        if (mainRole != null)
        {
            RoleInfo role = MainPlayer.Instance.GetRole2(uint.Parse(mainRole.id));
            if (role != null && role.badge_book_id != 0)
            {
                BadgeBook book = MainPlayer.Instance.badgeSystemInfo.GetBadgeBookByBookId(role.badge_book_id);
                mainRole.badgeBook = book;
            }
            for (int i = 0; i < config.NPCs.Count; ++i)
            {
                GameMatch.Config.TeamMember teamMate = config.NPCs [i];
                if (teamMate != null)
                {
                    RoleInfo roleTeammate = MainPlayer.Instance.GetRole2(uint.Parse(teamMate.id));
                    if (roleTeammate != null && roleTeammate.badge_book_id != 0)
                    {
                        BadgeBook book = MainPlayer.Instance.badgeSystemInfo.GetBadgeBookByBookId(roleTeammate.badge_book_id);
                        teamMate.badgeBook = book;
                    }
                }
            }
        }

        GameMatch match = null;

        switch (config.type)
        {
        case GameMatch.Type.ePVP_1PLUS:
        case GameMatch.Type.ePVP_3On3:
            match = new GameMatch_PVP(config);
            break;

        case GameMatch.Type.e1On1:
        case GameMatch.Type.eCareer1On1:
            match = new GameMatch_1ON1(config);
            break;

        case GameMatch.Type.ePractise:
            match = new GameMatch_Practise(config);
            break;

        case GameMatch.Type.eReady:
            match = new GameMatch_Ready(config);
            break;

        case GameMatch.Type.eFreePractice:
            match = new GameMatch_FreePractice(config);
            break;

        case GameMatch.Type.ePracticeVs:
            match = new GameMatch_PracticeVs(config);
            break;

        case GameMatch.Type.e3On3:
        case GameMatch.Type.eCareer3On3:
            match = new GameMatch_3ON3(config);
            break;

        case GameMatch.Type.eAsynPVP3On3:
            match = new GameMatch_AsynPVP3ON3(config);
            break;

        case GameMatch.Type.e3AIOn3AI:
            match = new GameMatch_3AION3AI(config);
            break;

        case GameMatch.Type.eReboundStorm:
            match = new GameMatch_ReboundStorm(config);
            break;

        case GameMatch.Type.eBlockStorm:
            match = new GameMatch_BlockStorm(config);
            break;

        case GameMatch.Type.eUltimate21:
            match = new GameMatch_Ultimate21(config);
            break;

        case GameMatch.Type.eMassBall:
            match = new GameMatch_MassBall(config);
            break;

        case GameMatch.Type.eGrabZone:
            match = new GameMatch_GrabZone(config);
            break;

        case GameMatch.Type.eGrabPoint:
            match = new GameMatch_GrabPoint(config);
            break;

        case GameMatch.Type.eBullFight:
            match = new GameMatch_BullFight(config);
            break;

        case GameMatch.Type.ePractice1V1:
            match = new GameMatch_Practice1V1(config);
            break;

        case GameMatch.Type.eQualifyingNewerAI:
            match = new GameMatch_QualifyingNewerAI(config);
            break;

        case GameMatch.Type.eLadderAI:
            match = new GameMatch_LadderAI(config);
            break;
        }
        if (match == null)
        {
            Debug.LogError("Unsupported match type is detected when creating a new match.");
            return(false);
        }

        mCurMatch = match;
        mCurMatch.Build();

        return(true);
    }
Exemple #4
0
    public void Update()
    {
        if (curStep == null && readyStep != null)
        {
            if (string.IsNullOrEmpty(readyStep.uiName) || IsUIVisible(readyStep.uiName, readyStep.highlightButton))
            {
                GuideStep stepToRun = readyStep;
                readyStep = null;
                RunStep(stepToRun);
            }
        }
        else if (curStep != null)
        {
            bool isUIVisible     = IsUIVisible(curStep.uiName);
            bool isButtonCovered = !IsUIVisible(curStep.uiName, curStep.highlightButton);

            if (curStep.conditions.Contains(GuideStep.CompleteCondition.EndWithUI) && !isUIVisible)
            {
                EndCurStep();
            }
            else
            {
                if (isUIVisible)
                {
                    if (!guideHiding && isButtonCovered)
                    {
                        Hide(true);
                    }
                    else if (guideHiding && !isButtonCovered)
                    {
                        Hide(false);
                    }

                    Animator animator = basePanel.FindChild(curStep.uiName).GetComponent <Animator>();
                    if (showTipAfterAnimating && !IsAnimating(animator))
                    {
                        ShowTip(curStep);
                        showTipAfterAnimating = false;
                    }
                }
                else
                {
                    //Interrupted
                    ModuleClear();
                }
            }
        }

        if (timerFinishStep != null)
        {
            timerFinishStep.Update(Time.deltaTime);
        }

        if (toListenPractiseGuide)
        {
            GameMatch_Practise match = GameSystem.Instance.mClient.mCurMatch as GameMatch_Practise;
            if (match != null)
            {
                PractiseBehaviourGuide behaviour = match.practise_behaviour as PractiseBehaviourGuide;
                if (behaviour != null)
                {
                    Transform tmBasePanel  = GameSystem.Instance.mClient.mUIManager.m_uiRootBasePanel.transform;
                    Transform tmBackButton = tmBasePanel.FindChild("UIPractise(Clone)/ButtonBack(Clone)");
                    if (tmBackButton != null)
                    {
                        NGUITools.SetActive(tmBackButton.gameObject, false);
                    }
                    behaviour.onOver     += OnPractiseGuideOver;
                    toListenPractiseGuide = false;
                }

                PractiseBehaviourSkillGuide behaviour1 = match.practise_behaviour as PractiseBehaviourSkillGuide;
                if (behaviour1 != null)
                {
                    behaviour1.onOver    += OnPractiseGuideOver;
                    toListenPractiseGuide = false;
                }
            }
        }
    }