void BuildDefenses_Loaded(MyMissionBase sender)
        {
            m_buildingStopped = false;

            m_turretsBuilt = 0;

            m_buildDefenses.MissionEntityIDs.Add(GetTurretFromContainer((uint)EntityID.TURRET_CONTAINER_ID_1).EntityId.Value.NumericValue);
            m_buildDefenses.MissionEntityIDs.Add(GetTurretFromContainer((uint)EntityID.TURRET_CONTAINER_ID_2).EntityId.Value.NumericValue);
            m_buildDefenses.MissionEntityIDs.Add(GetTurretFromContainer((uint)EntityID.TURRET_CONTAINER_ID_3).EntityId.Value.NumericValue);
            m_buildDefenses.MissionEntityIDs.Add(GetTurretFromContainer((uint)EntityID.TURRET_CONTAINER_ID_4).EntityId.Value.NumericValue);
            m_buildDefenses.MissionEntityIDs.Add(GetTurretFromContainer((uint)EntityID.TURRET_CONTAINER_ID_5).EntityId.Value.NumericValue);
            m_buildDefenses.MissionEntityIDs.Add(GetTurretFromContainer((uint)EntityID.TURRET_CONTAINER_ID_6).EntityId.Value.NumericValue);
            m_buildDefenses.MissionEntityIDs.Add(GetTurretFromContainer((uint)EntityID.TURRET_CONTAINER_ID_7).EntityId.Value.NumericValue);

            foreach (var detectorTurretContainerPair in m_detectorToTurretContainerMapping)
            {
                MyScriptWrapper.Highlight(detectorTurretContainerPair.Value, true, this);
                MyScriptWrapper.EnablePhysics(detectorTurretContainerPair.Value, false);
                MyScriptWrapper.UnhideEntity(MyScriptWrapper.GetEntity(detectorTurretContainerPair.Value));

                ShowContainer(MyScriptWrapper.GetEntity(detectorTurretContainerPair.Value) as MyPrefabContainer);

                var turret = GetTurretFromContainer(detectorTurretContainerPair.Value);
                Debug.Assert(turret != null);
                if (turret != null)
                {
                    turret.Enabled = false;
                    MyScriptWrapper.MarkEntity(turret, MyTexts.BuildTurret, MyHudIndicatorFlagsEnum.SHOW_TEXT | MyHudIndicatorFlagsEnum.SHOW_DISTANCE | MyHudIndicatorFlagsEnum.SHOW_BORDER_INDICATORS | MyHudIndicatorFlagsEnum.SHOW_MISSION_MARKER, MyGuitargetMode.Objective);
                }
            }


            foreach (var dummyId in m_detectorToTurretContainerMapping)
            {
                var detector = MyScriptWrapper.GetEntity(dummyId.Key) as MyEntityDetector;
                //MyScriptWrapper.GetEntity(dummyId.Key);
                Debug.Assert(detector != null);
                if (detector != null)
                {
                    // register for player ship enter
                    detector.OnEntityEnter += TurretDummyEnter;
                    detector.OnEntityLeave += TurretDummyLeave;
                    detector.On();
                }
            }

            m_canBuildNotification = MyScriptWrapper.CreateNotification(Localization.MyTextsWrapperEnum.PressToBuildTurret, MyGuiManager.GetFontMinerWarsBlue());
            m_canBuildNotification.SetTextFormatArguments(m_actionKeyString);

            m_remainingTurretsNotification = MyScriptWrapper.CreateNotification(Localization.MyTextsWrapperEnum.RemainingTurrets, MyGuiManager.GetFontMinerWarsBlue());
            m_remainingTurretsNotification.IsImportant = true;

            //m_canSkipNotification = MyScriptWrapper.CreateNotification(Localization.MyTextsWrapperEnum.PressToSkipTimer, MyGuiManager.GetFontMinerWarsBlue());
            //m_canSkipNotification.SetTextFormatArguments(m_actionKeyString);
            //m_canSkipNotification.Disappear();


            MyScriptWrapper.AddNotification(m_remainingTurretsNotification);

            MyScriptWrapper.OnUseKeyPress += Build_UseKeyPress;
        }
        private void ProtectBarth_Loaded(MyMissionBase sender)
        {
            m_canRepairNotification = MyScriptWrapper.CreateNotification(
                Localization.MyTextsWrapperEnum.PressToRepairTurret,
                MyGuiManager.GetFontMinerWarsBlue());
            m_canRepairNotification.SetTextFormatArguments(m_actionKeyString);


            m_repairing = false;


            ShowContainer(EntityID._05PirateBigShip);
            ShowContainer(EntityID._05PirateShip);

            MyScriptWrapper.SetEntityDestructible(MyScriptWrapper.GetEntity("MadelynsBridge"), true);

            MyScriptWrapper.PrepareMotherShipForMove(m_05PirateShip);
            MyScriptWrapper.PrepareMotherShipForMove(m_05PirateBigShip);
            MyScriptWrapper.SetEntityEnabled(MyScriptWrapper.GetEntity("FrontTurretM"), true);
            MyScriptWrapper.SetEntityEnabled(MyScriptWrapper.GetEntity("BackTurretM"), true);
            MyScriptWrapper.SetEntityEnabled(MyScriptWrapper.GetEntity("BottomTurretM"), true);
            ActivateSpawnpoints(m_05SpawnPoints);
        }
        public MyGuiScreenGamePlay(MyGuiScreenGamePlayType type, MyGuiScreenGamePlayType? previousType, MyMwcSectorIdentifier sectorIdentifier, int sectorVersion, MyMwcStartSessionRequestTypeEnum? sessionType)
            : base(Vector2.Zero, null, null)
        {
            MySystemTimer.SetByType(type);

            m_sessionType = sessionType;
            m_sectorIdentifier = sectorIdentifier;
            SectorVersion = sectorVersion;
            m_directionToSunNormalized = -MyMwcUtils.Normalize(GetPositionInMillionsOfKm());
            DrawMouseCursor = false;
            m_closeOnEsc = false;
            m_type = type;
            m_previousType = previousType;
            m_firstUpdateCall = true;
            m_firstDrawCall = FIRST_TOTAL_DELAY;
            m_drawEvenWithoutFocus = true;
            m_enableBackgroundFade = true;
            m_canShareInput = false;
            m_screenCanHide = false;

            m_isPreparedTextureForSectorLoadingScreen = false;
            m_prepareTextureForSectorLoadingScreen = false;

            MinerWars.AppCode.Networking.SectorService.MySectorServerCallback.ClearEvents();
            MinerWars.AppCode.Networking.SectorService.MySectorServerCallback.ShutdownNotification += new MinerWars.AppCode.Networking.SectorService.MySectorServerCallback.ShutdownHandler(MySectorServerCallback_ShutdownNotification);

            m_secondarySetup = new MyRender.MyRenderSetup();
            m_secondarySetup.EnabledModules = new HashSet<MyRenderModuleEnum>();
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.Cockpit);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.CockpitGlass);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.SunGlareAndLensFlare);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.UpdateOcclusions);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.AnimatedParticlesPrepare);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.TransparentGeometry);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.ParticlesDustField);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.VoxelHand);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.DistantImpostors);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.Decals);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.CockpitWeapons);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.SunGlow);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.SectorBorder);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.DrawSectorBBox);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.DrawCoordSystem);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.Explosions);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.BackgroundCube);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.GPS);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.TestField);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.AnimatedParticles);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.Lights);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.TransparentGeometryForward);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.Projectiles);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.DebrisField);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.ThirdPerson);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.Editor);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.SolarObjects);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.SolarMapGrid);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.PrunningStructure);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.SunWind);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.IceStormWind);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.PrefabContainerManager);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.PhysicsPrunningStructure);

            m_showGPSNotification = new MyHudNotification.MyNotification(MyTextsWrapperEnum.GPSReminder, MyHudConstants.MISSION_FONT, MyHudNotification.DONT_DISAPEAR, null, null);
            m_showGPSNotification.SetTextFormatArguments(new object[] { MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.GPS) });
        }
        private void ShowOrHideNotification(bool show, ref MyHudNotification.MyNotification notification, MyTextsWrapperEnum text, MyGameControlEnums? gameControl)
        {
            if (show)
            {
                if (notification == null)
                {
                    notification = new MyHudNotification.MyNotification(text, MyHudConstants.MISSION_FONT, MyHudNotification.DONT_DISAPEAR, null, null);
                    if (gameControl.HasValue)
                    {
                        notification.SetTextFormatArguments(new object[] { MyGuiManager.GetInput().GetGameControlTextEnum(gameControl.Value) });
                    }
                    notification.Disappear();
                }

                if (notification.IsDisappeared())
                {
                    notification.Appear();
                    MyHudNotification.AddNotification(notification);
                }
            }
            else
            {
                if (notification != null && !notification.IsDisappeared())
                    notification.Disappear();
            }
        }
 void OnCountdown(ref MyEventCountdown msg)
 {
     ClearCountdownNotification();
     if (msg.Timespan.Ticks > 0)
     {
         m_countdownNotification = new MyHudNotification.MyNotification(MyTextsWrapperEnum.Countdown, MyGuiManager.GetFontMinerWarsBlue());
         m_countdownNotification.SetTextFormatArguments(new object[] { String.Format("{0:00}", msg.Timespan.Minutes) + ":" + String.Format("{0:00}", msg.Timespan.Seconds) });
         MyHudNotification.AddNotification(m_countdownNotification);
     }
 }
        public override void Load()
        {
            
            MyScriptWrapper.OnBotReachedWaypoint += BotReachedWaypoint;
            MyScriptWrapper.OnSpawnpointBotSpawned += OnSpawnpointBotSpawned;
            MyScriptWrapper.EntityDeath += OnEntityDeath;

            m_actionKeyString[0] = MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.USE);
            
            m_canBuildNotification = MyScriptWrapper.CreateNotification(
                Localization.MyTextsWrapperEnum.PressToBuildTurret,
                MyGuiManager.GetFontMinerWarsBlue());
            m_canBuildNotification.SetTextFormatArguments(m_actionKeyString);

            m_remainingTurretsNotification = MyScriptWrapper.CreateNotification(
                Localization.MyTextsWrapperEnum.RemainingTurrets,
                MyGuiManager.GetFontMinerWarsBlue());

            //m_canSkipNotification = MyScriptWrapper.CreateNotification(
            //    Localization.MyTextsWrapperEnum.PressToSkipTimer,
            //    MyGuiManager.GetFontMinerWarsBlue());
            //m_canSkipNotification.SetTextFormatArguments(m_actionKeyString);
            //m_canSkipNotification.Disappear();

            m_generatorUnderAttackNotification = MyScriptWrapper.CreateNotification(
                Localization.MyTextsWrapperEnum.GeneratorUnderAttack,
                MyGuiManager.GetFontMinerWarsRed(), 3000);
            m_generatorUnderAttackNotification.Disappear();


            m_useProgress = new MyGuiScreenUseProgressBar(MyTextsWrapperEnum.Turrets, MyTextsWrapperEnum.BuildingInProgress,0f, MySoundCuesEnum.SfxProgressBuild, MySoundCuesEnum.SfxCancelBuild, MyGameControlEnums.USE, 0, 3000, 0);
            m_useProgress.OnCanceled += OnCanceledHandler;
            m_useProgress.OnSuccess += OnSuccessHandler;

            SetupMotherships();
            SetUpTurrets();

            base.Load();
        }