Esempio n. 1
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);
        }