void NavigateFromStart(AuroraDLG.AStarting start) { Debug.Log("Navigating from start"); // Find the entry this start points to curEntry = GetEntry((int)start.Index); mode = DialogState.CHOOSING_REPLY; }
void ToChooseReply(AuroraDLG.AReply.AEntries replyEntry) { Debug.Log("Navigating from reply"); curEntry = GetEntry((int)replyEntry.Index); curReply = null; mode = DialogState.CHOOSING_REPLY; }
void EntryView() { switch (mode) { case DialogState.STARTING: // Show the list of starting nodes foreach (AuroraDLG.AStarting start in dlg.StartingList) { AuroraDLG.AEntry entry = GetEntry((int)start.Index); string startLine = "null"; startLine = AuroraEngine.Resources.GetString(entry.Text); if (GUILayout.Button(startLine)) { if (Event.current.button == 1) { SelectedStart(start); } else { NavigateFromStart(start); } } } break; case DialogState.CHOOSING_REPLY: // Show the last line of dialog said by the PC string line = AuroraEngine.Resources.GetString(curEntry.Text); GUILayout.Label(line); break; case DialogState.CHOOSING_ENTRY: // The player is choosing their dialog option // Show the list of replies to the current entry if (curReply == null) { return; } foreach (AuroraDLG.AReply.AEntries link in curReply.EntriesList) { AuroraDLG.AEntry entry = GetEntry((int)link.Index); string linkLine = AuroraEngine.Resources.GetString(entry.Text); if (GUILayout.Button(linkLine)) { if (Event.current.button == 1) { SelectedReplyEntry(link); SelectedEntry(entry); } else { ToChooseReply(link); } } } break; } }
public void LoadDLG(AuroraDLG dlg) { curEntry = null; curReply = null; this.dlg = dlg; mode = DialogState.STARTING; }
void StartDialog(AuroraDLG dlg, AuroraObject owner) { // TODO: Find the appropriate starting point by running // the relevant NCS scripts dialogue = dlg; if (owner.GetType() == typeof(Creature)) { ((Creature)owner).OnDialogue(); } AuroraDLG.AStarting starter = null; foreach (AuroraDLG.AStarting option in dlg.StartingList) { string scriptName = option.Active; if (scriptName == "") { starter = option; break; } if (stateManager.RunConditionalScript(scriptName, owner) > 0) { starter = option; break; } } if (starter == null) { // Could not find a starter throw new System.Exception("Failed to find a successful starting option for dialog"); } AuroraDLG.AEntry startEntry = dlg.EntryList[(int)starter.Index]; Debug.Log("Start entry: " + startEntry); curEntry = startEntry; if (curEntry.Script != "") { stateManager.RunScript(curEntry.Script, owner); } curMode = DialogMode.NPC; this.owner = owner; }
void SelectedEntry(AuroraDLG.AEntry entry) { // The user selected an entry, so show all relevant replies curEditing = entry; }
void BackToStart() { curEntry = null; curReply = null; mode = DialogState.STARTING; }
void MoveFromReply(int idx) { curReply = dialogue.ReplyList[(int)replies[idx].Index]; Debug.Log((int)replies[idx].Index); //Debug.Log(curReply.id); if (curReply.Script != null && curReply.Script != "") { stateManager.RunScript(curReply.Script, stateManager.PC); } if (curReply.EntriesList.Count == 0) { // Dialog is finished EndDialog(); return; } curMode = DialogMode.NPC; // Get the next line of NPC dialog // TODO: Use conditional logic here by calling NCS scripts foreach (AuroraDLG.AReply.AEntries rply in curReply.EntriesList) { if (rply.Active == "") { curEntry = dialogue.EntryList[(int)rply.Index]; break; } NCSScript script = AuroraEngine.Resources.LoadScript(rply.Active); int value = script.RunConditional(new NCSContext(script, script.file)); if (value > 0) { curEntry = dialogue.EntryList[(int)rply.Index]; break; } else { Debug.Log("Conditional " + curEntry.Script + " failed"); } } // Load the audio AudioClip audio = GetAudioClip(); //LIP lipsync = AuroraEngine.Resources.LoadLipSync(curEntry.VO_ResRef); //if (lipsync != null) //{ // Debug.Log("Lip sync has length " + lipsync.length + " and " + lipsync.frames.Length + " frames"); //} if (audio != null) { Debug.Log("Found audio"); audioSource.clip = audio; audioSource.Play(); timer = audio.length; } else { Debug.Log("Did not find audio"); timer = 0; } if (timer == 0 && curEntry.CameraAnimation > 0) { timer = GetAnimationState().length; } if (curEntry.Delay > 0 && curEntry.Delay < 100000) { timer = curEntry.Delay; } // Run the on-play script for the current line being played if (curEntry.Script != "") { // TODO: Check who is the owner of the script when it's run through RuNScript stateManager.RunScript(curEntry.Script, stateManager.PC); } }
void ConvertDLG() { // The conversion works using the following process: // - For every Entry node: // - If the Speaker attribute is blank, set it to the Speaker string value instead // - For every Reply node: // - Create a new Entry node, and a new Reply node with empty text // - Give the new Entry node the same text as the original Reply node // - Connect the original Reply node to the new Entry node // - Connect the new Entry node to the new Reply node // - Remove all connections from the original Reply node to other Entry nodes, // and connect the new Reply node to those Entry nodes instead // We must do this first, or the speaker will also speak the PC's lines foreach (AuroraDLG.AEntry entry in dlg.EntryList) { if (entry.Speaker == "") { if (entry.Text.stringref > 1000000 && entry.Text.stringcount == 0 && entry.Text.strings.Count == 0) { // This line is blank } else { entry.Speaker = new GFFObject.CExoString() { str = speaker }; } } //if ( // (entry.Script != "" && entry.Speaker.str.ToLower() == speaker.ToLower()) //) //{ // // This entry requires a script to be executed with the original speaker as OBJECT_SELF... // entry.ActionParamStrA = entry.Script; // entry.Script = "og_speak_run"; //} //if ( // (entry.Script2 != "" && entry.Speaker.str.ToLower() == speaker.ToLower()) //) //{ // entry.ActionParamStrB = entry.Script2; // entry.Script2 = "og_speak_run"; //} } foreach (AuroraDLG.AReply reply in new List <AuroraDLG.AReply>(dlg.ReplyList)) { if (reply.Text.stringref > 1000000 && reply.Text.stringcount == 0 && reply.Text.strings.Count == 0) { continue; } if (reply.Text.strings.Count > 0 && reply.Text.strings[0].str == "") { continue; } // Add a new Entry AuroraDLG.AEntry newEntry = new AuroraDLG.AEntry(); newEntry.Text = reply.Text; newEntry.Delay = 4294967295; int newEntryIdx = dlg.EntryList.Count; newEntry.structid = (uint)newEntryIdx; dlg.EntryList.Add(newEntry); // Copy dialog information if (reply.Listener == "") { newEntry.Listener = speaker; } else { newEntry.Listener = reply.Listener; } newEntry.Emotion = reply.Emotion; // Copy camera information newEntry.CameraAngle = reply.CameraAngle; newEntry.CameraID = reply.CameraID; newEntry.CameraAnimation = reply.CameraAnimation; newEntry.CamVidEffect = reply.CamVidEffect; newEntry.CamFieldOfView = reply.CamFieldOfView; newEntry.CamHeightOffset = reply.CamHeightOffset; // Add a new Reply AuroraDLG.AReply newReply = new AuroraDLG.AReply(); newReply.Text = new GFFObject.CExoLocString() { stringref = 4294967295 }; newReply.Delay = 0; int newReplyIdx = dlg.ReplyList.Count; newReply.structid = (uint)newReplyIdx; dlg.ReplyList.Add(newReply); // We set up the chain as follows: // reply -> newEntry -> newReply -> reply.EntriesList // newEntry -> newReply newEntry.RepliesList = new List <AuroraDLG.AEntry.AReplies>() { new AuroraDLG.AEntry.AReplies() { Index = (uint)newReplyIdx } }; // newReply -> reply.EntriesList newReply.EntriesList = new List <AuroraDLG.AReply.AEntries>(reply.EntriesList); // reply -> newEntry reply.EntriesList = new List <AuroraDLG.AReply.AEntries>() { new AuroraDLG.AReply.AEntries() { Index = (uint)newEntryIdx } }; } GetWindow <KDialogEditor>(false, "Dialog Editor", true).dlg = dlg; }
public EntryNode() { entry = new AuroraDLG.AEntry(); }