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);
            });
        }
        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);
            });
        }
        internal override bool Read(System.IO.BinaryReader binaryReader, System.Net.EndPoint senderEndPoint, int gameVersion)
        {
            if (!base.Read(binaryReader, senderEndPoint, gameVersion)) return NetworkError();

            int? difficulty = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            if (!difficulty.HasValue) return NetworkError();

            Difficulty = (MyGameplayDifficultyEnum) difficulty.Value;

            return true;
        }
        internal override bool Read(System.IO.BinaryReader binaryReader, System.Net.EndPoint senderEndPoint, int gameVersion)
        {
            if (!base.Read(binaryReader, senderEndPoint, gameVersion))
            {
                return(NetworkError());
            }

            int?difficulty = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);

            if (!difficulty.HasValue)
            {
                return(NetworkError());
            }

            Difficulty = (MyGameplayDifficultyEnum)difficulty.Value;

            return(true);
        }
 public void OnEasyClick(MyGuiControlButton sender)
 {
     m_difficulty = MyGameplayDifficultyEnum.EASY;
     Run();
 }
        public void AddResponse(MyMwcStartSessionResponseTypeEnum startSessionResponse, MyMwcSectorIdentifier?sectorIdentifier, MyGameplayDifficultyEnum difficulty)
        {
            MyGuiScreenGamePlayType screenType;

            if (startSessionResponse == MyMwcStartSessionResponseTypeEnum.OK)
            {
                MyMwcSectorTypeEnum   sessionType;
                MyMwcSessionStateEnum sessionStartType;
                int?            userId   = null;
                MyMwcVector3Int?position = null;

                if ((m_sessionType == MyMwcStartSessionRequestTypeEnum.NEW_STORY) || (m_sessionType == MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT))
                {
                    MySession.Static = new MySinglePlayerSession(difficulty);
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.GAME_STORY;

                    sessionType      = MyMwcSectorTypeEnum.STORY;
                    sessionStartType = m_sessionType == MyMwcStartSessionRequestTypeEnum.NEW_STORY ? MyMwcSessionStateEnum.NEW_GAME : MyMwcSessionStateEnum.LOAD_CHECKPOINT;
                    userId           = MyClientServer.LoggedPlayer.GetUserId();
                }
                else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX)
                {
                    MySession.Static = new MySandboxSession();
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.EDITOR_SANDBOX;

                    Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor");
                    Debug.Assert(m_sectorIdentifier.Value.UserId == null || m_sectorIdentifier.Value.UserId == MyClientServer.LoggedPlayer.GetUserId(), "Sandbox sector user identifier must be null or same as current user");
                    sessionType      = MyMwcSectorTypeEnum.SANDBOX;
                    sessionStartType = MyMwcSessionStateEnum.EDITOR;
                    userId           = m_sectorIdentifier.Value.UserId;
                    position         = m_sectorIdentifier.Value.Position;
                }
                else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_STORY)
                {
                    MySession.Static = new MySinglePlayerSession(difficulty);
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.EDITOR_STORY;

                    Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor");
                    sessionType      = MyMwcSectorTypeEnum.STORY;
                    sessionStartType = MyMwcSessionStateEnum.EDITOR;
                    userId           = null;
                    position         = m_sectorIdentifier.Value.Position;
                }
                else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_MMO)
                {
                    MySession.Static = new MySinglePlayerSession(difficulty);
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.EDITOR_MMO;

                    Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor");
                    sessionType      = MyMwcSectorTypeEnum.MMO;
                    sessionStartType = MyMwcSessionStateEnum.EDITOR;
                    userId           = null;
                    position         = m_sectorIdentifier.Value.Position;
                }
                else if (
                    (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_OWN) ||
                    (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_FRIENDS) ||
                    (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_RANDOM))
                {
                    MySession.Static = new MySandboxSession();
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.GAME_SANDBOX;

                    Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for sandbox");
                    sessionType      = MyMwcSectorTypeEnum.SANDBOX;
                    sessionStartType = MyMwcSessionStateEnum.LOAD_CHECKPOINT;
                    userId           = m_sectorIdentifier.Value.UserId;
                    position         = m_sectorIdentifier.Value.Position;
                    //if (m_sessionType != MyMwcStartSessionRequestTypeEnum.SANDBOX_RANDOM)
                    //{
                    //    position = m_sectorIdentifier.Value.Position;
                    //}
                }
                else
                {
                    throw new NotImplementedException();
                }

                Action <MyMwcObjectBuilder_Checkpoint> enterSuccessAction = new Action <MyMwcObjectBuilder_Checkpoint>((checkpoint) =>
                {
                    OnSuccessEnter(screenType, m_sessionType, checkpoint);
                });

                MyGuiManager.AddScreen(new MyGuiScreenLoadCheckpointProgress(sessionType, sessionStartType, userId, position, m_checkpointName, enterSuccessAction));

                if (m_closeAfter != null)
                {
                    m_closeAfter.CloseScreenNow();
                }
            }
            else
            {
                MyMwcLog.WriteLine("Error starting the session: " + startSessionResponse.ToString());
                MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.StartGameFailed,
                                                                 MyTextsWrapperEnum.MessageBoxCaptionError, MyTextsWrapperEnum.Ok, null));
            }

            CloseScreen();
        }
Exemplo n.º 7
0
        ///////////////////// NEW STUFF //////////////////////////
        #region NEW_GAME

        /// <summary>
        /// Initializes a new single player session and start new game
        /// </summary>
        public static MyServerAction StartNewGame(MyGameplayDifficultyEnum difficulty, MyMissionID startMission = MyMissionID.EAC_SURVEY_SITE)
        {
            MySession.Static = new MySinglePlayerSession(difficulty);
            MySession.Static.Init();
            return MySession.Static.NewGame(startMission);
        }
Exemplo n.º 8
0
 public static MyGuiScreenLoading StartJoinMultiplayerSession(MyGameTypes gameType, MyGameplayDifficultyEnum difficulty, MyMwcObjectBuilder_Checkpoint checkpoint)
 {
     // Temporary
     MySession.Static = new MySinglePlayerSession(difficulty);
     MySession.Static.Init();
     return MySession.Static.JoinMultiplayerSession(gameType, checkpoint);
 }
Exemplo n.º 9
0
 public bool IsActivatedForDifficulty(MyGameplayDifficultyEnum difficulty) 
 {
     MyPersistentEntityFlags flagsForDifficulty = GetFlagsForDifficulty(difficulty);
     return (PersistentFlags & flagsForDifficulty) == flagsForDifficulty;
 }                
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MySession"/> class.
 /// </summary>
 public MySinglePlayerSession(MyGameplayDifficultyEnum difficulty)
 {
     MyGameplayConstants.SetGameplayDifficulty(difficulty);
 }
 public MyMwcObjectBuilder_Session(MyGameplayDifficultyEnum difficulty)
 {
     Difficulty = difficulty;
 }
Exemplo n.º 12
0
        ///////////////////// NEW STUFF //////////////////////////
        #region NEW_GAME

        /// <summary>
        /// Initializes a new single player session and start new game
        /// </summary>
        public static MyServerAction StartNewGame(MyGameplayDifficultyEnum difficulty, MyMissionID startMission = MyMissionID.EAC_SURVEY_SITE)
        {
            MySession.Static = new MySinglePlayerSession(difficulty);
            MySession.Static.Init();
            return(MySession.Static.NewGame(startMission));
        }
Exemplo n.º 13
0
        public void HostGame(string sectorName, string password, MyGameTypes gameType, GameCreatedHandler onGameCreated, MyJoinMode joinMode, MyGameplayDifficultyEnum difficulty)
        {
            Debug.Assert(!MyMultiplayerGameplay.IsRunning);

            MyMultiplayerPeers.Static.Restart();
            m_introductionTimer.Dispose();
            m_hostTimer.Dispose();

            m_createGameAction = onGameCreated;

            MyEventCreateGame createGameRequest = new MyEventCreateGame();

            createGameRequest.SectorName          = sectorName;
            createGameRequest.Password            = password;
            createGameRequest.Type                = gameType;
            createGameRequest.JoinMode            = joinMode;
            createGameRequest.Difficulty          = difficulty;
            MyMultiplayerGameplay.Static.JoinMode = joinMode;
            SetCallback <MyEventCreateGameResponse>(OnCreateGameResponse);
            MyMultiplayerPeers.Static.NetworkClient.RegisterCallback <MyEventLoginResponse>(OnLoginResponse);

            m_hostTimer           = new Timer();
            m_hostTimer.AutoReset = false;
            m_hostTimer.Elapsed  += new ElapsedEventHandler(m_hostTimer_Elapsed);
            m_hostTimer.Interval  = 10000;
            m_hostTimer.Start();

            MyMultiplayerGameplay.Static.LastCreateGameRequest = createGameRequest;
            MyMultiplayerPeers.Static.SendServer(ref createGameRequest);
        }
 public void OnNormalClick(MyGuiControlButton sender)
 {
     m_difficulty = MyGameplayDifficultyEnum.NORMAL;
     Run();
 }
Exemplo n.º 15
0
 public static MyGameplayDifficultyProfile GetGameplayDifficultyProfile(MyGameplayDifficultyEnum difficulty)
 {
     return m_gameplayDifficultyProfiles[(int)difficulty];
 }
Exemplo n.º 16
0
 public static void SetGameplayDifficulty(MyGameplayDifficultyEnum difficulty)
 {
     m_difficulty = difficulty;
     GameplayDifficultyProfile = m_gameplayDifficultyProfiles[(int)difficulty];
 }
Exemplo n.º 17
0
 public static MyGuiScreenLoading StartJoinMultiplayerSession(MyGameTypes gameType, MyGameplayDifficultyEnum difficulty, MyMwcObjectBuilder_Checkpoint checkpoint)
 {
     // Temporary
     MySession.Static = new MySinglePlayerSession(difficulty);
     MySession.Static.Init();
     return(MySession.Static.JoinMultiplayerSession(gameType, checkpoint));
 }
Exemplo n.º 18
0
 public string GetGameName(MyGameTypes gameType, MyGameplayDifficultyEnum difficulty)
 {
     if (gameType == MyGameTypes.Story)
     {
         if (MyMissions.ActiveMission != null)
         {
             return MyTextsWrapper.Get(MyMissions.ActiveMission.Name).ToString();
         }
         else
         {
             return MyTextsWrapper.Get(MyTextsWrapperEnum.FreeRoaming).ToString();
         }
     }
     else
     {
         return String.IsNullOrWhiteSpace(m_sectorIdentifier.SectorName) ? Checkpoint.SectorObjectBuilder.Name : m_sectorIdentifier.SectorName;
     }
 }
 public void OnNormalClick(MyGuiControlButton sender)
 {
     m_difficulty = MyGameplayDifficultyEnum.NORMAL;
     Run();
 }
 public void OnEasyClick(MyGuiControlButton sender)
 {
     m_difficulty = MyGameplayDifficultyEnum.EASY;
     Run();
 }
 public void OnHardClick(MyGuiControlButton sender)
 {
     m_difficulty = MyGameplayDifficultyEnum.HARD;
     Run();
 }
 public void OnHardClick(MyGuiControlButton sender)
 {
     m_difficulty = MyGameplayDifficultyEnum.HARD;
     Run();
 }
        public void AddResponse(MyMwcStartSessionResponseTypeEnum startSessionResponse, MyMwcSectorIdentifier? sectorIdentifier, MyGameplayDifficultyEnum difficulty)
        {
            MyGuiScreenGamePlayType screenType;

            if (startSessionResponse == MyMwcStartSessionResponseTypeEnum.OK)
            {
                MyMwcSectorTypeEnum sessionType;
                MyMwcSessionStateEnum sessionStartType;
                int? userId = null;
                MyMwcVector3Int? position = null;

                if ((m_sessionType == MyMwcStartSessionRequestTypeEnum.NEW_STORY) || (m_sessionType == MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT))
                {
                    MySession.Static = new MySinglePlayerSession(difficulty);
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.GAME_STORY;

                    sessionType = MyMwcSectorTypeEnum.STORY;
                    sessionStartType = m_sessionType == MyMwcStartSessionRequestTypeEnum.NEW_STORY ? MyMwcSessionStateEnum.NEW_GAME : MyMwcSessionStateEnum.LOAD_CHECKPOINT;
                    userId = MyClientServer.LoggedPlayer.GetUserId();
                }
                else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX)
                {
                    MySession.Static = new MySandboxSession();
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.EDITOR_SANDBOX;

                    Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor");
                    Debug.Assert(m_sectorIdentifier.Value.UserId == null || m_sectorIdentifier.Value.UserId == MyClientServer.LoggedPlayer.GetUserId(), "Sandbox sector user identifier must be null or same as current user");
                    sessionType = MyMwcSectorTypeEnum.SANDBOX;
                    sessionStartType = MyMwcSessionStateEnum.EDITOR;
                    userId = m_sectorIdentifier.Value.UserId;
                    position = m_sectorIdentifier.Value.Position;
                }
                else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_STORY)
                {
                    MySession.Static = new MySinglePlayerSession(difficulty);
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.EDITOR_STORY;

                    Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor");
                    sessionType = MyMwcSectorTypeEnum.STORY;
                    sessionStartType = MyMwcSessionStateEnum.EDITOR;
                    userId = null;
                    position = m_sectorIdentifier.Value.Position;
                }
                else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_MMO)
                {
                    MySession.Static = new MySinglePlayerSession(difficulty);
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.EDITOR_MMO;

                    Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor");
                    sessionType = MyMwcSectorTypeEnum.MMO;
                    sessionStartType = MyMwcSessionStateEnum.EDITOR;
                    userId = null;
                    position = m_sectorIdentifier.Value.Position;
                }
                else if (
                    (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_OWN) || 
                    (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_FRIENDS) ||
                    (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_RANDOM))
                {
                    MySession.Static = new MySandboxSession();
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.GAME_SANDBOX;

                    Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for sandbox");
                    sessionType = MyMwcSectorTypeEnum.SANDBOX;
                    sessionStartType = MyMwcSessionStateEnum.LOAD_CHECKPOINT;
                    userId = m_sectorIdentifier.Value.UserId;
                    position = m_sectorIdentifier.Value.Position;
                    //if (m_sessionType != MyMwcStartSessionRequestTypeEnum.SANDBOX_RANDOM)
                    //{
                    //    position = m_sectorIdentifier.Value.Position;
                    //}
                }
                else
                {
                    throw new NotImplementedException();
                }
                
                Action<MyMwcObjectBuilder_Checkpoint> enterSuccessAction = new Action<MyMwcObjectBuilder_Checkpoint>((checkpoint) =>
                {
                    OnSuccessEnter(screenType, m_sessionType, checkpoint);
                });

                MyGuiManager.AddScreen(new MyGuiScreenLoadCheckpointProgress(sessionType, sessionStartType, userId, position, m_checkpointName, enterSuccessAction));

                if (m_closeAfter != null) m_closeAfter.CloseScreenNow();
            }
            else
            {
                MyMwcLog.WriteLine("Error starting the session: " + startSessionResponse.ToString());
                MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.StartGameFailed,
                    MyTextsWrapperEnum.MessageBoxCaptionError, MyTextsWrapperEnum.Ok, null));
            }

            CloseScreen();
        }
Exemplo n.º 24
0
 private MyPersistentEntityFlags GetFlagsForDifficulty(MyGameplayDifficultyEnum difficulty) 
 {                        
     switch(difficulty)
     {
         case MyGameplayDifficultyEnum.EASY:
             return ACTIVATED_DIFFICULTY_EASY;
         case MyGameplayDifficultyEnum.NORMAL:
             return ACTIVATED_DIFFICULTY_NORMAL;
         case MyGameplayDifficultyEnum.HARD:
             return ACTIVATED_DIFFICULTY_HARD;
     }
     throw new MyMwcExceptionApplicationShouldNotGetHere();
 }
 public MyMwcObjectBuilder_Session(MyGameplayDifficultyEnum difficulty)
 {
     Difficulty = difficulty;
 }