public Rumour UnlockRandomRumour(NPC npcGiving) { List<Rumour> possible = availableRumours.Where(o => o.targetNpc != npcGiving).ToList(); if(possible.Count > 0) { Rumour rumour = possible[Random.Range(0, possible.Count)]; UnlockRumour(npcGiving, rumour); return rumour; } return null; }
public void CompleteRumour(Rumour rumour) { // Remove the rumour from unlockedRumours (Rumour is value so need to search all Keys to find it) foreach(NPC npc in unlockedRumours.Keys) { if(unlockedRumours[npc] == rumour) { unlockedRumours.Remove(npc); break; } } }
// Called from LevelManager to make sure the NPCs have been spawned beforehand public void InitialiseRumours() { availableRumours = new List<Rumour>(); unlockedRumours = new Dictionary<NPC, Rumour>(); List<NPC> availableNpcs = new List<NPC>(TownGenerator.instance.npcSpawner.NpcList); for(int i = 0; i < _rumourData.RumourCount; i++) { NPC npc = availableNpcs[Random.Range(0, availableNpcs.Count)]; Rumour rumour = new Rumour(npc, _rumourData.GetRumourStart(i), _rumourData.GetRumourMid(i), _rumourData.GetRumourEnd(i)); availableRumours.Add(rumour); availableNpcs.Remove(npc); } }
public void UnlockRumour(NPC npcGiving, Rumour rumour) { availableRumours.Remove(rumour); unlockedRumours.Add(npcGiving, rumour); rumour.targetNpc.ShowRumourIndicator(true); }
// Starts coroutines in order to scroll beat text and choices on the screen // success parameter is used for certain choice responses private IEnumerator DoDisplay(BeatData data, bool showAnimations, bool success = false) { if(showAnimations) { HUD.instance.dialogueMenu.SetActive(); yield return _waitInitial; } else { HUD.instance.dialogueMenu.HideChoicesPanel(); } NPC npcSpeaking = PlayerController.instance.npcSpeaking; TextDisplay npcSpeech = HUD.instance.dialogueMenu.NpcSpeechText; npcSpeech.Clear(); while (npcSpeech.IsBusy) { yield return null; } if(data.DisplayTextType == SpeechType.FlatterResponse || data.DisplayTextType == SpeechType.ThreatenResponse || data.DisplayTextType == SpeechType.BribeResponse) { HUD.instance.dialogueMenu.ShowNpcSpeech(data.GetDisplayText(_textData, success), showAnimations); } else if(data.DisplayTextType == SpeechType.RumourStart) { string text; if(success) { text = unlockedRumours[npcSpeaking].StartText; } else if(HasRumourAvailable(npcSpeaking)) { // If there are rumours available but the NPC disposition is too low then give a rejection line text = _textData.GetRandomRumourFail(); } else { // If there aren't any rumours available give a neutral apology text = _textData.GetRandomRumourUnknown(); } HUD.instance.dialogueMenu.ShowNpcSpeech(text, showAnimations); } else if(data.DisplayTextType == SpeechType.RumourEnd) { Rumour rumour = GetRumourForTargetNpc(npcSpeaking); HUD.instance.dialogueMenu.ShowNpcSpeech(rumour.EndText, showAnimations); CompleteRumour(rumour); } else { HUD.instance.dialogueMenu.ShowNpcSpeech(data.GetDisplayText(_textData, npcSpeaking.DispositionType), showAnimations); } // npcSpeech.Display(data.GetDisplayText(npcSpeaking.disposition)); // On the greeting beat wait until the speech has finished before showing the other panels while(npcSpeech.IsBusy) { yield return null; } if(showAnimations) HUD.instance.dialogueMenu.ShowNpcInfo(npcSpeaking); // yield return _wait; // Copy choices from other beat if needed if(data.CopyChoicesFromBeat) { int id = data.BeatIdToCopyFrom; data.Decision = _data.GetBeatById(id).Decision; } // Set choices List<ChoiceData> choices = new List<ChoiceData>();; int correctChoice = Random.Range(0, data.Decision.Count - 1); // -1 to account for the nevermind choice List<string> usedTextLines = new List<string>(); // Keep track of use choice text to avoid getting the same line twice for(int i = 0; i < data.Decision.Count; i++) { data.Decision[i].IsCorrectChoice = i == correctChoice; switch(data.Decision[i].TextType) { case ChoiceTextType.RandomFlatter: string text; do { text = _textData.GetRandomFlattery(npcSpeaking, i == correctChoice); } while(usedTextLines.Contains(text)); usedTextLines.Add(text); data.Decision[i].DisplayText = text; break; case ChoiceTextType.RandomThreaten: do { text = _textData.GetRandomThreaten(npcSpeaking, i == correctChoice); } while(usedTextLines.Contains(text)); usedTextLines.Add(text); data.Decision[i].DisplayText = text; break; case ChoiceTextType.BribeAmount: data.Decision[i].DisplayText = LevelManager.instance.BribeGoldAmount(i) + " gold"; break; case ChoiceTextType.RumourMid: Rumour rumour = GetRumourForTargetNpc(npcSpeaking); if(rumour != null) { data.Decision[i].DisplayText = rumour.MiddleText; choices.Add(data.Decision[i]); } break; } // Add all choices other than rumour as that is handled in the switch if(data.Decision[i].TextType != ChoiceTextType.RumourMid) { choices.Add(data.Decision[i]); } } _currentChoices = choices.ToArray(); HUD.instance.dialogueMenu.ShowChoicesPanel(npcSpeaking, _currentChoices); // for (int count = 0; count < data.Decision.Count; ++count) // { // ChoiceData choice = data.Decision[count]; // npcSpeech.Display(string.Format("{0}: {1}", (count + 1), choice.DisplayText)); // while (npcSpeech.IsBusy) // { // yield return null; // } // } // if(data.Decision.Count > 0) // { // npcSpeech.ShowWaitingForInput(); // } }
//takes in a rumour and a character ID and adds to the outcomes for the day public void DecideOutcome(Rumour r, CharacterID c) { Debug.Log("Rumour: " + r.summary + " to " + c.fullname); }