public RoomVO(RoomVO room) { Name = room.Name; Background = room.Background; Incident = room.Incident ?? _incident?.GetIncident(); Guests = room.Guests == null ? null : new CharacterVO[room.NumGuests]; for (int i = NumGuests - 1; i >= 0; i--) { Guests[i] = new CharacterVO(room.Guests[i]); } if (room.Actions != null) { Actions = new CommodityVO[room.Actions.Length]; for (int i = Actions.Length - 1; i >= 0; i--) { Actions[i] = new CommodityVO(room.Actions[i]); } } if (room.Rewards != null) { Rewards = new CommodityVO[room.Rewards.Length]; for (int i = Rewards.Length - 1; i >= 0; i--) { Rewards[i] = new CommodityVO(room.Rewards[i]); } } }
private void HandleIncident(IncidentVO incident) { if (incident != null && transform.childCount == 0) { Instantiate(IncidentViewPrefab, transform); } }
public override void OnOpen(LocationConfig config) { bool rendezvousMode = AmbitionApp.GetModel <CharacterModel>().CreateRendezvousMode; ParisModel paris = AmbitionApp.Paris; IncidentModel story = AmbitionApp.Story; LocationVO location = paris.SaveLocation(config); _incident = story.GetIncident(config.IntroIncidentConfig?.name); _location = config.name; LocationNameText.text = AmbitionApp.Localize(ParisConsts.LABEL + _location); LocationDescriptionText.text = AmbitionApp.Localize(ParisConsts.DESCRIPTION + _location); LocationImage.sprite = config.LocationModalSprite; GoButtonText.text = AmbitionApp.Localize(rendezvousMode ? ParisConsts.PICK_LOC_BTN_LABEL : ParisConsts.GO_LOC_BTN_LABEL); if (!AmbitionApp.CheckIncidentEligible(_incident) && config.StoryIncidentConfigs != null) { foreach (IncidentConfig icon in config.StoryIncidentConfigs) { if (AmbitionApp.CheckIncidentEligible(icon?.name)) { _incident = story.GetIncident(icon.name); } } } List.SetIncident(_incident); }
private void HandleOption(int option) { CalendarModel model = AmbitionApp.GetModel <CalendarModel>(); IncidentVO incident = model.Incident; if (incident != null) { MomentVO moment = model.Moment; MomentVO[] neighbors = incident.GetNeighbors(moment); if (option < neighbors.Length) { TransitionVO[] transitions = model.Incident.GetLinkData(moment); if (option < transitions.Length) // This should be a tautology, but whatever { Array.ForEach(transitions[option].Rewards, AmbitionApp.SendMessage); } model.Moment = neighbors[option]; } else { model.Moment = null; } } Activate(); }
public bool Schedule(IncidentVO incident) { if (incident == null) { return(false); } DateTime date = incident.Date.Equals(default) ? _schedule.Today : incident.Date;
private void QueueIncident(CalendarModel model, IncidentVO incident) { if (!model.IncidentQueue.Contains(incident)) { model.IncidentQueue = new Stack <IncidentVO>(model.IncidentQueue.Append(incident)); } AmbitionApp.SendMessage(incident); }
private void OnEnable() { //hideFlags = HideFlags.DontSave; TODO: This is causing build problems if (Incident == null) { Incident = new IncidentVO(); } _serializedObject = new SerializedObject(this); }
private void HandleEndIncident(string incidentID) { if (incidentID == _incident?.ID) { _incident = null; _animator.SetBool(ACTIVE, false); AmbitionApp.SendMessage(GameMessages.HIDE_HEADER); } }
public override void OnEnter() { PartyModel model = AmbitionApp.GetModel <PartyModel>(); CalendarModel calendar = AmbitionApp.GetModel <CalendarModel>(); IncidentModel story = AmbitionApp.Story; PartyVO party = AmbitionApp.GetModel <PartyModel>().Party; IncidentVO incident = story.GetIncident(party?.IntroIncident); LocalizationModel loc = AmbitionApp.GetModel <LocalizationModel>(); AmbitionApp.Game.Activity = ActivityType.Party; model.Turn = -1; model.Incidents = null; if (party == null) { model.Turns = 0; } else { string[] names = Enum.GetNames(typeof(PartySize)); int index = Array.IndexOf(names, party.Size.ToString()); if (index < 0) { index = 0; } if (index < model.NumTurnsByPartySize.Length) { model.Turns = model.NumTurnsByPartySize[index]; } else { model.Turns = model.NumTurnsByPartySize[model.NumTurnsByPartySize.Length - 1]; } if (party.RequiredIncidents?.Length > model.Turns) { model.Turns = party.RequiredIncidents.Length; } } if (incident == null) { IncidentVO[] incidents = AmbitionApp.Story.GetIncidents(IncidentType.PartyIntro); IncidentVO[] candidates = Array.FindAll(incidents, i => Array.IndexOf(i.Factions, party.Faction) >= 0); if (candidates.Length == 0) { candidates = Array.FindAll(incidents, i => ((i.Factions?.Length ?? 0) == 0 || (i.Factions.Length == 1 && i.Factions[0] == FactionType.None))); } incident = Util.RNG.TakeRandom(candidates); } loc.SetPartyOutfit(AmbitionApp.Inventory.GetEquippedItem(ItemType.Outfit) as OutfitVO); loc.SetParty(party); AmbitionApp.SendMessage(CalendarMessages.SCHEDULE, incident); }
public override void OnEnter() { LocationVO location = AmbitionApp.Paris.GetLocation(); IncidentVO incident = GetLocationIncident(location); AmbitionApp.Game.Activity = ActivityType.Paris; if (incident != null) { incident.Date = AmbitionApp.Calendar.Today; AmbitionApp.SendMessage(CalendarMessages.SCHEDULE, incident); } }
// Incident must be set for the list to populate public void SetIncident(IncidentVO incident) { _incident = incident; if (_incident?.Nodes != null) { _rewards = TraceRewards(0, new List <RewardRange>(), new List <int>()); } if (ListContainer != null) { ListContainer.SetActive(_rewards != null && _rewards.Count > 0); } }
void Start() { IncidentModel model = AmbitionApp.GetModel <IncidentModel>(); _incident = model.Incident; _background.sprite = model.RestoreSavedState(); HandleMoment(model.Moment); if (_incident != null) { int index = Array.IndexOf(_incident.Nodes, model.Moment); TransitionVO[] transitions = _incident.GetLinks(index); HandleTransitions(transitions); } }
public LocationVO SaveLocation(LocationConfig config) { if (config == null) { return(null); } List <string> incidents = new List <string>(); IncidentModel story = AmbitionApp.Story; IncidentVO incident = config.IntroIncidentConfig?.GetIncident(); if (incident != null) { story.Incidents[incident.ID] = incident; story.AddDependency(incident, config.name, IncidentType.Location); } if (config.StoryIncidentConfigs != null) { foreach (IncidentConfig iconfig in config.StoryIncidentConfigs) { incident = iconfig?.GetIncident(); if (incident != null) { incidents.Add(incident.ID); story.Incidents[incident.ID] = incident; story.AddDependency(incident, config.name, IncidentType.Location); } } } return(Locations[config.name] = new LocationVO() { ID = config.name, IntroIncident = config.IntroIncidentConfig?.name, StoryIncidents = incidents.ToArray(), SceneID = config.SceneID, IsOneShot = config.OneShot, IsDiscoverable = config.IsDiscoverable, IsRendezvous = config.IsRendezvous, Requirements = config.Requirements ?? new RequirementVO[0] }); }
public void SetIncident(IncidentVO incident) { _incident = incident; gameObject.SetActive(incident?.Nodes != null); if (incident?.Nodes == null) { return; } int nodeCount = incident.Nodes.Length; List <string> characters = new List <string>(); MomentVO moment; for (int i = 0; i < nodeCount && characters.Count < MAX_PORTRAITS; ++i) { moment = incident.Nodes[i]; SetAvatar(moment.Character1, characters); SetAvatar(moment.Character2, characters); } }
public void Execute(CommodityVO reward) { if (!string.IsNullOrEmpty(reward.ID)) { IncidentModel story = AmbitionApp.Story; IncidentVO incident = story.LoadIncident(reward.ID, IncidentType.Reward); if (incident != null) { CalendarModel calendar = AmbitionApp.GetModel <CalendarModel>(); if (reward.Value >= 0) { incident.Date = calendar.Today.AddDays(reward.Value); } story.Incidents[reward.ID] = incident; if (incident.IsScheduled) { AmbitionApp.SendMessage(CalendarMessages.SCHEDULE, incident); } } } }
public void Execute(CommodityVO reward) { CalendarModel calendar = AmbitionApp.GetModel <CalendarModel>(); IncidentVO incident = calendar.FindIncident(reward.ID); if (incident != null) { if (reward.Value > 0) { calendar.Incident = incident; } else { calendar.Schedule(incident); } } else { UnityEngine.Debug.LogWarning(">> WARNING! The requested incident " + reward.ID + " could not be found!"); } }
public void Execute(LocationPin location) { ParisModel model = AmbitionApp.GetModel <ParisModel>(); model.Location = location; if (location != null) { if (location.Name() == "Home") { model.Location = null; } else { IncidentVO incident = location.IntroIncidentConfig?.Incident; if (location != null && incident != null && (!location.Visited || !incident.OneShot)) { CalendarModel calendar = AmbitionApp.GetModel <CalendarModel>(); calendar.Incident = location.IntroIncidentConfig.Incident; } location.Visited = true; } } }
public static bool CheckIncidentEligible(IncidentVO incident) { if (AmbitionApp.Story.IsComplete(incident?.ID, true)) { return(false); } if (!AmbitionApp.CheckRequirements(incident.Requirements)) { return(false); } if (incident.Chapters?.Length == 0) { return(true); } if (Array.IndexOf(incident.Chapters, AmbitionApp.Game.Chapter) >= 0) { return(true); } return(false); //return !AmbitionApp.Story.IsComplete(incident?.ID, true) //&& AmbitionApp.CheckRequirements(incident.Requirements) //&& (incident.Chapters?.Length == 0 || Array.IndexOf(incident.Chapters, AmbitionApp.Game.Chapter) >= 0); }
public void Execute(string playerID) { GameModel game = AmbitionApp.Game; if (!game.Initialized) { AmbitionApp.Execute <InitGameCmd>(); } IncidentModel incidentModel = AmbitionApp.GetModel <IncidentModel>(); CalendarModel calendar = AmbitionApp.GetModel <CalendarModel>(); AmbitionApp.Execute <InitPlayerCmd, string>(playerID); List <IncidentVO> incidents = new List <IncidentVO>(incidentModel.Incidents.Values); foreach (IncidentVO incident in incidents) { if (incident.IsScheduled) { incidentModel.Schedule(incident, incident.Date); } } IncidentVO incdent = incidentModel.UpdateIncident(); game.Tutorials = new List <string>() { TutorialConsts.TUTORIAL_INCIDENT, TutorialConsts.TUTORIAL_CREDIBILITY, TutorialConsts.TUTORIAL_EXHAUSTION, TutorialConsts.TUTORIAL_PERIL, TutorialConsts.TUTORIAL_ALLEGIANCE, TutorialConsts.TUTORIAL_POWER, TutorialConsts.TUTORIAL_LIVRE }; AmbitionApp.UFlow.Register <IncidentTutorialController>(TutorialConsts.TUTORIAL_INCIDENT); AmbitionApp.UFlow.Invoke(FlowConsts.GAME_CONTROLLER); AmbitionApp.SendMessage(AudioMessages.STOP_MUSIC); }
private bool FindCharacters(IncidentVO incident, HashSet <string> characters) { if (incident?.Nodes == null) { return(false); } HashSet <string> local = new HashSet <string>(); foreach (MomentVO moment in incident.Nodes) { if (!string.IsNullOrEmpty(moment.Character1.Name) && characters.Contains(moment.Character1.Name)) { return(false); } local.Add(moment.Character1.Name); if (!string.IsNullOrEmpty(moment.Character2.Name) && characters.Contains(moment.Character2.Name)) { return(false); } local.Add(moment.Character2.Name); } characters.UnionWith(local); return(true); }
public void Execute(CalendarModel calendar) { IncidentModel story = AmbitionApp.Story; IncidentVO incident = story.Incident; if (incident == null && Util.RNG.Generate(100) < AmbitionApp.Game.PoliticalChance) { string[] incidentIDs = story.Types[IncidentType.Political]; List <IncidentVO> incidents = new List <IncidentVO>(); foreach (string incidentID in incidentIDs) { incident = story.GetIncident(incidentID); if (AmbitionApp.CheckIncidentEligible(incident) && !incident.IsScheduled) { incidents.Add(incident); } } if (incidents.Count > 0) { incident = Util.RNG.TakeRandom(incidents); AmbitionApp.SendMessage(CalendarMessages.SCHEDULE, incident); } } }
private void HandleEndIncident(IncidentVO incident) { _animator.SetBool(ACTIVE, false); }
public static List <CommodityVO> GetRewards(IncidentVO incident) { return(incident != null ? TraceRewards(incident, 0, new List <CommodityVO>(), new List <int>()) : new List <CommodityVO>()); }
private static List <CommodityVO> TraceRewards(IncidentVO incident, int node, List <CommodityVO> rewards, List <int> traversed) { if (traversed.Contains(node) || node >= (incident?.Nodes?.Length ?? 0)) { return(rewards); // Prevent circular references } MomentVO moment = incident.Nodes[node]; CommodityVO item; traversed.Add(node); if (moment.Rewards != null) { foreach (CommodityVO reward in moment.Rewards) { switch (reward.Type) { case CommodityType.Gossip: case CommodityType.Item: rewards.Add(reward.Clone()); break; case CommodityType.Livre: case CommodityType.Peril: case CommodityType.Credibility: item = rewards.Find(r => r.Type == reward.Type); if (item == null) { rewards.Add(reward.Clone()); } else { item.Value += reward.Value; } break; case CommodityType.Favor: item = rewards.Find(r => r.ID == reward.ID); if (item == null) { rewards.Add(reward.Clone()); } else { item.Value += reward.Value; } break; } } } int[] neighbors = incident.GetNeighbors(node); if (neighbors.Length == 0) { return(rewards); } foreach (int neighbor in neighbors) { rewards = TraceRewards(incident, neighbor, rewards, new List <int>(traversed)); } return(rewards); }
public bool LoadParty(string partyID, out PartyVO party) { PartyConfig config = Resources.Load <PartyConfig>(Filepath.PARTIES + partyID); if (config == null) { party = null; Resources.UnloadUnusedAssets(); return(false); } IncidentModel story = AmbitionApp.Story; List <string> incidents = new List <string>(); IncidentVO incident = config.IntroIncident?.GetIncident(); PartyModel model = AmbitionApp.GetModel <PartyModel>(); party = new PartyVO(config.name); party.Size = config.Size == PartySize.None ? PartySize.Trivial : config.Size; party.IntroIncident = incident?.ID; story.AddDependency(incident, config.name, IncidentType.Party); incident = config.ExitIncident?.GetIncident(); party.ExitIncident = incident?.ID; story.AddDependency(incident, config.name, IncidentType.Party); if (config.RequiredIncidents != null) { string[] names = Enum.GetNames(typeof(PartySize)); int index = Array.IndexOf(names, party.Size.ToString()); int numTurns = index < model.NumTurnsByPartySize.Length ? model.NumTurnsByPartySize[index] : model.NumTurnsByPartySize[model.NumTurnsByPartySize.Length - 1]; if (config.RequiredIncidents.Length > numTurns) { numTurns = config.RequiredIncidents.Length; for (int i = model.NumTurnsByPartySize.Length - 1; i > 0; --i) { if (numTurns >= model.NumTurnsByPartySize[i] && i < names.Length) { party.Size = (PartySize)i; break; } } } foreach (IncidentConfig iconfig in config.RequiredIncidents) { incident = iconfig?.GetIncident(); incidents.Add(incident?.ID); story.AddDependency(incident, config.name, IncidentType.Party); } } party.RequiredIncidents = incidents.ToArray(); if (config.SupplementalIncidents != null) { incidents.Clear(); foreach (IncidentConfig iconfig in config.SupplementalIncidents) { incident = iconfig?.GetIncident(); if (incident != null) { incidents.Add(incident?.ID); story.AddDependency(incident, config.name, IncidentType.Party); } } } party.SupplementalIncidents = incidents.ToArray(); if (config.Date > 0) { party.Day = new DateTime(config.Date).Subtract(AmbitionApp.Calendar.StartDate).Days; } party.Faction = config.Faction == FactionType.None ? party.Faction : config.Faction; party.RSVP = config.RSVP == RSVP.Required || party.RSVP == RSVP.Required ? RSVP.Required : party.RSVP == RSVP.New ? config.RSVP : config.RSVP == RSVP.New ? party.RSVP : config.RSVP; if (!string.IsNullOrWhiteSpace(config.Host)) { party.Host = config.Host; } party.Requirements = config.Requirements; party.Map = config.Map?.name; config = null; Resources.UnloadUnusedAssets(); return(true); }
public override void InitializeEditor(SerializedObject serializedObject) { Incident = Incident ?? new IncidentVO(); }
private void HandleIncident(IncidentVO incident) => _incident = incident;
public override void OnEnter() { PartyModel model = AmbitionApp.GetModel <PartyModel>(); IncidentVO[] incidents = new IncidentVO[model.NumRooms]; IncidentModel story = AmbitionApp.Story; if (model.Incidents != null) { incidents = new IncidentVO[model.NumRooms]; for (int i = model.NumRooms - 1; i >= 0; --i) { incidents[i] = story.GetIncident(model.Incidents[i]); } } else { HashSet <string> characters = new HashSet <string>(); if (model.RequiredIncident != null) { int index = RNG.Generate(model.NumRooms); incidents[index] = story.GetIncident(model.RequiredIncident); } else { List <IncidentVO> result = new List <IncidentVO>(); IncidentVO incident; if (model.Party.SupplementalIncidents != null) { string[] shuffle = RNG.Shuffle(model.Party.SupplementalIncidents); foreach (string incidentID in shuffle) { incident = story.GetIncident(incidentID); if (result.Count < model.NumRooms) { if (FindCharacters(incident, characters)) { result.Add(incident); } } } } if (result.Count < model.NumRooms) { incidents = story.GetIncidents(IncidentType.Party); incidents = RNG.Shuffle(incidents); foreach (IncidentVO rand in incidents) { if (AmbitionApp.CheckIncidentEligible(rand) && (rand.Factions?.Length == 0 || Array.IndexOf(rand.Factions, model.Party.Faction) >= 0) && FindCharacters(rand, characters)) { result.Add(rand); } if (result.Count >= model.NumRooms) { break; } } } while (result.Count < model.NumRooms) { result.Add(null); } incidents = RNG.Shuffle(result); } model.Incidents = new string[model.NumRooms]; for (int i = model.NumRooms - 1; i >= 0; --i) { model.Incidents[i] = incidents[i]?.ID; } } AmbitionApp.SendMessage(PartyMessages.SELECT_INCIDENTS, incidents); string title = AmbitionApp.Localize(PartyConstants.PARTY_NAME + model.Party.ID); if (string.IsNullOrEmpty(title)) { title = PartyConstants.PARTY_REASON + model.Party.Faction.ToString().ToLower() + "." + model.Party.phrases[0]; } AmbitionApp.SendMessage(GameMessages.SHOW_HEADER, title); }
public IncidentVO(IncidentVO incident) : this(incident as DirectedGraph <MomentVO, TransitionVO>) { this.Name = incident.Name; this.Date = incident.Date; }