示例#1
0
        public override void OnEnter()
        {
            AmbitionApp.Game.Activity = ActivityType.Evening;
            IncidentModel story  = AmbitionApp.Story;
            GossipModel   gossip = AmbitionApp.Gossip;

            IncidentVO[] incidents;
            IncidentVO   incident;

            if (gossip.GossipActivity > 0 && Util.RNG.Generate(100) < gossip.ReproachChance[gossip.GossipActivity - 1])
            {
                incidents = AmbitionApp.Story.GetIncidents(IncidentType.Caught);
                incident  = TakeRandom(incidents);
                if (incident != null)
                {
                    incident.Date = AmbitionApp.Calendar.Today.AddDays(1);
                    AmbitionApp.SendMessage(CalendarMessages.SCHEDULE, incident);
                }
            }
            gossip.GossipActivity = 0;
            if (AmbitionApp.Game.Perilous)
            {
                incidents = story.GetIncidents(IncidentType.Peril);
                incident  = TakeRandom(incidents);
                if (incident != null)
                {
                    incident.Date = AmbitionApp.Calendar.Today;
                    AmbitionApp.SendMessage(CalendarMessages.SCHEDULE, incident);
                }
            }
            AmbitionApp.Game.Perilous = false;
        }
示例#2
0
        public override void OnOpen(GossipVO gossip)
        {
            GossipModel model = AmbitionApp.Gossip;
            int         day   = AmbitionApp.Calendar.Day;

            _gossip = gossip;
            _price  = model.GetValue(_gossip, day);
            _shift  = model.GetShift(_gossip, day);

            Dictionary <string, string> subs = new Dictionary <string, string>();

            subs["$SHIFTAMOUNT"] = AmbitionApp.Localize("shift_degree." + _shift);
            subs["$GOSSIPNAME"]  = AmbitionApp.Gossip.GetName(_gossip);
            subs["$GOSSIPPRICE"] = _price.ToString("£### ###");
            subs["$CAUGHTODDS"]  = AmbitionApp.Localize("gossip_caught_odds." + AmbitionApp.Gossip.GossipActivity.ToString());
            subs["$FACTION"]     = AmbitionApp.Localize(_gossip.Faction.ToString().ToLower());
            //Performing the substitutions themselves
            BodyText.text = AmbitionApp.Localize(GossipConsts.PEDDLE_INFLUENCE_LOC + DialogConsts.BODY, subs);

            if (gossip.IsPower)
            {
                IncreaseStatText.text = AmbitionApp.Localize(GossipConsts.PEDDLE_INFLUENCE_INC_POWER_LOC, subs)
                                        ?? AmbitionApp.Localize(DialogConsts.DEFAULT_CONFIRM);
                DecreaseStatText.text = AmbitionApp.Localize(GossipConsts.PEDDLE_INFLUENCE_DEC_POWER_LOC, subs)
                                        ?? AmbitionApp.Localize(DialogConsts.DEFAULT_CONFIRM);
            }
            else
            {
                IncreaseStatText.text = AmbitionApp.Localize(GossipConsts.PEDDLE_INFLUENCE_INC_ALLEGIANCE_LOC, subs)
                                        ?? AmbitionApp.Localize(DialogConsts.DEFAULT_CONFIRM);
                DecreaseStatText.text = AmbitionApp.Localize(GossipConsts.PEDDLE_INFLUENCE_DEC_ALLEGIANCE_LOC, subs)
                                        ?? AmbitionApp.Localize(DialogConsts.DEFAULT_CONFIRM);
            }
        }
示例#3
0
        public void Execute(CommodityVO commodity)
        {
            GossipModel model = AmbitionApp.Gossip;

            if (model.Quests.Count >= model.MaxQuests)
            {
                return;
            }

            FactionModel factions = AmbitionApp.GetModel <FactionModel>();
            QuestVO      quest    = new QuestVO();

            CommodityVO[] rewards;
            int           rewardTier = RNG.Generate(2) < 1 ? 0 : RNG.Generate(3) < 2 ? 1 : 2;

            if (!Enum.TryParse <FactionType>(commodity.ID, true, out quest.Faction))
            {
                List <FactionType> factionTypes = new List <FactionType>(factions.Factions.Keys);
                factionTypes.Remove(FactionType.None);
                quest.Faction = RNG.TakeRandom(factionTypes);
            }

            quest.Created = AmbitionApp.Calendar.Day;
            quest.Due     = commodity.Value >= 5
                ? quest.Created + commodity.Value
                : quest.Created + RNG.Generate(5) + RNG.Generate(4) + RNG.Generate(4) + 5;

            rewards      = model.RewardTiers[rewardTier].Rewards;
            quest.Reward = RNG.TakeRandom(rewards);
            AmbitionApp.Localization.SetCurrentQuest(quest);
            AmbitionApp.Gossip.Quests.Add(quest);
            AmbitionApp.Gossip.Broadcast();
        }
示例#4
0
        public static List <RewardItem> CreateRewardListItems(IEnumerable <CommodityVO> commodities, RewardItem listItem)
        {
            List <RewardItem>  result     = new List <RewardItem>();
            List <CommodityVO> rewards    = TallyRewards(commodities);
            GossipModel        model      = AmbitionApp.GetModel <GossipModel>();
            RewardItem         item       = listItem;
            List <string>      duplicates = new List <string>();
            string             gossipName;
            GameObject         obj;
            bool           doCreate;
            CharacterModel characterModel = AmbitionApp.GetModel <CharacterModel>();
            CharacterVO    character;

            foreach (CommodityVO reward in rewards)
            {
                switch (reward.Type)
                {
                case CommodityType.Gossip:
                    gossipName = model.GetName(reward);
                    doCreate   = true;
                    break;

                case CommodityType.Favor:
                    character = characterModel.GetCharacter(reward.ID);
                    doCreate  = character != null &&
                                character.FavoredLocations?.Length + character.OpposedLocations?.Length > 0 &&
                                !duplicates.Contains(reward.ID);
                    if (!doCreate)
                    {
                        duplicates.Add(reward.ID);
                    }
                    break;

                case CommodityType.Livre:
                case CommodityType.Credibility:
                case CommodityType.Peril:
                    doCreate = true;
                    break;

                default:
                    doCreate = false;
                    break;
                }
                if (doCreate)
                {
                    if (item == null)
                    {
                        obj  = GameObject.Instantiate <GameObject>(listItem.gameObject, listItem.transform.parent);
                        item = obj.GetComponent <RewardItem>();
                    }
                    item.Data = reward;
                    item.gameObject.SetActive(true);
                    result.Add(item);
                    item = null;
                }
            }
            listItem.gameObject.SetActive(result.Count > 0);
            return(result);
        }
示例#5
0
        public void Execute(QuestVO quest)
        {
            GossipModel model = AmbitionApp.GetModel <GossipModel>();

            if (model.Quests.Remove(quest))
            {
            }
        }
示例#6
0
        public void Register(Core.ModelSvc modelService)
        {
            GossipModel model = modelService.Register <GossipModel>();

            Array.Sort(Relevance, (a, b) => a.Age.CompareTo(b.Age));
            model.Relevances     = Relevance;
            model.Tiers          = Tiers;
            model.MaxQuests      = MaxQuests;
            model.ReproachChance = ReproachChance;
            model.RewardTiers    = RewardTiers;
        }
示例#7
0
        // Adds new ranges or expands existing ones
        private List <RewardRange> Accumulate(List <RewardRange> ranges, List <RewardRange> rewards)
        {
            List <RewardRange> result = new List <RewardRange>(ranges);
            List <string>      gossip = new List <string>();
            GossipModel        model  = AmbitionApp.GetModel <GossipModel>();
            string             gossipName;
            RewardRange        range;
            CharacterVO        character;
            CommodityVO        commodity;

            foreach (RewardRange reward in rewards)
            {
                switch (reward.Type)
                {
                case CommodityType.Gossip:
                    commodity  = new CommodityVO(CommodityType.Gossip, reward.ID, reward.Low);
                    gossipName = model.GetName(commodity);
                    if (!gossip.Contains(gossipName))
                    {
                        gossip.Add(gossipName);
                        range = new RewardRange(ref commodity);
                        result.Add(range);
                    }
                    break;

                case CommodityType.Favor:
                    character = AmbitionApp.GetModel <CharacterModel>().GetCharacter(reward.ID);
                    if (character?.FavoredLocations?.Length + character?.OpposedLocations?.Length > 0)
                    {
                        UpdateOrAdd(ref result, reward.Type, reward.ID, reward.Low, reward.High);
                    }
                    break;

                case CommodityType.Livre:
                case CommodityType.Credibility:
                case CommodityType.Peril:
                case CommodityType.Servant:
                    UpdateOrAdd(ref result, reward.Type, reward.ID, reward.Low, reward.High, true);
                    break;
                }
            }
            return(result);
        }
示例#8
0
 private void HandleRefresh(GossipModel model) => Refresh();