Example #1
0
 public void HandleDialogue()
 {
     if (currentLine.GetType() == typeof(DialogueLine))
     {
         DialogueLine line = (DialogueLine)currentLine;
         SetLine(line.Speaker, line.Text);
         return;
     }
     else if (currentLine.GetType() == typeof(DialogueIfBranch))
     {
         DialogueIfBranch ifLine = (DialogueIfBranch)currentLine;
         if (CheckConditions(ifLine.ConditionsToCheck, ifLine.CheckType))
         {
             if (ifLine.TrueLineId == 0)
             {
                 EndDialogue();
                 return;
             }
             currentLine = currentDialogue.FindLineById(ifLine.TrueLineId);
             HandleDialogue();
             return;
         }
         else if (ifLine.FalseLineId == 0)
         {
             EndDialogue();
             return;
         }
         else
         {
             currentLine = currentDialogue.FindLineById(ifLine.FalseLineId);
             ;
             HandleDialogue();
         }
         return;
     }
     else if (currentLine.GetType() == typeof(DialogueOption))
     {
         DialogueOption options = (DialogueOption)currentLine;
         SetLine(options.Speaker, options.Text);
         SetUpOptions(options);
         return;
     }
     else
     {
         EndDialogue();
     }
     return;
 }
Example #2
0
    /*
     * public int DialogueLength{
     *      get{ return currentDialogue.Length; }
     *      set { currentDialogue.Length = value; }
     * }
     */

    public void StartDialogue()
    {
        gameState = GameState.Dialogue;

        /*
         * DeserializeXMLDialogue (npcTarget.dialogueXMLPath);
         * if (gameState == GameState.Dialogue) {
         *      speakerName.text = currentDialogue.Speaker;
         *      dialogueText.text = currentDialogue.Speech [0];
         *      currentLine = 0;
         *      dialogueBox.SetActive (true);
         * }
         */
        if (npcTarget != null)
        {
            if (npcTarget.dialogueHead != null)
            {
                currentDialogue = npcTarget.dialogueHead;
                currentLine     = currentDialogue.FindLineById(currentDialogue.FirstLineId);
                dialogueBox.SetActive(true);
                HandleDialogue();
            }
        }
    }