コード例 #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 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);
            });
        }
コード例 #3
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)));
            }
        }
コード例 #4
0
        // Restarts gameplay (loads last checkpoint or reloads sandbox)
        // Be careful, this is used for Gameover screen too!
        public void Restart()
        {
            MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);

            if (MyGuiScreenGamePlay.Static.GetGameType() == MyGuiScreenGamePlayType.GAME_STORY)
            {
                MySession.StartLastCheckpoint();
            }
            else if (MyGuiScreenGamePlay.Static.GetGameType() == MyGuiScreenGamePlayType.GAME_SANDBOX)
            {
                var sectorIdentifier = MyGuiScreenGamePlay.Static.GetSectorIdentifier();
                MySession.StartSandbox(sectorIdentifier.Position, sectorIdentifier.UserId);
            }
            else if (MyGuiScreenGamePlay.Static.IsEditorActive())
            {
                // The "old way" in future should be on MySession
                CloseScreenNow();

                Action<MyMwcObjectBuilder_Checkpoint> enterSuccessAction = new Action<MyMwcObjectBuilder_Checkpoint>((checkpoint) =>
                {
                    var loadScreen = new MyGuiScreenLoading(new MyGuiScreenGamePlay(m_type, m_previousType, checkpoint.CurrentSector, checkpoint.SectorObjectBuilder.Version, m_sessionType.Value), MyGuiScreenGamePlay.Static);
                    loadScreen.AnnounceLeaveToServer = true;
                    loadScreen.LeaveSectorReason = MyMwcLeaveSectorReasonEnum.RELOAD;

                    loadScreen.AddEnterSectorResponse(checkpoint, null);
                    MyGuiManager.AddScreen(loadScreen);
                });
                MyMissions.Unload();
                MyGuiManager.AddScreen(new MyGuiScreenLoadCheckpointProgress(m_sectorIdentifier.SectorType, MyMwcSessionStateEnum.EDITOR, m_sectorIdentifier.UserId, m_sectorIdentifier.Position, null, enterSuccessAction));
            }
        }
コード例 #5
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;
        }
コード例 #6
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);
        }
コード例 #7
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);
        }