Beispiel #1
0
        protected override void OnClick()
        {
            TroopRoster prisonRoster = MobileParty.MainParty.PrisonRoster;
            int         num          = 0;
            IRecruitPrisonersCampaignBehavior campaignBehavior = Campaign.Current.GetCampaignBehavior <IRecruitPrisonersCampaignBehavior>();
            CharacterObject bestPrisoner = null;

            while ((bestPrisoner = getBestRecruitablePrisoner()) != null)
            {
                if (MobileParty.MainParty.Party.PartySizeLimit <= MobileParty.MainParty.MemberRoster.TotalManCount)
                {
                    break;
                }

                int recruitableNumber = Campaign.Current.GetCampaignBehavior <IRecruitPrisonersCampaignBehavior>().GetRecruitableNumber(bestPrisoner);
                if (recruitableNumber > 0)
                {
                    int maxRecruitable = MobileParty.MainParty.Party.PartySizeLimit - MobileParty.MainParty.MemberRoster.TotalManCount;
                    recruitableNumber = Math.Min(recruitableNumber, maxRecruitable);
                    num += recruitableNumber;
                    PartyCommand command = new PartyCommand();
                    command.FillForRecruitTroop(PartyRosterSide.Right, TroopType.Prisoner, bestPrisoner, recruitableNumber);
                    _partyLogic.AddCommand(command);
                }
            }
            InformationManager.DisplayMessage(new InformationMessage("Recruited " + num.ToString() + " prisoners"));
        }
Beispiel #2
0
        private void DailyTick()
        {
            MobileParty mainParty    = MobileParty.MainParty;
            TroopRoster memberRoster = mainParty.MemberRoster;

            if (memberRoster.TotalManCount >= mainParty.Party.PartySizeLimit)
            {
                return;
            }

            TroopRoster prisonRoster = mainParty.PrisonRoster;

            if (prisonRoster.TotalManCount == 0)
            {
                return;
            }

            IRecruitPrisonersCampaignBehavior recruitPrisonerBehavior = Campaign.Current.GetCampaignBehavior <IRecruitPrisonersCampaignBehavior>();

            if (recruitPrisonerBehavior == null)
            {
                return;
            }

            List <Tuple <CharacterObject, int> > recruitablePrisoners = new List <Tuple <CharacterObject, int> >();

            for (int i = 0; i < prisonRoster.Count; i++)
            {
                CharacterObject prisoner       = prisonRoster.GetCharacterAtIndex(i);
                int             numRecruitable = recruitPrisonerBehavior.GetRecruitableNumber(prisoner);

                if (numRecruitable > 0)
                {
                    recruitablePrisoners.Add(new Tuple <CharacterObject, int>(prisoner, numRecruitable));
                }
            }

            recruitablePrisoners.Sort((x, y) => y.Item1.Tier.CompareTo(x.Item1.Tier));

            for (int i = 0; i < recruitablePrisoners.Count; i++)
            {
                CharacterObject prisoner       = recruitablePrisoners[i].Item1;
                int             numRecruitable = recruitablePrisoners[i].Item2;
                while (numRecruitable > 0)
                {
                    recruitPrisonerBehavior.SetRecruitableNumber(prisoner, --numRecruitable);
                    prisonRoster.AddToCounts(prisoner, -1, false, 0, 0, true, -1);
                    mainParty.MemberRoster.AddToCounts(prisoner, 1, false, 0, 0, true, -1);
                    if (memberRoster.TotalManCount >= mainParty.Party.PartySizeLimit)
                    {
                        break;
                    }
                }
                if (memberRoster.TotalManCount >= mainParty.Party.PartySizeLimit)
                {
                    break;
                }
            }
        }