public void Construct(DialogueAction action, KeyCode hotkey) { this.action = action; this.hotkey = hotkey; this.text.text = $"{KeyCodes.GetLabel(this.hotkey)}. {this.action.Text}"; }
public DialogueController(RootLine rootLine, GameObject[] speakerGOs, GameObject pcGO, string situation) { currentLine = rootLine; speakers = new DialogueAction[speakerGOs.Length]; speakerMemories = new ArrayList(); for (int i = 0; i < speakerGOs.Length; i++){ GameObject speakerGO = speakerGOs[i]; bool isPC = speakerGO == pcGO; if(!isPC) { speakerMemories.Add(speakerGOs[i].GetComponent("ImpressionMemory")); } GameObject otherSpeakerGO = speakerGOs[0]; if (otherSpeakerGO == speakerGO){ otherSpeakerGO = speakerGOs[1]; } DialogueAction speaker = new DialogueAction(speakerGO, otherSpeakerGO.name, isPC); speakers[i] = speaker; ((ActionRunner)speakerGO.GetComponent("ActionRunner")).ResetRoutine(speaker, false); if (isPC){ pc = speaker; goodbyeLine = GetGoodbyeLine(otherSpeakerGO); } } if(pc != null) { SendActionStarted(); } this.situation = situation; //InitLookingDirections(); currentSpeaker = null; started = false; firstLineSaid = false; }
public void UpdateDialog(DialogueAction action) { UpdateDialog(action.dialog, Globals.campaign.contentLibrary.actorDB.GetData(action.actorID).Name, action.actorID); gameObject.SetActive(true); }
public void UpdateRealScene() { if (dialogueValues.actions[selAction].type == DActionType.SET_TEXT) { DialogueAction.CreateAction(dialogueValues.actions[selAction].type).Act(currentState, dialogueValues.actions[selAction]); } dvc = GameObject.FindObjectOfType <DialogueVisualContainer>(); dvc.background.UpdateBackground(); for (int i = 0; i < dvc.characters.Length; i++) { dvc.characters[i].UpdateCharacter(); } dvc.textBox.text = dvc.currentDialogueText.value; dvc.musicText.text = (dvc.currentMusic.value) ? dvc.currentMusic.value.name : "[NO MUSIC]"; }
public void ModifyOnExitAction(DialogueAction action, bool add) { if (add) { if (!_onExitActions.Contains(action)) { Undo.RecordObject(this, "Dialogue Added OnExit Action"); _onExitActions.Add(action); EditorUtility.SetDirty(this); } } else { Undo.RecordObject(this, "Dialogue Removed OnExit Action"); _onExitActions.Remove(action); EditorUtility.SetDirty(this); } }
//adds initial player response options and returns the string of the characters greeting //for conversations started by the character //a speech alert pops up. If the player clicks on it this function is called //Started by a notification public void StartConversation(int convoID, int characterID) { StartCoroutine(DisplayCharacterResponse(conversations[convoID][0].characterResponse)); for (int i = 0; i < conversations[convoID][0].playerOptions.Length; i++) { int responseID = conversations[convoID][0].playerOptions[i]; dialogueDecisionObject.GetComponentsInChildren <Text>()[1].text = conversations[convoID][responseID].responseSummary; DialogueAction dA = dialogueDecisionObject.GetComponent <DialogueAction>(); dA.dialogueMessage = conversations[convoID][responseID].playerResponse; dA.characterID = characterID; dA.messageID = conversations[convoID][responseID].nodeID; dA.convoID = convoID; dA.effect = conversations[convoID][responseID].effect; dA.parameter = conversations[convoID][responseID].parameter1; var dialogueObj = Instantiate(dialogueDecisionObject); dialogueObj.transform.SetParent(dialogueOptionsPanel.transform, false); } }
public void ClearAction() { action = null; actionSet = false; }
private bool SayNextLine() { if (nextLine == null){ Debug.Log("============================= NPC Dialogue is over ========================================="); EndDialogue(); return true; } if (currentSpeaker != null){ currentSpeaker.InterruptLine(); } currentLine = nextLine; currentSpeaker = nextSpeaker; nextLine = null; nextSpeaker = null; //Debug.Log(currentSpeaker.GetActor().name + " says: " + currentLine.GetText().Replace("\n", "\\n")); bool npcNpcDialogue=false; if (pc == null) { npcNpcDialogue=true; } currentSpeaker.SayLine(npcNpcDialogue); firstLineSaid = true; currentLine.PerformConsequence(this, currentSpeaker.GetActor()); if (pc != null){ MoveCamera(); } return false; }
private void ComplainAboutInterruption(DialogueAction interruptedSpeaker) { ArrayList otherSpeakers = new ArrayList(speakers); otherSpeakers.Remove(interruptedSpeaker); DialogueAction complainer = (DialogueAction)otherSpeakers[(int)Random.Range(0, otherSpeakers.Count)]; complainer.StartQuickReaction(new OneLinerAction(complainer.GetActor(), "interrupted", CharacterManager.GetPC())); }
private bool AdvanceToNextLinePC() { ArrayList availableResponses = GetAvailableResponses(currentLine); if (availableResponses.Count == 0){ EndDialogue(); return true; } else if (availableResponses.Count == 1){ nextLine = (Line)availableResponses[0]; nextSpeaker = pc; nextSpeaker.PrepareLine(nextLine); return false; } else { availableResponses.Add(new VariantLine(goodbyeLine)); DialogueGUI.AskNextPCLine(availableResponses); nextSpeaker = pc; return false; } }
private bool AdvanceToNextLineNPC() { ArrayList availableResponses = GetAvailableResponses(currentLine); if (availableResponses.Count == 0){ //Debug.Log("============================= NPC Dialogue should be over ========================================="); return false; } else { nextLine = (Line)availableResponses[Random.Range(0, availableResponses.Count)]; foreach (DialogueAction speaker in speakers){ if (speaker.IsName(nextLine.GetSpeakerName())){ nextSpeaker = speaker; } } nextSpeaker.PrepareLine(nextLine); return false; } }
public void PerformDialogueAction(DialogueAction action) { action.DoDialogueAction(dialogueID, npcId); }
void _HandleNpcDialogue(Dictionary<string, object> props) { // update our idea of the state //QuestLogEntry logEntry = null; NpcId = (OID)props["npcOid"]; dialogue = new Dialogue(); dialogue.dialogueID = (int)props ["dialogueID"]; dialogue.title = (string)props ["title"]; dialogue.text = (string)props ["text"]; dialogue.npcId = NpcId; int numOptions = (int)props["numOptions"]; for (int i = 0; i < numOptions; i++) { DialogueAction action = new DialogueAction(); action.actionType = (string)props ["option" + i + "action"]; action.actionID = (int)props ["option" + i + "actionID"]; action.actionText = (string)props ["option" + i + "text"]; dialogue.actions.Add(action); } // dispatch a ui event to tell the rest of the system string[] args = new string[1]; AtavismEventSystem.DispatchEvent ("DIALOGUE_UPDATE", args); }
public bool OnExitActionsContain(DialogueAction action) { return(_onExitActions.Contains(action)); }
public void SetAction(DialogueAction nAction) { action = nAction; actionSet = action != null; }
bool DrawActionsFoldout(int id, int idOfType) { if (CurrentNodes[idOfType].Action == null) { CurrentNodes[idOfType].SetAction(new DialogueAction()); } bool save = false; DialogueAction currentAction = CurrentNodes[idOfType].Action; DialogueNodeActionsFoldouts[idOfType] = EditorGUILayout.Foldout(DialogueNodeActionsFoldouts[idOfType], currentAction.ToString()); if (DialogueNodeActionsFoldouts[idOfType]) { Rect dummy = EditorGUILayout.BeginVertical(Config.FoldoutInteriorStyle); { currentAction.AdvanceTimeSet = EditorGUILayout.ToggleLeft("Advance Time", currentAction.AdvanceTimeSet); if (currentAction.AdvanceTimeSet) { //rysuj kontrolkÄ™ HurtPlayer save |= DrawAdvanceTimeActionInterior(currentAction); } currentAction.HurtPlayerSet = EditorGUILayout.ToggleLeft("Hurt Player", currentAction.HurtPlayerSet); if (currentAction.HurtPlayerSet) { //rysuj kontrolkÄ™ HurtPlayer save |= DrawHurtPlayerActionInterior(currentAction); } currentAction.HurtPlayerSanitySet = EditorGUILayout.ToggleLeft("Hurt Player's Sanity", currentAction.HurtPlayerSanitySet); if (currentAction.HurtPlayerSanitySet) { save |= DrawHurtPlayerSanityInterior(currentAction); } currentAction.ChangeMusicSet = EditorGUILayout.ToggleLeft("Change Music", currentAction.ChangeMusicSet); if (currentAction.ChangeMusicSet) { save |= DrawChangeMusicInterior(currentAction); } currentAction.ChangeAmbienceSet = EditorGUILayout.ToggleLeft("Change Ambience", currentAction.ChangeAmbienceSet); if (currentAction.ChangeAmbienceSet) { save |= DrawChangeAmbienceInterior(currentAction); } currentAction.GiveItemSet = EditorGUILayout.ToggleLeft("Give Item", currentAction.GiveItemSet); if (currentAction.GiveItemSet) { save |= DrawGiveItemInterior(currentAction); } currentAction.TakeItemSet = EditorGUILayout.ToggleLeft("Take Item", currentAction.TakeItemSet); if (currentAction.TakeItemSet) { save |= DrawTakeItemInterior(currentAction); } currentAction.UseItemSet = EditorGUILayout.ToggleLeft("Use Item", currentAction.UseItemSet); if (currentAction.UseItemSet) { save |= DrawUseItemInterior(currentAction); } currentAction.SpendMoneySet = EditorGUILayout.ToggleLeft("Spend Money", currentAction.SpendMoneySet); if (currentAction.SpendMoneySet) { save |= DrawSpendMoneyInterior(currentAction); } currentAction.AcquireMoneySet = EditorGUILayout.ToggleLeft("Acquire Money", currentAction.AcquireMoneySet); if (currentAction.AcquireMoneySet) { save |= DrawAcquireMoneyInterior(currentAction); } currentAction.UpdateJournalSet = EditorGUILayout.ToggleLeft("Update Journal", currentAction.UpdateJournalSet); if (currentAction.UpdateJournalSet) { save |= DrawUpdateJournalInterior(currentAction); } } EditorGUILayout.EndVertical(); } return(save); }
private DialogueAction ProcessNodeAction() { string line; DialogueAction ActionNode = new DialogueAction(); do { line = GetValidLine(); if(line != null) { if(line[0] == '}') break; else { string[] elements = line.Split('='); switch(elements[0].ToLower()) { case "action": ChoiceOutcome co = ProcessChoiceOutcome(elements[1]); if(co != null) ActionNode.AddAction(co); break; } } } } while(line != null); return ActionNode; }
public void setup() { //Load and save important data. //Setup Dialogue outputs allNpcNames = new string[(int)Subject.MaxValue] { "Cindy", "Charly", "Darol" }; allNpcStartingDialogue = new int[(int)Subject.MaxValue] { 0, 2, 4 }; const int MaxConvoNum = 6; int convo, sentence; int testSet; allSceneDialogue_speech = new Output[MaxConvoNum][]; allSceneDialogue_functions = new AfterFunc[MaxConvoNum][]; allSceneDialogue_menus = new DialogueMenuData[MaxConvoNum]; allSceneDialogue_actions = new DialogueAction[MaxConvoNum]; convo = 0; sentence = 0; allSceneDialogue_speech[convo] = new Output[3]; allSceneDialogue_speech[convo][sentence++] = new Output((int)Subject.Cindy, "Oh hi"); allSceneDialogue_speech[convo][sentence++] = new Output(MeId, "Hey"); allSceneDialogue_speech[convo][sentence++] = new Output((int)Subject.Cindy, "... Why are you here?"); testSet = allSceneDialogue_speech[convo][allSceneDialogue_speech[convo].Length - 1].m_subjectId;//Check that all sentences have been set. allSceneDialogue_functions[convo] = new AfterFunc[] { new AfterFunc((int)Subject.Cindy, 1, 0, null) }; allSceneDialogue_menus[convo] = new DialogueMenuData(MenuResultInstruct.SaveToPlayerPrefs_Int, new DialogueMenuOption[] { new DialogueMenuOption(5, "To say hi to you", new SpeechSaveData(SaveL_sayHiToCindy, 0)) }); convo = 1; sentence = 0; allSceneDialogue_speech[convo] = new Output[1]; allSceneDialogue_speech[convo][sentence++] = new Output((int)Subject.Cindy, "I'm still thinking."); testSet = allSceneDialogue_speech[convo][allSceneDialogue_speech[convo].Length - 1].m_subjectId;//Check that all sentences have been set. allSceneDialogue_functions[convo] = new AfterFunc[] { new AfterFunc((int)Subject.Charly, 3, 0, null) }; convo = 2; sentence = 0; allSceneDialogue_speech[convo] = new Output[1]; allSceneDialogue_speech[convo][sentence++] = new Output((int)Subject.Charly, "Sup bud"); testSet = allSceneDialogue_speech[convo][allSceneDialogue_speech[convo].Length - 1].m_subjectId;//Check that all sentences have been set. allSceneDialogue_functions[convo] = new AfterFunc[] { }; convo = 3; sentence = 0; allSceneDialogue_speech[convo] = new Output[3]; allSceneDialogue_speech[convo][sentence++] = new Output((int)Subject.Charly, "Best not to bother her."); allSceneDialogue_speech[convo][sentence++] = new Output(MeId, "Why?"); allSceneDialogue_speech[convo][sentence++] = new Output((int)Subject.Charly, "Because she's thinking!"); testSet = allSceneDialogue_speech[convo][allSceneDialogue_speech[convo].Length - 1].m_subjectId;//Check that all sentences have been set. allSceneDialogue_functions[convo] = new AfterFunc[] { new AfterFunc((int)Subject.Charly, 2, 0, null) }; convo = 4; sentence = 0; allSceneDialogue_speech[convo] = new Output[4]; allSceneDialogue_speech[convo][sentence++] = new Output((int)Subject.Darol, "Hi "); allSceneDialogue_speech[convo][sentence++] = new Output(MeId, "Wheren't you in the other room?"); allSceneDialogue_speech[convo][sentence++] = new Output((int)Subject.Darol, "Yes"); allSceneDialogue_speech[convo][sentence++] = new Output(MeId, ":/"); testSet = allSceneDialogue_speech[convo][allSceneDialogue_speech[convo].Length - 1].m_subjectId;//Check that all sentences have been set. allSceneDialogue_functions[convo] = new AfterFunc[] { new AfterFunc(-1, -1, NoAnimChange, new SpeechSaveData(SaveL_seeDarolInTwoPlaces, 0)) }; convo = 5; sentence = 0; allSceneDialogue_speech[convo] = new Output[1]; allSceneDialogue_speech[convo][sentence++] = new Output((int)Subject.Cindy, "That's sweet"); testSet = allSceneDialogue_speech[convo][allSceneDialogue_speech[convo].Length - 1].m_subjectId;//Check that all sentences have been set. allSceneDialogue_functions[convo] = new AfterFunc[] { new AfterFunc((int)Subject.Cindy, 1, 0, null) }; }