Beispiel #1
0
        static void MyFactions_OnFactionStatusChanged(MyMwcObjectBuilder_FactionEnum faction1, MyMwcObjectBuilder_FactionEnum faction2, MyFactionRelationEnum previousRelation, bool display, bool save)
        {
            if (!display)
            {
                return;
            }

            MyTextsWrapperEnum    relationChangeEnum = MyTextsWrapperEnum.General;
            MyFactionRelationEnum newRelation        = MyFactions.GetFactionsRelation(faction1, faction2);

            switch (newRelation)
            {
            case MyFactionRelationEnum.Friend:
                relationChangeEnum = MyTextsWrapperEnum.GlobalEventFactionRelationChange_NeutralToFriends;
                break;

            case MyFactionRelationEnum.Neutral:
                if (previousRelation == MyFactionRelationEnum.Friend)
                {
                    relationChangeEnum = MyTextsWrapperEnum.GlobalEventFactionRelationChange_FriendsToNeutral;
                }
                else
                {
                    relationChangeEnum = MyTextsWrapperEnum.GlobalEventFactionRelationChange_EnemyToNeutral;
                }
                break;

            case MyFactionRelationEnum.Enemy:
                relationChangeEnum = MyTextsWrapperEnum.GlobalEventFactionRelationChange_NeutralToEnemy;
                break;
            }

            MyHudNotification.AddNotification(new MyHudNotification.MyNotification(relationChangeEnum, 5000, null, new object[] { MyFactionConstants.GetFactionProperties(faction1).Name.ToString(), MyFactionConstants.GetFactionProperties(faction2).Name.ToString() }));
        }
 public override void Load()
 {
     base.Load();
     m_remainingTime         = m_submissionDuration;
     m_countdownNotification = new MyHudNotification.MyNotification(MyTextsWrapperEnum.Countdown, (int)m_remainingTime.TotalMilliseconds, null);
     MyHudNotification.AddNotification(m_countdownNotification, MyGuiScreenGamePlayType.GAME_STORY);
 }
Beispiel #3
0
        public void UseFromHackingTool(MySmallShip useBy, int hackingLevelDifference)
        {
            float cashMoveToPlayer = Cash * (0.5f + hackingLevelDifference * 0.1f);

            MySession.Static.Player.Money += cashMoveToPlayer;
            Cash -= cashMoveToPlayer;
            MyHudNotification.AddNotification(
                new MyHudNotification.MyNotification(MyTextsWrapperEnum.YouObtainNotification, MyGuiManager.GetFontMinerWarsGreen(), 5000, null, new object[] { MyMwcUtils.GetFormatedPriceForGame((decimal)cashMoveToPlayer) }));
        }
 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 void Start()
        {
            MyGuiManager.AddScreen(this);

            if (Background && BackgroundNotification.HasValue)
            {
                var notification = new MyHudNotification.MyNotification(BackgroundNotification.Value);
                MyHudNotification.AddNotification(notification);
                this.Closed += (screen) => notification.Disappear();
            }
        }
Beispiel #6
0
 public void Start()
 {
     if (m_hudNotification != null)
     {
         if (m_hudNotification.IsDisappeared())
         {
             m_hudNotification.Appear();
         }
         MyHudNotification.AddNotification(m_hudNotification);
     }
 }
Beispiel #7
0
        public static void ShowObjectiveCompleted()
        {
            var notification = new MyHudNotification.MyNotification(
                MyTextsWrapperEnum.NotificationObjectiveComplete,
                MyHudNotification.GetCurrentScreen(),
                .85f,
                MyHudConstants.MISSION_FONT,
                MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                15000); // TODO constant

            MyHudNotification.AddNotification(notification);
        }
Beispiel #8
0
 public void Display(object[] parameters)
 {
     if (Text != null)
     {
         MyGuiFont font = GetFontDelegate();
         MyHudNotification.MyNotification notification = new MyHudNotification.MyNotification(Text.Value, font, 5000, null, parameters);
         MyHudNotification.AddNotification(notification);
     }
     if (SoundCue != null)
     {
         MyAudio.AddCue2D(SoundCue.Value);
     }
 }
Beispiel #9
0
 public override void Load()
 {
     base.Load();
     if (m_isOn)
     {
         m_countdownNotification             = new MyHudNotification.MyNotification(NotificationText, MyGuiManager.GetFontMinerWarsBlue(), (int)RemainingTime.TotalMilliseconds, null);
         m_countdownNotification.IsImportant = true;
         if (DisplayCounter)
         {
             MyHudNotification.AddNotification(m_countdownNotification);
         }
     }
 }
Beispiel #10
0
 public void Suspend(bool isOn)
 {
     if (isOn && !m_isOn)
     {
         m_countdownNotification             = new MyHudNotification.MyNotification(NotificationText, (int)RemainingTime.TotalMilliseconds);
         m_countdownNotification.IsImportant = true;
         if (DisplayCounter)
         {
             MyHudNotification.AddNotification(m_countdownNotification);
         }
     }
     m_isOn = isOn;
 }
Beispiel #11
0
        public MyServerAction SaveLastCheckpoint(bool createChapter = false)
        {
            if (MyMultiplayerGameplay.IsRunning && !MyMultiplayerGameplay.Static.IsHost)
            {
                return(null);
            }

            var lastChapterTime = MyLocalCache.GetLastChapterTimestamp();
            var nextChapterTime = lastChapterTime + TimeSpan.FromHours(3);

            if (MyMissions.ActiveMission == null && DateTime.Now > nextChapterTime)
            {
                createChapter = true;
            }

            MyMwcSectorIdentifier sectorId = MyGuiScreenGamePlay.Static.GetSectorIdentifier();

            if (CanBeSaved(false, sectorId, false))
            {
                var notification = new MyHudNotification.MyNotification(Localization.MyTextsWrapperEnum.SavingSectorToServer, 2500);
                MyHudNotification.AddNotification(notification);

                var checkpoint = GetCheckpointBuilder(true);
                checkpoint.CurrentSector.UserId = MyClientServer.LoggedPlayer.GetUserId(); // Saving players checkpoint

                if (MySession.PlayerShip != null && checkpoint.PlayerObjectBuilder.ShipObjectBuilder != null)
                {
                    float refilRatio = 0.5f;

                    var ship = checkpoint.PlayerObjectBuilder.ShipObjectBuilder;
                    ship.ArmorHealth     = MathHelper.Clamp(ship.ArmorHealth, refilRatio * MySession.PlayerShip.MaxArmorHealth, MySession.PlayerShip.MaxArmorHealth);
                    ship.ShipHealthRatio = MathHelper.Clamp(ship.ShipHealthRatio, refilRatio, 1.0f);
                    ship.Fuel            = MathHelper.Clamp(ship.Fuel, refilRatio * MySession.PlayerShip.MaxFuel, MySession.PlayerShip.MaxFuel);
                    ship.Oxygen          = MathHelper.Clamp(ship.Oxygen, refilRatio * MySession.PlayerShip.MaxOxygen, MySession.PlayerShip.MaxOxygen);
                    checkpoint.PlayerObjectBuilder.Health = MathHelper.Clamp(checkpoint.PlayerObjectBuilder.Health, refilRatio * 100, 100);
                }

                // Need to store actual checkpoint...because when we travel, we receive only sector, not checkpoint
                MyGuiScreenGamePlay.Static.AddEnterSectorResponse(checkpoint, null);

                Debug.Assert(checkpoint.CurrentSector.UserId != null, "Saving last checkpoint as story");
                UpdatePlayerStartDummy(checkpoint);

                MyLocalCache.SaveCheckpoint(checkpoint, createChapter);
                checkpoint.SectorObjectBuilder = null; // Don't save sector
            }
            return(null);
        }
        public override bool IsSuccess()
        {
            m_isNearLocation = base.IsSuccess() || IsNearRealLocation();
            if (m_isNearLocation)
            {
                m_notification.SetTextFormatArguments(new object[] { MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.USE) });
                m_notification.Appear();
                MyHudNotification.AddNotification(m_notification);
            }
            else
            {
                m_notification.Disappear();
            }

            return(false);
        }
Beispiel #13
0
        private MyGuiScreenEditorSaveProgress Save(bool saveSector, string checkpointName, bool asTemplate, bool visibleSave, bool pause)
        {
            MyMwcSectorIdentifier sectorId = MyGuiScreenGamePlay.Static.GetSectorIdentifier();
            bool isEditor = MyGuiScreenGamePlay.Static.IsEditorActive();

            if (CanBeSaved(asTemplate, sectorId, isEditor))
            {
                MyMwcObjectBuilder_Checkpoint checkpoint = GetCheckpointBuilder(saveSector);
                checkpoint.CheckpointName = checkpointName;

                // Need to store actual checkpoint...because when we travel, we receive only sector, not checkpoint
                MyGuiScreenGamePlay.Static.AddEnterSectorResponse(checkpoint, null);

                bool savePlayerShip = MyGuiScreenGamePlay.Static.GetGameType() == MyGuiScreenGamePlayType.EDITOR_STORY ? MyEditor.SavePlayerShip : true;

                if (savePlayerShip && saveSector)
                {
                    UpdatePlayerStartDummy(checkpoint);
                }

                MyHudNotification.MyNotification notification = null;
                if (!visibleSave)
                {
                    notification = new MyHudNotification.MyNotification(Localization.MyTextsWrapperEnum.SavingSectorToServer, 2500);
                    MyHudNotification.AddNotification(notification);
                }

                StringBuilder errors = null;
                if (isEditor)
                {
                    errors = CheckMissingObject(checkpoint);
                }

                MyGuiScreenEditorSaveProgress screen = new MyGuiScreenEditorSaveProgress(sectorId, checkpoint, savePlayerShip, visibleSave, pause);
                //screen.Closed += new MyGuiScreenBase.ScreenHandler((s) => { if (notification != null) notification.Disappear(); });

                CheckErrors(errors, screen);
                return(screen);
            }

            return(null);
        }
        public override void UpdateBeforeSimulation()
        {
            base.UpdateBeforeSimulation();

            if (IsDust || IsSound)
            {
                float influence = CalculateInfluenceStrength(MyCamera.Position);
                if (m_influenceStrengthCamera != influence)
                {
                    if (IsDust)
                    {
                        ChangeDustColor(influence);
                    }
                    if (IsSound)
                    {
                        ChangeSound(influence);
                    }
                    m_influenceStrengthCamera = influence;
                }

                #region DEBUGING
                if (MyFakes.ENABLE_DEBUG_INFLUENCE_SPHERES_SOUNDS && IsSound)
                {
                    if (influence > 0f)
                    {
                        if (influence > m_nearestInfluenceSphereStrength)
                        {
                            m_nearestInfluenceSphere = this;
                            if (m_notification == null)
                            {
                                m_notification = new MyHudNotification.MyNotification(m_nearestInfluenceSphere.m_cueEnum.ToString() + ":" + (int)m_maxVolume, MyGuiManager.GetFontMinerWarsBlue());
                                MyHudNotification.AddNotification(m_notification);
                            }
                        }
                    }
                    else
                    {
                        if (m_nearestInfluenceSphere == this)
                        {
                            m_nearestInfluenceSphere         = null;
                            m_nearestInfluenceSphereStrength = 0f;
                            if (m_notification != null)
                            {
                                m_notification.Disappear();
                                m_notification = null;
                            }
                        }
                    }
                }
                #endregion
            }

            if (IsRadioactivity)
            {
                float influence = CalculateInfluenceStrength(MySession.PlayerShip.GetPosition());
                if (m_influenceStrengthShip != influence)
                {
                    ChangeRadioactivity(influence);
                    m_influenceStrengthShip = influence;
                }
            }
        }
Beispiel #15
0
        //  Called when we finished harvesting current voxel
        void StartReleaseVoxel()
        {
            if (m_parentMinerShip == null || m_parentMinerShip.IsDead() || m_parentMinerShip.Inventory == null)
            {
                return;
            }

            StartImplodeCue();
            BoundingSphere explosion = new BoundingSphere(m_headPositionTransformed, MyVoxelConstants.VOXEL_SIZE_IN_METRES * 1);

            //remove decals
            MyDecals.HideTrianglesAfterExplosion(m_inVoxelMap, ref explosion);
            //cut off

            var minedMaterialsWithContents = MyVoxelGenerator.CutOutSphereFastWithMaterials(m_inVoxelMap, explosion);

            var dustEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Harvester_Finished);

            dustEffect.WorldMatrix = Matrix.CreateTranslation(m_headPositionTransformed);

            bool hudHarvestingCompletePlayed = false;
            bool harvestingFinishedAsyncSent = false;

            var minedOres = new Dictionary <int, float>();

            foreach (var minedMaterialWithContent in minedMaterialsWithContents)
            {
                MyOreRatioFromVoxelMaterial[] oreFromVoxel = MyVoxelMapOreMaterials.GetOreFromVoxelMaterial(minedMaterialWithContent.Key);
                if (oreFromVoxel != null && this.Parent == MySession.PlayerShip)
                {
                    // accumulate amounts of the same type
                    foreach (MyOreRatioFromVoxelMaterial oreRatio in oreFromVoxel)
                    {
                        float amount    = minedMaterialWithContent.Value * oreRatio.Ratio * MyHarvestingTubeConstants.MINED_CONTENT_RATIO;
                        float oldAmount = 0;
                        minedOres.TryGetValue((int)oreRatio.OreType, out oldAmount);
                        minedOres[(int)oreRatio.OreType] = amount + oldAmount;
                    }

                    if (!harvestingFinishedAsyncSent)
                    {
                        try
                        {
                            // Disabled, still unused on server
                            //var client = MySectorServiceClient.GetCheckedInstance();
                            //client.HarvestingFinishedAsync(minedMaterialWithContent.Key, (byte)(minedMaterialWithContent.Value * MyVoxelConstants.VOXEL_CONTENT_FULL_FLOAT));
                        }
                        catch (Exception)
                        {
                            Debug.Fail("Cannot send harvesting to server");
                        }
                        harvestingFinishedAsyncSent = true;
                    }

                    if (!hudHarvestingCompletePlayed)
                    {
                        hudHarvestingCompletePlayed = true;
                        MyAudio.AddCue2D(MySoundCuesEnum.HudHarvestingComplete);
                    }
                }
            }


            bool inventoryFullWarningPlayed = false;

            // add ores to inventory
            foreach (var ore in minedOres)
            {
                float amountLeft = m_parentMinerShip.Inventory.AddInventoryItem(MyMwcObjectBuilderTypeEnum.Ore, ore.Key, ore.Value, false);

                float amountAdded = ore.Value - amountLeft;
                if (amountAdded > 0f)
                {
                    MyHudNotification.AddNotification(new MyHudNotification.MyNotification(MyTextsWrapperEnum.HarvestNotification, 3500, textFormatArguments: new object[]
                    {
                        amountAdded,
                        ((MyGuiOreHelper)MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.Ore, ore.Key)).Name
                    }
                                                                                           ));
                }

                if (amountLeft > 0f)
                {
                    MyHudNotification.AddNotification(new MyHudNotification.MyNotification(MyTextsWrapperEnum.HarvestNotificationInventoryFull, MyGuiManager.GetFontMinerWarsRed(), 3500,
                                                                                           textFormatArguments: new object[]
                    {
                        amountLeft,
                        ((MyGuiOreHelper)MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.Ore, ore.Key)).Name
                    }
                                                                                           ));
                    if (!inventoryFullWarningPlayed)
                    {
                        MyAudio.AddCue2D(MySoundCuesEnum.HudInventoryFullWarning);
                        inventoryFullWarningPlayed = true;
                    }
                }
            }

            StartReturningBack();
        }
Beispiel #16
0
        static MyGlobalEvents()
        {
            m_globalEvents[(int)MyGlobalEventEnum.SunWind] =
                new MyGlobalEvent(
                    Type : MyGlobalEventEnum.SunWind,
                    Name : MyTextsWrapperEnum.GlobalEventSunWindName,
                    Description : MyTextsWrapperEnum.GlobalEventSunWindDescription,
                    RatePerHour : 12.0f,
                    Icon : null,
                    Enabled : true,
                    Action : delegate(object o, EventArgs e)
            {
                //dont allow sunwind in god editor on or when the game is paused
                if (!MySunWind.IsActive && !(MyGuiScreenGamePlay.Static.IsEditorActive() && !MyGuiScreenGamePlay.Static.IsIngameEditorActive()) && !MyMinerGame.IsPaused())
                {
                    //MyHudNotification.AddNotification(new MyHudNotification.MyNotification(MyTextsWrapperEnum.GlobalEventSunWindDescription, 5000));
                    MySunWind.Start();
                    //MyAudio.AddCue2D(MySoundCuesEnum.HudSolarFlareWarning);
                }
            },
                    WriteToEventLog: false
                    );

            m_globalEvents[(int)MyGlobalEventEnum.FractionStatusChange] =
                new MyGlobalEvent(
                    Type : MyGlobalEventEnum.FractionStatusChange,
                    Name : MyTextsWrapperEnum.GlobalEventFactionChangeName,
                    Description : MyTextsWrapperEnum.GlobalEventFactionChangeDescription,
                    RatePerHour : 10.0f,
                    Icon : null,
                    Enabled : false,
                    Action : delegate(object o, EventArgs e)
            {
                float statusChange = MyMwcUtils.GetRandomFloat(MyFactions.RELATION_WORST, MyFactions.RELATION_BEST) / 10.0f;

                int[] enumValues = MyMwcFactionsByIndex.GetFactionsIndexes();
                System.Diagnostics.Debug.Assert(enumValues.Length > 3);

                MyMwcObjectBuilder_FactionEnum faction1;
                do
                {
                    faction1 = MyMwcFactionsByIndex.GetFaction(MyMwcUtils.GetRandomInt(enumValues.Length));
                }while (faction1 == MyMwcObjectBuilder_FactionEnum.None);

                MyMwcObjectBuilder_FactionEnum faction2;
                do
                {
                    faction2 = MyMwcFactionsByIndex.GetFaction(MyMwcUtils.GetRandomInt(enumValues.Length));
                }while ((faction1 == faction2) || (faction2 == MyMwcObjectBuilder_FactionEnum.None));

                MyFactions.ChangeFactionStatus(faction1, faction2, statusChange);
            },
                    WriteToEventLog: false
                    );

            m_globalEvents[(int)MyGlobalEventEnum.MeteorWind] =
                new MyGlobalEvent(
                    Type : MyGlobalEventEnum.SunWind,
                    Name : MyTextsWrapperEnum.GlobalEventMeteorWindName,
                    Description : MyTextsWrapperEnum.GlobalEventSunWindDescription,
                    RatePerHour : MyFakes.ENABLE_RANDOM_METEOR_SHOWER ? 1.0f : 0.0f,
                    Icon : null,
                    Enabled : false,
                    Action : delegate(object o, EventArgs e)
            {
                //dont allow sunwind in god editor on or when the game is paused
                if (!(MyGuiScreenGamePlay.Static.IsEditorActive() && !MyGuiScreenGamePlay.Static.IsIngameEditorActive()) && !MyMinerGame.IsPaused())
                {
                    //MyHudNotification.AddNotification(new MyHudNotification.MyNotification(MyTextsWrapperEnum.GlobalEventSunWindDescription, 5000));
                    MyMeteorWind.Start();
                    //MyAudio.AddCue2D(MySoundCuesEnum.SfxSolarFlareWarning);
                }
            },
                    WriteToEventLog: false
                    );


            // todo implement localization strings
            m_globalEvents[(int)MyGlobalEventEnum.IceStorm] =
                new MyGlobalEvent(
                    Type : MyGlobalEventEnum.IceStorm,
                    Name : MyTextsWrapperEnum.GlobalEventIceStormName,              //Name: MyTextsWrapperEnum.GlobalEvent_IceStorm_Name,
                    Description : MyTextsWrapperEnum.GlobalEventSunWindDescription, //IceStorm_Description,
                    RatePerHour : MyFakes.ENABLE_RANDOM_ICE_STORM ? 1.0f : 0.0f,
                    Icon : null,
                    Enabled : false,
                    Action : delegate(object o, EventArgs e)
            {
                //dont allow sunwind in god editor on or when the game is paused
                if (!(MyGuiScreenGamePlay.Static.IsEditorActive() && !MyGuiScreenGamePlay.Static.IsIngameEditorActive()) && !MyMinerGame.IsPaused())
                {
                    MyHudNotification.AddNotification(new MyHudNotification.MyNotification(MyTextsWrapperEnum.GlobalEventSunWindDescription, 5000, null));        // MyHudNotification.AddNotification(new MyHudNotification.MyNotification(MyTextsWrapperEnum.GlobalEvent_IceStorm_Description, 5000));
                    MyIceStorm.Start();
                    MyAudio.AddCue2D(MySoundCuesEnum.HudSolarFlareWarning);
                }
            },
                    WriteToEventLog: false
                    );

            m_globalEvents[(int)MyGlobalEventEnum.IceComet] =
                new MyGlobalEvent(
                    Type : MyGlobalEventEnum.IceComet,
                    Name : MyTextsWrapperEnum.GlobalEventIceCometName,
                    Description : MyTextsWrapperEnum.GlobalEventIceCometDescription,
                    RatePerHour : 0.0f,
                    Icon : null,
                    Enabled : false,
                    Action : delegate(object o, EventArgs e)
            {
                if (!(MyGuiScreenGamePlay.Static.IsEditorActive() && !MyGuiScreenGamePlay.Static.IsIngameEditorActive()) && !MyMinerGame.IsPaused())
                {
                    MyHudNotification.AddNotification(new MyHudNotification.MyNotification(MyTextsWrapperEnum.GlobalEventSunWindDescription, 5000));
                    MyIceComet.Start();
                    MyAudio.AddCue2D(MySoundCuesEnum.HudSolarFlareWarning);
                }
            },
                    WriteToEventLog: false
                    );

            foreach (MyGlobalEvent e in m_globalEvents)
            {
                System.Diagnostics.Debug.Assert(e != null);
            }

            MyFactions.OnFactionStatusChanged += new MyFactionStatusChangeHandler(MyFactions_OnFactionStatusChanged);
        }