示例#1
0
        private void HourlyTick(MBCampaignEvent campaignevent, object[] delegateparams)
        {
            currentForageHours++;
            if (currentForageHours < forageHours)
            {
                return;
            }

            int gatheredMeat   = MBRandom.RandomInt(minFoodAmount, maxFoodAmount);
            int gatheredGrapes = MBRandom.RandomInt(minFoodAmount, maxFoodAmount);

            ItemObject grape = MBObjectManager.Instance.GetObject <ItemObject>("grape");
            ItemObject meat  = MBObjectManager.Instance.GetObject <ItemObject>("meat");

            MobileParty.MainParty.ItemRoster.AddToCounts(grape, gatheredGrapes);
            MobileParty.MainParty.ItemRoster.AddToCounts(meat, gatheredMeat);

            Campaign.Current.TimeControlMode = CampaignTimeControlMode.Stop;

            InformationManager.ShowInquiry(new InquiryData(eventTitle, $"Your troop managed to forage {gatheredMeat} slabs of meat and {gatheredGrapes} baskets of grapes!", true, false, "Done", null, null, null), true);

            hourlyTickEvent.Unregister(this);
            hourlyTickEvent = null;

            MobileParty.MainParty.IsActive = true;

            StopEvent();
        }
示例#2
0
        public override void StartEvent()
        {
            if (Settings.GeneralSettings.DebugMode)
            {
                InformationManager.DisplayMessage(new InformationMessage($"Starting {this.RandomEventData.EventType}", RandomEventsSubmodule.textColor));
            }

            List <InquiryElement> inquiryElements = new List <InquiryElement>();

            inquiryElements.Add(new InquiryElement("a", "Order the men to gather some food.", null));
            inquiryElements.Add(new InquiryElement("b", "There's no time.", null));

            MultiSelectionInquiryData msid = new MultiSelectionInquiryData(
                eventTitle,                                                                                                                                                      // Title
                "While traveling you come across a large meadow with grazing deer surrounded by grape vines. If you have some spare time, perhaps you could collect some food.", // Description
                inquiryElements,                                                                                                                                                 // Options
                false,                                                                                                                                                           // Can close menu without selecting an option. Should always be false.
                1,                                                                                                                                                               // Force a single option to be selected. Should usually be true
                "Okay",                                                                                                                                                          // The text on the button that continues the event
                null,                                                                                                                                                            // The text to display on the "cancel" button, shouldn't ever need it.
                (elements) =>                                                                                                                                                    // How to handle the selected option. Will only ever be a single element unless force single option is off.
            {
                if ((string)elements[0].Identifier == "a")
                {
                    Campaign.Current.TimeControlMode = CampaignTimeControlMode.UnstoppableFastForwardForPartyWaitTime;

                    MobileParty.MainParty.IsActive = false;

                    waitPos = MobileParty.MainParty.Position2D;

                    //hourlyTickEvent = CampaignEvents.CreatePeriodicEvent(1f, 0f);
                    hourlyTickEvent = CampaignEvents.CreatePeriodicEvent(CampaignTime.HoursFromNow(1f), CampaignTime.Zero);
                    hourlyTickEvent.AddHandler(new MBCampaignEvent.CampaignEventDelegate(HourlyTick));
                }
                else if ((string)elements[0].Identifier == "b")
                {
                    StopEvent();
                }
                else
                {
                    MessageBox.Show($"Error while selecting option for \"{this.RandomEventData.EventType}\"");
                }
            },
                null);                 // What to do on the "cancel" button, shouldn't ever need it.

            InformationManager.ShowMultiSelectionInquiry(msid, true);
        }
示例#3
0
 public override void CancelEvent()
 {
     hourlyTickEvent.Unregister(this);
     hourlyTickEvent = null;
     MobileParty.MainParty.IsActive = true;
 }
        public static bool DisperseArmy(ref Army __instance, ref bool ____armyIsDispersing, ref List <MobileParty> ____parties, ref MBCampaignEvent ____hourlyTickEvent, Army.ArmyDispersionReason reason = Army.ArmyDispersionReason.Unknown)
        {
            try
            {
                if (____armyIsDispersing)
                {
                    return(false);
                }
                CampaignEventDispatcher.Instance.OnArmyDispersed(__instance, reason, __instance.Parties.Contains(MobileParty.MainParty));
                ____armyIsDispersing = true;
                int num = 0;
                for (int i = __instance.Parties.Count - 1; i >= num; i--)
                {
                    __instance.Parties[i].Army = null;
                }
                ____parties.Clear();
                __instance.Kingdom = null;
                if (__instance.LeaderParty == MobileParty.MainParty)
                {
                    MapState mapState = Game.Current.GameStateManager.ActiveState as MapState;
                    if (mapState != null)
                    {
                        mapState.OnDispersePlayerLeadedArmy();
                    }
                }
                Campaign.Current.DeletePeriodicEvent(____hourlyTickEvent);
                ____armyIsDispersing = false;
            }
            catch (Exception ex)
            {
                InformationManager.DisplayMessage(new InformationMessage($"GCO prevented crash with error {ex.Message}"));
            }

            return(false);
        }
示例#5
0
 public static bool Prefix(MBCampaignEvent campaignEvent)
 {
     return(campaignEvent != null);
 }