Ejemplo n.º 1
0
    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);
        }
    }
Ejemplo n.º 2
0
    void Awake()
    {
        m_match = GameSystem.Instance.mClient.mCurMatch;

        leftNameLabel  = transform.FindChild("LeftName").GetComponent <UILabel>();
        rightNameLabel = transform.FindChild("RightName").GetComponent <UILabel>();
        bg             = transform.FindChild("Bg").GetComponent <UISprite>();
        leftScoreNode  = transform.FindChild("LeftScore");
        rightScoreNode = transform.FindChild("RightScore");
        timerNode      = transform.FindChild("TimerNode");

        GameObject prefab = ResourceLoadManager.Instance.LoadPrefab("Prefab/GUI/TimerBoard") as GameObject;

        timerBoard = CommonFunction.InstantiateObject(prefab, timerNode).GetComponent <TimerBoard>();
        timerBoard.backgroundVisible = false;

        prefab                 = ResourceLoadManager.Instance.LoadPrefab("Prefab/GUI/ScoreBoard") as GameObject;
        leftScoreBoard         = CommonFunction.InstantiateObject(prefab, leftScoreNode).GetComponent <ScoreBoard_new>();
        leftScoreBoard.isLeft  = true;
        rightScoreBoard        = CommonFunction.InstantiateObject(prefab, rightScoreNode).GetComponent <ScoreBoard_new>();
        rightScoreBoard.isLeft = false;

        mCounter24            = GameUtils.FindChildRecursive(transform, "TimeCounter24").GetComponent <UTimeCounter24>();
        m_match.m_count24Time = m_match.MAX_COUNT24_TIME;
        mCounter24.gameObject.SetActive(false);

        mCenterAnchor = GameUtils.FindChildRecursive(transform, "Anchor_Center");
        mTopAnchor    = GameUtils.FindChildRecursive(transform, "Anchor_Top");

        leftBall  = transform.FindChild("LeftBall").gameObject;
        rightBall = transform.FindChild("RightBall").gameObject;

        m_leftNode  = transform.Find("LeftNode");
        m_rightNode = transform.Find("RightNode");

        prefab      = ResourceLoadManager.Instance.LoadPrefab("Prefab/GUI/msg/Foul_24") as GameObject;
        m_goFoulMsg = GameObject.Instantiate(prefab) as GameObject;
        m_goFoulMsg.transform.parent = mCenterAnchor;
        m_goFoulMsg.SetActive(false);

        prefab           = ResourceLoadManager.Instance.LoadPrefab("Prefab/GUI/msg/Msg_CheckBall") as GameObject;
        m_goCheckBallMsg = GameObject.Instantiate(prefab) as GameObject;
        m_goCheckBallMsg.transform.parent = mCenterAnchor;
        m_goCheckBallMsg.SetActive(false);

        prefab = ResourceLoadManager.Instance.LoadPrefab("Prefab/GUI/ButtonPause") as GameObject;
        Transform buttonParent = transform.FindChild("ButtonPause");

        goExit = CommonFunction.InstantiateObject(prefab, buttonParent);
        UIEventListener.Get(goExit).onClick = OnExit;

        goShortMsgFolder = transform.FindChild("ButtonArrow").gameObject;
        goShortMsgFolder.AddComponent <TweenRotation>();

        UIEventListener.Get(goShortMsgFolder).onClick = OnClickMsg;

        goCustomMsg = transform.FindChild("LeftButton/ButtonTalk").gameObject;
        UIEventListener.Get(goCustomMsg).onClick = OnClickMsg;

        goMsg1 = transform.FindChild("LeftButton/ButtonMark/Icon").gameObject;
        UIEventListener.Get(goMsg1.transform.parent.gameObject).onClick = OnClickMsg;

        goMsg2 = transform.FindChild("LeftButton/ButtonExchange/Icon").gameObject;
        UIEventListener.Get(goMsg2.transform.parent.gameObject).onClick = OnClickMsg;

        GameObject goGrid = transform.FindChild("LeftButton/Grid").gameObject;

        uiGridCustomMsgs = goGrid.GetComponent <UIGrid>();
        GameObject sampleBtn = uiGridCustomMsgs.GetChild(0).gameObject;
        GameObject goBtnItem = GameObject.Instantiate(sampleBtn) as GameObject;

        m_btnCustomItem = goBtnItem.GetComponent <UIButton>();
        goBtnItem.SetActive(false);
        sampleBtn.SetActive(false);

        m_msgHomeBlobs = transform.FindChild("HomeBlobs").GetComponent <UIMatchMessageBlob>();
        m_msgAwayBlobs = transform.FindChild("AwayBlobs").GetComponent <UIMatchMessageBlob>();

        m_sprWifi = transform.FindChild("RightButton/ButtonWifi/Icon").GetComponent <UISprite>();
        m_labWifi = transform.FindChild("RightButton/ButtonWifi/Num").GetComponent <UILabel>();


        m_curMatchMsgCond = 0;
        m_bShowCustomMsg  = false;
        m_bShowAll        = true;


        GameMatch.LeagueType leagueType = m_match.GetConfig().leagueType;
        if (leagueType == GameMatch.LeagueType.eRegular1V1 || leagueType == GameMatch.LeagueType.ePVP || leagueType == GameMatch.LeagueType.eQualifyingNew ||
            leagueType == GameMatch.LeagueType.eQualifyingNewer ||
            leagueType == GameMatch.LeagueType.eQualifyingNewerAI ||
            leagueType == GameMatch.LeagueType.eLadderAI
            )
        {
            m_pingTime = new GameUtils.Timer4View(2f, OnPing);
        }
        else
        {
            m_bShowAll = false;
            goShortMsgFolder.SetActive(false);
            transform.FindChild("RightButton").gameObject.SetActive(false);
        }

        m_matchScoreEffect = gameObject.AddComponent <UIMatchScoreEffect>();

        OnPing();
    }