Exemplo n.º 1
0
 void ToChooseReply(AuroraDLG.AReply.AEntries replyEntry)
 {
     Debug.Log("Navigating from reply");
     curEntry = GetEntry((int)replyEntry.Index);
     curReply = null;
     mode     = DialogState.CHOOSING_REPLY;
 }
Exemplo n.º 2
0
    public void LoadDLG(AuroraDLG dlg)
    {
        curEntry = null;
        curReply = null;

        this.dlg = dlg;
        mode     = DialogState.STARTING;
    }
Exemplo n.º 3
0
    void ReplyView()
    {
        switch (mode)
        {
        case DialogState.STARTING:
            break;

        case DialogState.CHOOSING_REPLY:
            // Show the list of entries for the current reply
            if (curEntry == null)
            {
                return;
            }

            foreach (AuroraDLG.AEntry.AReplies link in curEntry.RepliesList)
            {
                AuroraDLG.AReply reply = GetReply((int)link.Index);
                string           line  = AuroraEngine.Resources.GetString(reply.Text);
                if (GUILayout.Button(line))
                {
                    if (Event.current.button == 1)
                    {
                        SelectedEntryReply(link);
                        SelectedReply(reply);
                    }
                    else
                    {
                        ToChooseEntry(link);
                    }
                }
            }
            break;

        case DialogState.CHOOSING_ENTRY:
            // Show the last line of dialog spoken by the NPC
            break;
        }
    }
Exemplo n.º 4
0
 void SelectedReply(AuroraDLG.AReply reply)
 {
     // The user selected a reply, so show all relevant entries
     curEditing = reply;
 }
Exemplo n.º 5
0
 void ToChooseEntry(AuroraDLG.AEntry.AReplies entryReply)
 {
     Debug.Log("Navigating from entry");
     curReply = GetReply((int)entryReply.Index);
     mode     = DialogState.CHOOSING_ENTRY;
 }
Exemplo n.º 6
0
 void BackToStart()
 {
     curEntry = null;
     curReply = null;
     mode     = DialogState.STARTING;
 }
Exemplo n.º 7
0
    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);
        }
    }
Exemplo n.º 8
0
 public ReplyNode()
 {
     reply = new AuroraDLG.AReply();
 }
Exemplo n.º 9
0
    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;
    }