コード例 #1
0
        public static XmlRewardData GetInstance()
        {
            if (_instance == null)
            {
                _instance = new XmlRewardData();
            }

            return(_instance);
        }
コード例 #2
0
        private void CalculateReward(MBReadOnlyList <MapEventParty> defeatedParties, MapEventParty mapEventPlayerParty)
        {
            foreach (var party in defeatedParties)
            {
                var moneyAmount     = 0;
                var renownAmount    = 0;
                var influenceAmount = 0;
                var partyRewards    = XmlRewardData.GetInstance().PartyRewards;
                var partyReward     = partyRewards.FirstOrDefault(el => party.Party.Id.Contains(el.PartyId));
                if (partyReward != null)
                {
                    foreach (var reward in partyReward.Rewards)
                    {
                        switch (reward.Type)
                        {
                        case RewardType.Influence:
                            if (reward.RenownInfluenceMoneyAmount != null)
                            {
                                influenceAmount = Convert.ToInt32(reward.RenownInfluenceMoneyAmount);
                                mapEventPlayerParty.GainedInfluence += Convert.ToSingle(reward.RenownInfluenceMoneyAmount);
                            }
                            break;

                        case RewardType.Money:
                            if (reward.RenownInfluenceMoneyAmount != null)
                            {
                                moneyAmount = Convert.ToInt32(reward.RenownInfluenceMoneyAmount);
                                mapEventPlayerParty.PlunderedGold += Convert.ToInt32(reward.RenownInfluenceMoneyAmount);
                            }
                            break;

                        case RewardType.Item:
                            if (reward.ItemId != null)
                            {
                                var itemToAdd = Items.All.FirstOrDefault(obj => obj.StringId == reward.ItemId);
                                if (reward.Chance != null)
                                {
                                    if (IsItemGiven(Convert.ToDecimal(reward.Chance)))
                                    {
                                        mapEventPlayerParty.RosterToReceiveLootItems.Add(new ItemRosterElement(itemToAdd, 1));
                                    }
                                }
                            }
                            break;

                        case RewardType.Renown:
                            if (reward.RenownInfluenceMoneyAmount != null)
                            {
                                renownAmount = Convert.ToInt32(reward.RenownInfluenceMoneyAmount);
                                mapEventPlayerParty.GainedRenown += Convert.ToSingle(reward.RenownInfluenceMoneyAmount);
                            }
                            break;
                        }
                    }

                    InformationManager.DisplayMessage(
                        new InformationMessage(
                            $"{mapEventPlayerParty.Party?.LeaderHero?.Name.ToString() ?? Agent.Main.Name} defeated {party.Party.Name} gaining {moneyAmount} denars, {renownAmount} renown and {influenceAmount} influence",
                            Colors.Green
                            )
                        );
                }
            }
        }
コード例 #3
0
 public SpawnRewardBehavior() : base()
 {
     XmlRewardData.GetInstance();
 }