Beispiel #1
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);
    }
Beispiel #2
0
    public bool CreateNewMatch(string configName, ulong session_id = 0ul, GameMatch.Type matchType = GameMatch.Type.eNone)
    {
        if (mPlayerManager != null)
        {
            mPlayerManager.RemoveAllPlayers();
        }

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

        GameMatch.Config config = new GameMatch.Config();
        GameSystem.Instance.gameMatchConfig.LoadMatchConfig(ref config, GameMatch.Type.eNone);
        GameSystem.Instance.gameMatchConfig.LoadMatchConfig(ref config, matchType);
        config.session_id = session_id;
        if (config.MainRole == null)
        {
            config.MainRole    = new GameMatch.Config.TeamMember();
            config.MainRole.id = (MainPlayer.Instance.CaptainID).ToString();
        }

        GameMatch match = null;

        switch (config.type)
        {
        case GameMatch.Type.e1On1:
            match = new GameMatch_1ON1(config);
            break;

        case GameMatch.Type.eReady:
            object o = LuaScriptMgr.Instance.GetLuaTable("_G")["TestScene"];
            if (o != null)
            {
                config.sceneId = (uint)(double)o;
            }
            match = new GameMatch_Ready(config);
            break;

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

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

        case GameMatch.Type.eGuide:
            GameMatch_Guide.SetConfig(ref config);
            match = new GameMatch_Guide(config);
            break;

        case GameMatch.Type.ePVP_1PLUS:
        case GameMatch.Type.ePVP_3On3:
            //match = new GameMatch_PVP(config);
            match = new GameMatch_PVP(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);
    }