예제 #1
0
        public override void OnOpen(DateTime date)
        {
            CharacterModel     model = AmbitionApp.GetModel <CharacterModel>();
            GameObject         obj;
            RendezvousListItem item = ListItem;

            AmbitionApp.GetModel <CharacterModel>().CreateRendezvous = null;

            _rendez = new RendezVO()
            {
                Created  = AmbitionApp.Calendar.Day,
                RSVP     = RSVP.New,
                Day      = date.Subtract(AmbitionApp.Calendar.StartDate).Days,
                IsCaller = true
            };

            foreach (CharacterVO character in model.Characters.Values)
            {
                if (character.IsDateable && !character.IsRendezvousScheduled)
                {
                    if (item == null)
                    {
                        obj  = Instantiate(ListItem.gameObject, ListItem.transform.parent);
                        item = obj.GetComponent <RendezvousListItem>();
                    }
                    item?.SetCharacter(character, LiaisonConfig.GetSprite(character.Faction.ToString()));
                    item = null;
                }
            }
        }
예제 #2
0
 public void Reset()
 {
     Characters.Clear();
     CreateRendezvous = null;
     _schedule.Clear();
     Broadcast();
 }
예제 #3
0
 private void HandleRendez(RendezVO rendez)
 {
     if (rendez.Day == AmbitionApp.Calendar.Day)
     {
         HandleCalendarRefresh(AmbitionApp.Calendar);
     }
 }
예제 #4
0
 private void Open(RendezVO rendez)
 {
     if (rendez != null)
     {
         GameObject       obj  = Instantiate(RendezvousInvitationPrefab, DialogParent);
         RendezvousDialog dlog = obj.GetComponent <RendezvousDialog>();
         dlog.Initialize(rendez);
     }
 }
예제 #5
0
        private void HandleRendez(RendezVO rendez)
        {
            EventListItemView item = _pool.Find(i => i.Event == rendez);

            if (item != null)
            {
                item.Event = rendez;
            }
        }
예제 #6
0
        public void SetEvents(PartyVO[] parties, RendezVO[] liaisons)
        {
            RendezVO rendez = liaisons.Length == 0
                ? null
                : Array.Find(liaisons, l => l.IsAttending)
                              ?? Array.Find(liaisons, l => l.RSVP == RSVP.New)
                              ?? liaisons[0];
            PartyVO party1 = parties.Length == 0
                ? null
                : Array.Find(parties, p => p.IsAttending)
                             ?? Array.Find(parties, p => p.RSVP == RSVP.New)
                             ?? parties[0];
            PartyVO party2 = rendez != null
                ? party1
                : Array.Find(parties, p => p != party1);
            bool showRespond = !Array.Exists(parties, p => p.IsAttending) &&
                               !Array.Exists(liaisons, r => r.IsAttending) &&
                               (Array.Exists(parties, p => p.RSVP == RSVP.New) || Array.Exists(liaisons, p => p.RSVP == RSVP.New && !p.IsCaller));

            if (rendez != null)
            {
                party1 = null;
            }

            RespondIndicator.gameObject.SetActive(showRespond);

            // Party2 Icon is centered
            Party2Icon.gameObject.SetActive(party1 != null);
            if (party1 != null)
            {
                Party2Icon.sprite = CalendarSpriteConfig.GetSprite(party1.Faction.ToString());
                Party2RSVPIcon.gameObject.SetActive(party1.RSVP != RSVP.New);
                Party2RSVPIcon.sprite = CalendarSpriteConfig.GetSprite(party1.IsAttending ? ACCEPTED : DECLINED);
            }

            // Party1 Icon is in corner
            Party1Icon.gameObject.SetActive(party2 != null);
            if (party2 != null)
            {
                Party1Icon.sprite = CalendarSpriteConfig.GetSprite(party2.Faction.ToString());
                Party1RSVPIcon.gameObject.SetActive(party2.RSVP != RSVP.New);
                Party1RSVPIcon.sprite = CalendarSpriteConfig.GetSprite(party2.IsAttending ? ACCEPTED : DECLINED);
            }

            // Liaison is centered
            liaisonIcon.gameObject.SetActive(rendez != null);
            if (rendez != null)
            {
                CharacterVO character = AmbitionApp.GetModel <CharacterModel>().GetCharacter(rendez.Character);
                liaisonIcon.sprite = LiaisonConfig.GetSprite(character?.Faction.ToString());
                liaisonResponse.gameObject.SetActive(rendez.RSVP != RSVP.New);
                liaisonResponse.sprite = CalendarSpriteConfig.GetSprite(rendez.IsAttending ? ACCEPTED : DECLINED);
            }
        }
예제 #7
0
        public override void OnEnter()
        {
            CharacterModel  characters = AmbitionApp.GetModel <CharacterModel>();
            List <RendezVO> rendezs    = characters.GetPendingInvitations(true, false);

            if (rendezs.Count > 0)
            {
                RendezVO rendez = rendezs[0];
                AmbitionApp.SendMessage(RendezvousMessages.CREATE_RENDEZVOUS_RESPONSE, rendez);
                AmbitionApp.OpenDialog(DialogConsts.RSVP, new CalendarEvent[] { rendez });
            }
        }
예제 #8
0
        public override void OnEnter()
        {
            CalendarModel cal = AmbitionApp.Calendar;

            PartyVO[] parties = cal.GetOccasions <PartyVO>(cal.Day - 1);
            PartyVO   party   = Array.Find(parties, p => p.RSVP == RSVP.New);

            if (party != null)
            {
                CommodityVO penalty = new CommodityVO(CommodityType.Credibility, AmbitionApp.GetModel <PartyModel>().IgnoreInvitationPenalty);
                Dictionary <string, string> subs = new Dictionary <string, string>();
                LocalizationModel           loc  = AmbitionApp.GetModel <LocalizationModel>();
                party.RSVP           = RSVP.Declined;
                subs["$PARTYNAME"]   = loc.GetPartyName(party);
                subs["$CREDIBILITY"] = penalty.Value.ToString();
                AmbitionApp.OpenDialog(DialogConsts.MISSED_RSVP_DIALOG, subs);
                AmbitionApp.SendMessage(penalty);
            }
            else
            {
                RendezVO[] dates = cal.GetOccasions <RendezVO>(cal.Day - 1);
                RendezVO   date  = Array.Find(dates, d => d.RSVP == RSVP.New);
                if (date != null)
                {
                    CharacterModel characters  = AmbitionApp.GetModel <CharacterModel>();
                    CharacterVO    character   = characters.GetCharacter(date.Character);
                    bool           isPenalized = !date.IsCaller;
                    date.RSVP = RSVP.Declined;
                    if (character != null)
                    {
                        character.LiaisonDay = -1;
                    }
                    AmbitionApp.SendMessage(date);
                    if (isPenalized)
                    {
                        int         penalty      = characters.MissedRendezvousPenalty;
                        CommodityVO favorPenalty = new CommodityVO()
                        {
                            Type  = CommodityType.Favor,
                            ID    = date.Character,
                            Value = penalty
                        };
                        AmbitionApp.SendMessage(favorPenalty);
                        Dictionary <string, string> subs = new Dictionary <string, string>();
                        subs["$SHORTNAME"] = AmbitionApp.GetModel <LocalizationModel>().GetShortName(character, date.Character);
                        subs["$FAVOR"]     = penalty.ToString();
                        AmbitionApp.OpenDialog(DialogConsts.MISSED_RENDEZVOUS_DIALOG, subs);
                    }
                }
            }
        }
예제 #9
0
        public static bool Check(RequirementVO req)
        {
            RendezVO rendez = AmbitionApp.GetEvent() as RendezVO;

            if (rendez == null)
            {
                return(false);
            }

            CharacterModel model     = AmbitionApp.GetModel <CharacterModel>();
            CharacterVO    character = model.GetCharacter(rendez.Character);

            return(RequirementsSvc.Check(req, character?.Favor ?? 0));
        }
예제 #10
0
        public static bool Check(RequirementVO req)
        {
            RendezVO rendez = AmbitionApp.GetEvent() as RendezVO;

            if (rendez == null)
            {
                return(false);
            }

            CharacterModel model = AmbitionApp.GetModel <CharacterModel>();
            int            score = model.GetOutfitFavor(rendez.Character, AmbitionApp.Inventory.GetEquippedItem(ItemType.Outfit) as OutfitVO);

            return(RequirementsSvc.Check(req, score));
        }
예제 #11
0
        public void Execute(CommodityVO commodity)
        {
            CharacterModel model     = AmbitionApp.GetModel <CharacterModel>();
            CharacterVO    character = model.GetCharacter(commodity.ID);

            if (character != null)
            {
                character.Acquainted = commodity.Value > 0;
                model.Broadcast();

                if (!character.IsDateable && character.IsRendezvousScheduled)
                {
                    RendezVO[] rendezs = AmbitionApp.Calendar.GetOccasions <RendezVO>(character.LiaisonDay);
                    RendezVO   rendez  = Array.Find(rendezs, r => r.Character == commodity.ID);
                    AmbitionApp.Calendar.Remove(rendez);
                }
            }
        }
예제 #12
0
        public void Execute(CommodityVO commodity)
        {
            RendezVO rendez = AmbitionApp.GetEvent() as RendezVO;

            if (rendez == null)
            {
                return;
            }

            CharacterModel model  = AmbitionApp.GetModel <CharacterModel>();
            CommodityVO    reward = new CommodityVO()
            {
                Type  = CommodityType.Favor,
                ID    = rendez.Character,
                Value = model.GetOutfitFavor(rendez.Character, AmbitionApp.Inventory.GetEquippedItem(ItemType.Outfit) as OutfitVO)
            };

            AmbitionApp.SendMessage(reward);
        }
예제 #13
0
        public override void OnEnter()
        {
            RendezVO vous = AmbitionApp.Calendar.GetOccasions <RendezVO>()[0];

            AmbitionApp.GetModel <GameModel>().Activity = ActivityType.Rendezvous;
            LocationVO location = AmbitionApp.Paris.GetLocation(vous.Location);
            IncidentVO incident;

            // This will crash if the rendezvous location is badly configured
            foreach (string ID in location.StoryIncidents)
            {
                AmbitionApp.Story.Incidents.TryGetValue(ID, out incident);
                if (incident != null && AmbitionApp.CheckIncidentEligible(incident))
                {
                    AmbitionApp.Story.Schedule(incident);
                    return;
                }
            }

            // TODO: Evaluate Outfit for Rendezvous
        }
예제 #14
0
        public void Execute(DateTime date)
        {
            CalendarModel calendar = AmbitionApp.GetModel <CalendarModel>();
            PartyModel    model    = AmbitionApp.GetModel <PartyModel>();

            PartyVO[]  parties = calendar.GetOccasions <PartyVO>(date);
            RendezVO[] dates   = calendar.GetOccasions <RendezVO>(date);
            if (parties.Length + dates.Length > 0)
            {
                PartyVO  party  = Array.Find(parties, p => p.IsAttending);
                RendezVO rendez = Array.Find(dates, p => p.IsAttending);
                if (party != null)
                {
                    AmbitionApp.OpenDialog(DialogConsts.RSVP, new CalendarEvent[] { party });
                }
                else if (rendez != null)
                {
                    AmbitionApp.OpenDialog(DialogConsts.RSVP, new CalendarEvent[] { rendez });
                }
                else
                {
                    List <CalendarEvent> events = new List <CalendarEvent>(parties);
                    events.AddRange(dates);
                    AmbitionApp.OpenDialog(DialogConsts.RSVP, events.ToArray());
                }
            }
            else if (date.Subtract(calendar.Today).Days >= 1 && AmbitionApp.Paris.Rendezvous.Count > 0)
            {
                CharacterModel cModel = AmbitionApp.GetModel <CharacterModel>();
                foreach (CharacterVO character in cModel.Characters.Values)
                {
                    if (character.IsDateable && !character.IsRendezvousScheduled)
                    {
                        AmbitionApp.OpenDialog(DialogConsts.CREATE_RENDEZVOUS, date);
                        break;
                    }
                }
            }
        }
예제 #15
0
        public void Execute(CalendarModel calendar)
        {
            RendezVO[]     rendezs    = calendar.GetOccasions <RendezVO>(calendar.Day - 1);
            CharacterModel characters = AmbitionApp.GetModel <CharacterModel>();
            CharacterVO    notable;
            ChapterVO      chapter = AmbitionApp.Game.GetChapter();

            // Let down notables who haven't responded to your invitations
            rendezs = Array.FindAll(rendezs, r => r.RSVP == RSVP.New && r.IsCaller);
            foreach (RendezVO rendez in rendezs)
            {
                notable = characters.GetCharacter(rendez.Character);
                if (notable != null)
                {
                    notable.LiaisonDay = -1;
                }
                rendez.RSVP = RSVP.Declined; // The Command penalizes the player; we're avoiding that here
                AmbitionApp.SendMessage(rendez);
            }

            if ((chapter.TrivialPartyChance + chapter.DecentPartyChance + chapter.GrandPartyChance > 0) && (int)(calendar.Today.DayOfWeek) % 7 == 6)
            // For whatever reason, DateTime weeks start on Monday
            {
                List <string>   locations;
                CalendarEvent[] events;
                bool            doSchedule;
                foreach (CharacterVO character in characters.Characters.Values)
                {
                    if (character.IsDateable && character.LiaisonDay < 0 && RNG.Generate(100) < characters.LiaisonChance)
                    {
                        int day = calendar.Day + RNG.Generate(2, 6);
                        events     = AmbitionApp.GetEvents(day);
                        doSchedule = (!Array.Exists(events, e => e is RendezVO) && !Array.Exists(events, e => e.IsAttending));
                        if (!doSchedule)
                        {
                            events     = AmbitionApp.GetEvents(++day);
                            doSchedule = (!Array.Exists(events, e => e is RendezVO) && !Array.Exists(events, e => e.IsAttending));
                        }
                        if (doSchedule)
                        {
                            locations = new List <string>(character.FavoredLocations);
                            if (locations.Count == 0)
                            {
                                locations = new List <string>(AmbitionApp.Paris.Rendezvous);
                                locations.RemoveAll(l => Array.IndexOf(character.OpposedLocations, l) >= 0);
                            }
                            if (locations.Count > 0) // If there's no viable locations, skip it
                            {
                                RendezVO liaison = new RendezVO()
                                {
                                    Created  = -1,
                                    ID       = character.ID,
                                    Day      = day,
                                    Location = RNG.TakeRandom(locations),
                                    RSVP     = RSVP.New,
                                    IsCaller = false
                                };
                                character.LiaisonDay = day;
                                AmbitionApp.SendMessage(CalendarMessages.SCHEDULE, liaison);
                            }
                        }
                    }
                }
            }
        }