コード例 #1
0
        public static MyGuiScreenStartSessionProgress CurrentScreen = null;    //  This is always filled with reference to actual instance of this scree. If there isn't, it's null.


        public MyGuiScreenStartSessionProgress(MyMwcStartSessionRequestTypeEnum sessionType,  MyTextsWrapperEnum progressText, MyMwcSectorIdentifier? sectorIdentifier, MyGameplayDifficultyEnum difficulty, string checkpointName, MyGuiScreenBase closeAfter) : 
            base(progressText, false)
        {
            // TODO: Not ready yet
            //Debug.Assert(sessionType != MyMwcStartSessionRequestTypeEnum.NEW_STORY && sessionType != MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT, "Invalid operation, call OndrejP");

            m_sectorIdentifier = sectorIdentifier;
            m_sessionType = sessionType;
            m_backgroundFadeColor = MyGuiConstants.SCREEN_BACKGROUND_FADE_BLANK_DARK_PROGRESS_SCREEN;
            m_closeAfter = closeAfter;
            m_difficulty = difficulty;
            m_checkpointName = checkpointName;
            CurrentScreen = this;

            OnSuccessEnter = new Action<MyGuiScreenGamePlayType, MyMwcStartSessionRequestTypeEnum, MyMwcObjectBuilder_Checkpoint>((screenType, sessType, checkpoint) =>
            {
                var newGameplayScreen = new MyGuiScreenGamePlay(screenType, null, checkpoint.CurrentSector, checkpoint.SectorObjectBuilder.Version, sessType);
                var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static);

                if (sessType == MyMwcStartSessionRequestTypeEnum.NEW_STORY)
                    loadScreen.AddEnterSectorResponse(checkpoint, MyMissionID.EAC_SURVEY_SITE);
                else
                    loadScreen.AddEnterSectorResponse(checkpoint, null);

                MyGuiManager.AddScreen(loadScreen);
            });
        }
コード例 #2
0
        public MyGuiScreenLoading(MyGuiScreenGamePlay screenToLoad, MyGuiScreenGamePlay screenToUnload, MyTexture2D textureFromConstructor)
            : base(Vector2.Zero, null, null)
        {
            MyLoadingPerformance.Instance.StartTiming();

            System.Diagnostics.Debug.Assert(Static == null);
            Static = this;

            m_screenToLoad = screenToLoad;
            m_screenToUnload = screenToUnload;
            m_closeOnEsc = false;
            DrawMouseCursor = false;
            m_loadInDrawFinished = false;
            m_drawEvenWithoutFocus = true;
            m_currentQuoteOfTheDay = MyQuoteOfTheDay.GetRandomQuote();
            
            Vector2 loadingTextSize = MyGuiManager.GetNormalizedSize(MyGuiManager.GetFontMinerWarsBlue(),
                MyTextsWrapper.Get(MyTextsWrapperEnum.LoadingPleaseWait), MyGuiConstants.LOADING_PLEASE_WAIT_SCALE);
            m_rotatingWheelTexture = MyGuiManager.GetLoadingTexture();
            Controls.Add(new MyGuiControlRotatingWheel(this, MyGuiConstants.LOADING_PLEASE_WAIT_POSITION - new Vector2(0, 0.075f + loadingTextSize.Y),
                MyGuiConstants.ROTATING_WHEEL_COLOR, MyGuiConstants.ROTATING_WHEEL_DEFAULT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, m_rotatingWheelTexture));
            m_backgroundTextureFromConstructor = textureFromConstructor;

            m_loadFinished = false;
            
            if (m_screenToLoad != null)
            {
                MyMinerGame.IsGameReady = false;
            }
        }
コード例 #3
0
        public MyGuiScreenMultiplayerEnterGameRequest(MyGuiScreenGamePlay.MyJoinGameRequest request)
            : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(574f / 1600f, 600 / 1200f), false, MyGuiManager.GetSandboxBackgoround())
        {
            m_enableBackgroundFade = true;
            m_backgroundFadeColor = new Vector4(0.0f, 0.0f, 0.0f, 0.5f);

            m_request = request;
            AddCaption(MyTextsWrapperEnum.JoinRequestTitle);

            Vector2 menuPositionOrigin = new Vector2(0.0f, -m_size.Value.Y / 2.0f + 0.146f);
            MyGuiControlButtonTextAlignment menuButtonTextAlignement = MyGuiControlButtonTextAlignment.CENTERED;

            Controls.Add(new MyGuiControlLabel(this, menuPositionOrigin + 0 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, null, new StringBuilder(MyTextsWrapper.GetFormatString(MyTextsWrapperEnum.JoinRequest, request.Message.PlayerInfo.DisplayName)), MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiConstants.DEFAULT_CONTROL_FONT));

            Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + 1 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                MyTextsWrapperEnum.AllowEnter, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnAllowEnter, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));

            Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + 2 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                MyTextsWrapperEnum.DenyEnter, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnDenyEnter, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));

            MyGuiControlLabel lblRememberSetting = new MyGuiControlLabel(this, menuPositionOrigin + 3 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA - new Vector2(0.03f, 0), null, MyTextsWrapperEnum.Remember, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            Controls.Add(lblRememberSetting);

            m_chkRememberSetting = new MyGuiControlCheckbox(this, menuPositionOrigin + 3 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA + new Vector2(0.05f, 0), false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR, lblRememberSetting);
            Controls.Add(m_chkRememberSetting);
        }
コード例 #4
0
        public MyGuiScreenUnloading(MyGuiScreenGamePlay screenToUnload, MyGuiScreenBase screenToShowAfter)
            : base(Vector2.Zero, null, null)
        {
            m_screenToUnload = screenToUnload;
            m_closeOnEsc = false;
            DrawMouseCursor = false;
            m_loadInDrawFinished = false;
            m_drawEvenWithoutFocus = true;
            m_currentQuoteOfTheDay = MyQuoteOfTheDay.GetRandomQuote();
            
            Vector2 loadingTextSize = MyGuiManager.GetNormalizedSize(MyGuiManager.GetFontMinerWarsBlue(),
                MyTextsWrapper.Get(MyTextsWrapperEnum.LoadingPleaseWait), MyGuiConstants.LOADING_PLEASE_WAIT_SCALE);
            m_rotatingWheelTexture = MyGuiManager.GetLoadingTexture();
            Controls.Add(new MyGuiControlRotatingWheel(this, MyGuiConstants.LOADING_PLEASE_WAIT_POSITION - new Vector2(0, 0.075f + loadingTextSize.Y),
                MyGuiConstants.ROTATING_WHEEL_COLOR, MyGuiConstants.ROTATING_WHEEL_DEFAULT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, m_rotatingWheelTexture));

            m_loadFinished = false;

            MyMinerGame.IsGameReady = false;
            m_screenToShowAfter = screenToShowAfter;
        }
コード例 #5
0
 public MyGuiScreenLoading(MyGuiScreenGamePlay screenToLoad, MyGuiScreenGamePlay screenToUnload)
     : this(screenToLoad, screenToUnload, null)
 {
 }
コード例 #6
0
        public override bool CloseScreen()
        {
            bool ret = base.CloseScreen();

            if (ret == true && m_screenToLoad != null)
            {
                //  Screen is loaded so now we can add it to other thread
                MyGuiManager.AddScreen(m_screenToLoad);
                m_screenToLoad = null;
            }

            return ret;
        }
コード例 #7
0
        public override void UnloadContent()
        {
            AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyGuiScreenLoading::UnloadContent");
            //  This is just for case that whole application is quiting after Alt+F4 or something
            //  Don't try to unload content in that thread or something - we don't know in what state it is. Just abort it.

            if (m_drawLoadingThread != null && m_drawLoadingThread.IsAlive == true)
            {
                m_backgroundThreadExit.Set();
                m_drawLoadingThread.Join();
            }

            if (m_backgroundScreenTexture != null) MyTextureManager.UnloadTexture(m_backgroundScreenTexture);
            if (m_backgroundTextureFromConstructor!=null) MyTextureManager.UnloadTexture(m_backgroundTextureFromConstructor);
            if (m_backgroundScreenTexture!=null) MyTextureManager.UnloadTexture(m_rotatingWheelTexture);
            if (m_currentSectorDescription != null && m_currentSectorDescription.Item2 != null && m_currentSectorDescription.Item2.Item3 != null) MyTextureManager.UnloadTexture(m_currentSectorDescription.Item2.Item3);


            if (m_screenToLoad != null && !m_loadFinished && m_loadInDrawFinished)
            {
                //  Call unload because there might be running precalc threads and we need to stop them
                //m_screenToLoad.UnloadObjects();
                m_screenToLoad.UnloadContent();
                m_screenToLoad.UnloadData();
               
                //m_screenToLoad.UnloadData();
                m_screenToLoad = null;
            }

            
            if (m_screenToLoad != null && !m_loadInDrawFinished)
            {
                m_screenToLoad.UnloadContent();
            }
            

            base.UnloadContent();

            System.Diagnostics.Debug.Assert(Static == this);
            Static = null;

            AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }
コード例 #8
0
        public void OnEditorClick(MyGuiControlButton sender)
        {
            if (MyClientServer.LoggedPlayer == null || MyClientServer.LoggedPlayer.GetCanAccessEditorForStory() || MyClientServer.LoggedPlayer.GetCanAccessEditorForMMO())
            {
                AddLoginScreen(new MyGuiScreenSelectEditor(this));
            }
            else if (!MySteam.IsActive && !MyClientServer.IsMwAccount) // Demo user...generate sector 0, 0, 0. User cant save.
            {
                MyGuiManager.CloseAllScreensNowExcept(MyGuiScreenGamePlay.Static);

                MySession.Static = new MySandboxSession();
                MySession.Static.Init();

                var sector = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.SANDBOX, MyPlayerLocal.OFFLINE_MODE_USERID, new CommonLIB.AppCode.Utils.MyMwcVector3Int(0, 0, 0), String.Empty);
                var newGameplayScreen = new MyGuiScreenGamePlay(MyGuiScreenGamePlayType.EDITOR_SANDBOX, null, sector, 0, MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX);
                var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static);

                var checkpoint = new MyMwcObjectBuilder_Checkpoint();
                checkpoint.CurrentSector = sector;
                checkpoint.SectorObjectBuilder = new MyMwcObjectBuilder_Sector();
                checkpoint.SectorObjectBuilder.FromGenerator = true;
                checkpoint.SectorObjectBuilder.Position = sector.Position;
                checkpoint.SessionObjectBuilder = new MyMwcObjectBuilder_Session(MyGameplayDifficultyEnum.EASY);

                loadScreen.AddEnterSectorResponse(checkpoint, null);

                MyGuiManager.AddScreen(loadScreen);
            }
            else
            {
                MyMwcSectorTypeEnum sectorType = MyMwcClientServer.GetSectorTypeFromSessionType(MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX);
                AddLoginScreen(
                    new MyGuiScreenLoadSectorIdentifiersProgress(sectorType, false, new MyGuiScreenEnterSectorMap(this, MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX, MyTextsWrapperEnum.StartEditorInProgressPleaseWait, MyConfig.LastSandboxSector)));
            }
        }
コード例 #9
0
        public override bool Update(bool hasFocus)
        {
            if (base.Update(hasFocus) == false) return false;

            int blockUpdate = -1;
            AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyGuiScreenUnloading::Update()", ref blockUpdate);

            if (this.GetState() == MyGuiScreenState.OPENED)
            {
                if (!m_loadFinished)
                {
                    int blockLoad = -1;
                    AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("LoadInBackgroundThread", ref blockLoad);

                    m_backgroundThreadExit = new ManualResetEvent(false);

                    m_drawLoadingThread = new Thread(BackgroundWorkerThread);
                    m_drawLoadingThread.Name = "Unloading thread";
                    m_drawLoadingThread.IsBackground = true;
                    MyGuiManager.AllowedThread = m_drawLoadingThread;
                    m_drawLoadingThread.Start();

                    if (m_screenToUnload != null)
                    {
                        MyMwcLog.WriteLine("RunBackgroundThread - START");
                        m_screenToUnload.UnloadContent();
                        m_screenToUnload.UnloadData();
                        m_screenToUnload.CloseScreenNow();
                        m_screenToUnload = null;
                        MyMwcLog.WriteLine("RunBackgroundThread - END");                        
                    }

                    m_backgroundThreadExit.Set();
                    m_drawLoadingThread.Join();

                    m_loadFinished = true;
                    MyGuiManager.AllowedThread = Thread.CurrentThread;

                    AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(blockLoad);
                }
            }
            if(m_loadFinished){
                MyMinerGame.IsGameReady = true;
                CloseScreen();
            }

            AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(blockUpdate);

            return true;
        }
コード例 #10
0
        public static MyGuiScreenLoading ReloadGameplayScreen(MyMwcObjectBuilder_Checkpoint checkpoint, MyMwcStartSessionRequestTypeEnum? sessionType = null, MyGuiScreenGamePlayType? gameplayType = null, MyMissionID? startMission = null, MyMwcTravelTypeEnum? travelType = null)
        {
            if (MyMultiplayerGameplay.IsRunning)
                MyMultiplayerGameplay.Static.Suspend();

            if (checkpoint.SectorObjectBuilder != null)
            {
                MySession.Static.Is2DSector = MyMwcSectorIdentifier.Is25DSector(checkpoint.SectorObjectBuilder.Name);
            }

            Debug.Assert((gameplayType != null && sessionType != null) || MyGuiScreenGamePlay.Static != null, "Set gameplay type and session type, there's no previous gameplay screen");
            MyGuiScreenGamePlayType newGameplayType = gameplayType.HasValue ? gameplayType.Value : MyGuiScreenGamePlay.Static.GetGameType();
            MyMwcStartSessionRequestTypeEnum? newSessionType = sessionType.HasValue ? sessionType.Value : MyGuiScreenGamePlay.Static.GetSessionType();
            MyGuiScreenGamePlayType? previousGameplaytype = MyGuiScreenGamePlay.Static != null ? MyGuiScreenGamePlay.Static.GetPreviousGameType() : (MyGuiScreenGamePlayType?)null;
            MyMissionID? previousMissionToStart = MyGuiScreenGamePlay.Static != null ? MyGuiScreenGamePlay.Static.m_missionToStart : (MyMissionID?)null;

            var newGameplayScreen = new MyGuiScreenGamePlay(newGameplayType, previousGameplaytype, checkpoint.CurrentSector, checkpoint.SectorObjectBuilder.Version, newSessionType);
            newGameplayScreen.m_missionToStart = previousMissionToStart;
            if (travelType.HasValue)
                newGameplayScreen.m_travelReason = travelType.Value;


            var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static);
            loadScreen.AddEnterSectorResponse(checkpoint, startMission);

            /*
            if (MyConfig.NeedShowPerfWarning)
            {
                MyGuiScreenPerformanceWarning perfWarningScreen = new MyGuiScreenPerformanceWarning(loadScreen);

                perfWarningScreen.Closed += delegate
                {
                    MyGuiManager.AddScreen(loadScreen);
                };

                MyGuiManager.AddScreen(perfWarningScreen);
            }
            else*/
            {
                MyGuiManager.AddScreen(loadScreen);
            }

            return loadScreen;
        }
コード例 #11
0
        public override void UnloadData()
        {
            MyMwcLog.WriteLine("MyGuiScreenGamePlay.UnloadData - START");
            MyMwcLog.IncreaseIndent();

            // duplicated call (called in UnloadContent)
            //if (EditorControls != null)
            //{
            //    EditorControls.UnloadContent();
            //}
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Cleanup missions");
            // Session.Init is not called so cleanup on sector enter
            MyMissions.Unload();
            //m_missionToStart = null; //we need it to load
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            MyRadar.UnloadData();
            MyHud.UnloadData();
            MyEditor.Static.UnloadData();

            MyVoxelMaps.AutoRecalculateVoxelMaps = false;

            MyEntities.UnloadData();

            MyVoxelMaps.AutoRecalculateVoxelMaps = true;

            MyExplosionDebrisVoxel.UnloadData();
            MyExplosionDebrisModel.UnloadData();
            MyUniversalLauncherShells.UnloadData();
            MyCannonShots.UnloadData();
            MyMissiles.UnloadData();
            MyHologramShips.UnloadData();
            MyHudNotification.ClearAllNotifications();
            MyHudWarnings.UnloadData();
            MyDebrisField.UnloadData();
            MyNuclearExplosion.Unload();
            MyEnemyTargeting.Unload();
            MyPathfindingHelper.Unload();
            MySmallShipBot.TotalAliveBots = 0;

            // HOTFIX:
            MyExplosions.UnloadData();
            MyProjectiles.UnloadData();

            //Lights needs to be after explosion, because explosion can keep them
            MyLights.UnloadData();


            if ((IsFlyThroughActive() == false) && (MyMwcFinalBuildConstants.ENABLE_TRAILER_SAVE == true))
            {
                MyTrailerSave.Save();
            }

            if (MyPhysics.physicsSystem != null)
            {
                MyPhysics.physicsSystem.DestroyPhysics();
            }

            MyWayPointGraph.UnloadData();
            MyVoxelMaps.UnloadData();
            MyVoxelPrecalc.UnloadData();
            MyVoxelCacheRender.UnloadData();
            MyVoxelCacheCellRenderHelper.UnloadData();
            MyVoxelCacheData.UnloadData();
            MyVoxelContentCellContents.UnloadData();
            MyVoxelGenerator.UnloadData();
            //MyVoxelMaterials.UnloadData();

            MyDistantImpostors.UnloadData();

            MyPrefabContainerManager.GetInstance().UnloadData();
            MyDistantImpostors.UnloadData();
            //MyModels.UnloadData();

            //MyRender.UnloadData();
            MyDialogues.UnloadData();
            MyFriendlyFire.Unload();
            MyShouts.UnloadData();

            Parallel.Clean();

            Static = null;
            MyMwcLog.DecreaseIndent();
            GC.Collect(2);
            GC.Collect(1);
            GC.Collect(0);


            int modelMeshes2 = MyPerformanceCounter.PerAppLifetime.MyModelsMeshesCount;
            int modelVertices2 = MyPerformanceCounter.PerAppLifetime.MyModelsVertexesCount;
            int modelTriangles2 = MyPerformanceCounter.PerAppLifetime.MyModelsTrianglesCount;
            MyPerformanceCounter.MyPerAppLifetime app = MyPerformanceCounter.PerAppLifetime;

            // After data unload, render structures should be definitelly empty
            //MyRender.AssertStructuresEmpty();

            m_entity = null;
            m_checkpoint = null;

            //MySession.PlayerShip = null;

            //var o = SharpDX.Diagnostics.ObjectTracker.FindActiveObjects();

            MyMwcLog.WriteLine("MyGuiScreenGamePlay.UnloadData - END");
        }
コード例 #12
0
        //  IMPORTANT: This method will be called in background thread so don't mess with main thread objects!!!
        public override void LoadContent()
        {
            MyMwcLog.WriteLine("MyGuiScreenGamePlay.LoadContent - START");
            MyMwcLog.IncreaseIndent();

            Static = this;
            MyMinerGame.IsGameReady = false;

#if DETECT_LEAKS
            MyRender.LoadContent();              
#endif

            MySimpleObjectDraw.LoadContent();

            MyEntities.OnEntityRemove += new Action<MyEntity>(MyEntities_OnEntityRemove);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("LoadContent");
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Part1");

            MyCommonDebugUtils.AssertRelease(m_assertWasCalledUnloadContentBeforeLoadContent == true);

            MyPerformanceTimer.GuiScreenGamePlay_LoadContent.Start();

            if (IsEditorActive()) CameraAttachedTo = MyCameraAttachedToEnum.Spectator;

            MyMwcObjectBuilder_InventoryItem.ReloadDisabledItems(MySession.Is25DSector);

            MyHudSectorBorder.LoadContent();
            MyBackgroundCube.LoadContent(GetSectorIdentifier());
            MyTransparentGeometry.LoadContent();

            MyHud.LoadContent(this);
            //MyHudRadar.LoadContent();
            MyHudGPS.LoadContent();
            MyDecals.LoadContent();
            MyCockpitGlassDecals.LoadContent();
            MyCockpitGlass.LoadContent();
            MyCockpitWeapons.LoadContent();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Part2");

            // TODO: petrzilka, refactor
            List<MyMwcObjectBuilder_Base> objects = null;
            if (m_checkpoint != null && m_checkpoint.SectorObjectBuilder != null)
            {
                objects = m_checkpoint.SectorObjectBuilder.SectorObjects;
            }

            MyDistantImpostors.LoadContent(objects, false /*IsGameActive() || IsEditorActive()*/);//ok

            MyVoxelCacheData.LoadContent();
            MyVoxelCacheRender.LoadContent();

            MyExplosions.LoadContent();
            MyModels.LoadContent();
            MyModelSubObjects.LoadContent();
            MySunWind.LoadContent();
            MyIceStorm.LoadContent();
            MyHudNotification.LoadContent();
            MyVoxelMaterials.LoadContent();
            MyVoxelMaps.LoadContent();
            MyDebrisField.LoadContent();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Part3");

            MyEditor.Static.LoadContent();
            MyCamera.LoadContent();

            // load editor controls also when game active, because we can enter editor during gameplay
            if (IsEditorActive() || IsGameActive())
            {
                EditorControls.LoadContent();
                if (IsEditorActive())
                {
                    EditorControls.AddEditorControlsToList(Controls);
                }
                //FoundationFactoryControls.LoadContent();
            }

            MyEditor.Static.LoadContent();
            MyCamera.LoadContent();
            MyPerformanceTimer.GuiScreenGamePlay_LoadContent.End();

            MyEnvironmentMap.Reset();

            m_assertWasCalledUnloadContentBeforeLoadContent = false;

            //  Base load content must be called after child's load content
            base.LoadContent();

            //  Do GC collect as last step. Reason is that after we loaded new level, a lot of garbage is created and we want to clear it now and not wait until GC decides so.
            //  Sleep is there because we want GC to finish before this background thread ends. We don't want tearing during main menu or game is displaying.
            GC.Collect();
            //Thread.Sleep(100);    //  Not needed anymore because we load on main thread and ther are no sound interferences

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyGuiScreenGamePlay.LoadContent - END");
        }
コード例 #13
0
        public override void LoadData()
        {
            MyMwcLog.WriteLine("MyGuiScreenGamePlay.LoadData - START");
            MyMwcLog.IncreaseIndent();

            m_multipleLoadsCount++;

            int loadDataBlock = -1;
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyGuiScreenGamePlay.LoadData", ref loadDataBlock);

            MyPerformanceTimer.GuiScreenGamePlay_LoadData.Start();

            Static = this;

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MySunGlare.UpdateSectorInfo");
            MySunGlare.UpdateSectorInfo();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyGuiScreenGamePlay.InitSounds");

            InitSounds();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyGuiScreenGamePlay.MyHudSectorBorder block");
            MyHudSectorBorder.LoadData();
            MyDistantImpostors.LoadData();
            MyLights.LoadData();
            MyExplosions.LoadData();
            MyProjectiles.LoadData();
            MyCockpitGlassDecals.LoadData();
            MyModels.LoadData();

            if (IsEditorActive())
            {
                MyGuiManager.LoadPrefabPreviews();
            }
            MyTransparentGeometry.LoadData();
            MyParticlesDustField.LoadData();
            MyHud.LoadData();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyGuiScreenGamePlay.MyVoxelMaterials block");
            MyVoxelMaterials.LoadData();

            MyVoxelGenerator.LoadData();
            MyDebrisField.LoadData();

            MyVoxelContentCellContents.LoadData();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyGuiScreenGamePlay.MyVoxelCacheData block");
            MyVoxelCacheData.LoadData();
            MyVoxelCacheCellRenderHelper.LoadData();
            MyVoxelCacheRender.LoadData();
            MyVoxelPrecalc.LoadData();
            MyVoxelMaps.LoadData();

            MyWayPointGraph.LoadData();

            MyPhysics physics = new MyPhysics();
            physics.InitializePhysics();
            MyConstants.InitializeCollisionLayers();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyGuiScreenGamePlay.MyAmmoConstants block");
            MyAmmoConstants.LoadData();

            MyEntities.LoadData();

            MyMissiles.LoadData();
            MyHologramShips.LoadData();
            MyCannonShots.LoadData();
            MyUniversalLauncherShells.LoadData(true);
            MyExplosionDebrisVoxel.LoadData();
            MyExplosionDebrisModel.LoadData();

            MyEditor.Static.LoadData();
            MyFriendlyFire.Load();

            if (MyFakes.ENABLE_SHOUT)
            {
                MyShouts.LoadData();
            }

            // load editor controls also when game active, because we can enter editor during gameplay
            if (IsEditorActive() || IsGameActive())
            {
                EditorControls.LoadData();
                //FoundationFactoryControls.LoadData();
            }

            m_invokeGameEditorSwitch = false;
            m_lastTimeSwitchedDroneControl = MyConstants.FAREST_TIME_IN_PAST;

            MyPerformanceTimer.GuiScreenGamePlay_LoadData.End();

            PartialDustColor = new List<Vector4>();

            m_notificationYouHaveToBeNearMothership = new MyHudNotification.MyNotification(MyTextsWrapperEnum.NotificationYouHaveToBeNearMothership, MyGuiManager.GetFontMinerWarsRed(), (int)TimeSpan.FromSeconds(5).TotalMilliseconds);
            m_notificationUnableToLeaveSectorMission = new MyHudNotification.MyNotification(MyTextsWrapperEnum.UnableToLeaveSectorMission, MyGuiManager.GetFontMinerWarsRed(), (int)TimeSpan.FromSeconds(5).TotalMilliseconds);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(loadDataBlock);

            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyGuiScreenGamePlay.LoadData - END");
        }
コード例 #14
0
        void ValidateAllMissionsStartingFrom(int index)
        {
            var allMissions = MyMissions.Missions.Values.OfType<MyMission>().ToList();
            if (index >= allMissions.Count) return;

            var mission = allMissions[index];
            MyMissionID missionId = mission.ID;
            // each mission is automatically validated after start
            MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);

            var startSessionScreen = new MyGuiScreenStartSessionProgress(MyMwcStartSessionRequestTypeEnum.NEW_STORY,
                MyTextsWrapperEnum.StartGameInProgressPleaseWait, null, MyGameplayDifficultyEnum.EASY, null, null);

            startSessionScreen.OnSuccessEnter = new Action<MyGuiScreenGamePlayType, MyMwcStartSessionRequestTypeEnum, MyMwcObjectBuilder_Checkpoint>((screenType, sessionType, checkpoint) =>
            {
                Action<MyMwcObjectBuilder_Sector, Vector3> enterSuccessAction = new Action<MyMwcObjectBuilder_Sector, Vector3>((sector, newPosition) =>
                {
                    MyMwcVector3Int sectorPosition;
                    sectorPosition = sector.Position;

                    MyMwcSectorIdentifier newSectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.STORY, MyClientServer.LoggedPlayer.GetUserId(), sectorPosition, null);
                    var newScreen = new MyGuiScreenGamePlay(MyGuiScreenGamePlayType.GAME_STORY, null, newSectorIdentifier, sector.Version, MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT);
                    var loadScreen = new MyGuiScreenLoading(newScreen, MyGuiScreenGamePlay.Static);
                    newScreen.OnGameReady += new ScreenHandler((screen) =>
                    {
                        ((MyMission)MyMissions.GetMissionByID(missionId)).Accept();
                        ValidateAllMissionsStartingFrom(index + 1);  // validate the next mission
                    });

                    loadScreen.AnnounceLeaveToServer = true;
                    loadScreen.LeaveSectorReason = MyMwcLeaveSectorReasonEnum.TRAVEL;

                    // Current sector and sector object builder has changed
                    checkpoint.ActiveMissionID = -1; // Manually deactivate mission
                    checkpoint.PlayerObjectBuilder.ShipObjectBuilder.PositionAndOrientation.Position = newPosition;
                    checkpoint.EventLogObjectBuilder.Clear(); // Or just clear mission start/finish

                    // Make prereq missions completed
                    foreach (var prereq in mission.RequiredMissions)
                    {
                        var start = new MyEventLogEntry() { EventType = EventTypeEnum.MissionStarted, EventTypeID = (int)prereq }.GetObjectBuilder();
                        var end = new MyEventLogEntry() { EventType = EventTypeEnum.MissionFinished, EventTypeID = (int)prereq }.GetObjectBuilder();
                        checkpoint.EventLogObjectBuilder.Add(start);
                        checkpoint.EventLogObjectBuilder.Add(end);
                    }

                    checkpoint.SectorObjectBuilder = sector;
                    checkpoint.CurrentSector.Position = sector.Position;
                    loadScreen.AddEnterSectorResponse(checkpoint, missionId);

                    MyGuiManager.AddScreen(loadScreen);

                    if (MyMinerGame.IsPaused())
                        MyMinerGame.SwitchPause();
                });

                //  Load neighbouring sector 
                MyGuiManager.AddScreen(new MyGuiScreenEnterSectorProgress(MyMwcTravelTypeEnum.SOLAR, mission.Location.Sector, Vector3.Zero, enterSuccessAction));

                //var newGameplayScreen = new MyGuiScreenGamePlay(screenType, null, checkpoint.CurrentSector, sessionType);
                //var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static);

                //loadScreen.AddEnterSectorResponse(checkpoint);
                //MyGuiManager.AddScreen(loadScreen);
            });

            MyGuiManager.AddScreen(startSessionScreen);
        }