Beispiel #1
0
 public virtual bool Initialize(GameContextBase InGameContext)
 {
     DebugHelper.Assert(InGameContext != null);
     this.GameContext = InGameContext;
     return(this.GameContext != null);
 }
Beispiel #2
0
        public GameInfoBase StartGame(GameContextBase InGameContext)
        {
            DebugHelper.Assert(InGameContext != null);
            if (InGameContext == null)
            {
                return(null);
            }
            if (Singleton <BattleLogic> .get_instance().isRuning)
            {
                return(null);
            }
            SynchrReport.Reset();
            GameSettings.DecideDynamicParticleLOD();
            Singleton <CHeroSelectBaseSystem> .get_instance().m_fOpenHeroSelectForm = Time.time - Singleton <CHeroSelectBaseSystem> .get_instance().m_fOpenHeroSelectForm;

            this.m_fLoadingTime = Time.time;
            this.m_eventsLoadingTime.Clear();
            ApolloAccountInfo accountInfo = Singleton <ApolloHelper> .GetInstance().GetAccountInfo(false);

            DebugHelper.Assert(accountInfo != null, "account info is null");
            this.m_iMapId    = InGameContext.levelContext.m_mapID;
            this.m_kGameType = InGameContext.levelContext.GetGameType();
            this.m_eventsLoadingTime.Add(new KeyValuePair <string, string>("OpenID", (accountInfo == null) ? "0" : accountInfo.get_OpenId()));
            this.m_eventsLoadingTime.Add(new KeyValuePair <string, string>("LevelID", InGameContext.levelContext.m_mapID.ToString()));
            this.m_eventsLoadingTime.Add(new KeyValuePair <string, string>("isPVPLevel", InGameContext.levelContext.IsMobaMode().ToString()));
            this.m_eventsLoadingTime.Add(new KeyValuePair <string, string>("isPVPMode", InGameContext.levelContext.IsMobaMode().ToString()));
            this.m_eventsLoadingTime.Add(new KeyValuePair <string, string>("bLevelNo", InGameContext.levelContext.m_levelNo.ToString()));
            Singleton <BattleLogic> .GetInstance().isRuning = true;

            Singleton <BattleLogic> .GetInstance().isFighting = false;

            Singleton <BattleLogic> .GetInstance().isGameOver = false;

            Singleton <BattleLogic> .GetInstance().isWaitMultiStart = false;

            ActionManager.Instance.frameMode = true;
            MonoSingleton <ActionManager> .GetInstance().ForceStop();

            Singleton <GameObjMgr> .GetInstance().ClearActor();

            Singleton <SceneManagement> .GetInstance().Clear();

            MonoSingleton <SceneMgr> .GetInstance().ClearAll();

            MonoSingleton <GameLoader> .GetInstance().ResetLoader();

            InGameContext.PrepareStartup();
            if (!MonoSingleton <GameFramework> .get_instance().EditorPreviewMode)
            {
                DebugHelper.Assert(InGameContext.levelContext != null);
                DebugHelper.Assert(!string.IsNullOrEmpty(InGameContext.levelContext.m_levelDesignFileName));
                if (string.IsNullOrEmpty(InGameContext.levelContext.m_levelArtistFileName))
                {
                    MonoSingleton <GameLoader> .get_instance().AddLevel(InGameContext.levelContext.m_levelDesignFileName);
                }
                else
                {
                    MonoSingleton <GameLoader> .get_instance().AddDesignSerializedLevel(InGameContext.levelContext.m_levelDesignFileName);

                    MonoSingleton <GameLoader> .get_instance().AddArtistSerializedLevel(InGameContext.levelContext.m_levelArtistFileName);
                }
                MonoSingleton <GameLoader> .get_instance().AddSoundBank("Effect_Common");

                MonoSingleton <GameLoader> .get_instance().AddSoundBank("System_Voice");
            }
            GameInfoBase gameInfoBase = InGameContext.CreateGameInfo();

            DebugHelper.Assert(gameInfoBase != null, "can't create game logic object!");
            this.gameInfo = gameInfoBase;
            gameInfoBase.PreBeginPlay();
            Singleton <BattleLogic> .get_instance().m_LevelContext = this.gameInfo.gameContext.levelContext;

            try
            {
                DebugHelper.CustomLog("GameBuilder Start Game: ispvplevel={0} ispvpmode={4} levelid={1} leveltype={6} levelname={3} Gametype={2} pick={5}", new object[]
                {
                    InGameContext.levelContext.IsMobaMode(),
                    InGameContext.levelContext.m_mapID,
                    InGameContext.levelContext.GetGameType(),
                    InGameContext.levelContext.m_levelName,
                    InGameContext.levelContext.IsMobaMode(),
                    InGameContext.levelContext.GetSelectHeroType(),
                    InGameContext.levelContext.m_pveLevelType
                });
                Player hostPlayer = Singleton <GamePlayerCenter> .get_instance().GetHostPlayer();

                if (hostPlayer != null)
                {
                    DebugHelper.CustomLog("HostPlayer player id={1} name={2} ", new object[]
                    {
                        hostPlayer.PlayerId,
                        hostPlayer.Name
                    });
                }
            }
            catch (Exception)
            {
            }
            if (!MonoSingleton <GameFramework> .get_instance().EditorPreviewMode)
            {
                this.m_fLoadProgress = 0f;
                MonoSingleton <GameLoader> .GetInstance().Load(new GameLoader.LoadProgressDelegate(this.onGameLoadProgress), new GameLoader.LoadCompleteDelegate(this.OnGameLoadComplete));

                MonoSingleton <VoiceSys> .GetInstance().HeroSelectTobattle();

                Singleton <GameStateCtrl> .GetInstance().GotoState("LoadingState");
            }
            return(gameInfoBase);
        }