コード例 #1
0
    }     //End parseScriptFromLine

    private Set getNextSet(Conversation conversation, Set set)
    {
        //If it's the start of the conversation, get the first set
        if (set == null)
        {
            return(JSONHolder.getSetFromConversation(0, conversation));
        }//End if
        //Get specific next set pointed to by the current set
        if (set.setLines[currentIndex].nextSet != null && set.setLines[currentIndex].nextSet.Length > 0)
        {
            return(JSONHolder.getSetFromConversation(set.setLines[currentIndex].nextSet, conversation));
        }//End if
        //Move on to the next set in the array
        else
        {
            int index = System.Array.IndexOf(conversation.setIDs, set.setLines[currentIndex].nextSet);
            if (index == -1)
            {
                conversationIsOver = true;
                return(null);
            }//End else
            else
            {
                return(JSONHolder.getSetFromConversation(index, conversation));
            } //End if
        }     //End else
    }         //End getNextSet
コード例 #2
0
    }//End startDialogue

    public void runDialogue(SetLine setLineFromDialogueChoice)
    {
        //Reset script run status
        storedLineSeenResult = false;
        finishedLine         = false;
        doneBeforeLine       = false;
        doneAfterLine        = false;
        destroyOldDialogueObjects();
        currentDialogue = gameObject.AddComponent <CurrentDialogue>();
        //Try to get the next set in the conversation
        if (setLineFromDialogueChoice == null)
        {
            set = getNextSet(conversation, set);
        }//End if
        else
        {
            set = JSONHolder.getSetFromConversation(setLineFromDialogueChoice.nextSet, conversation);
        }//End else
        //If there is no next set in the conversation, the conversation is over
        if (!conversationIsOver && set != null)
        {
            lines = getNextLines(set);
            if (set.speaker.Equals("PLAYER"))
            {
                List <SetLine> dialogueOptions = setUpDialogueOptions();
                currentDialogue.speakerIsPlayer(playerData);
                currentDialogue.setDialogueOptions(dialogueOptions);
                currentDialogue.displayDialogueOptions();
            }//End if
             //Display individual NPC line
            else if (set.speaker.Equals("NPC"))
            {
                if (lines[0].doBeforeLine != null)
                {
                    //Run a script before the line itself has run
                    runDialogueLineScript(lines[0]);
                }//End if
                //Set NPC dialogue data up
                setNPCDialogueData();
                currentDialogue.speakLine();
                StartCoroutine(WaitForLineToFinish());
            }//End else if
            else
            {
                Debug.LogError("ERROR IN SET JSON: PLAYER or NPC speaker marker in " + set.setID + " mistyped as " + set.speaker + ".");
            } //End else
        }     //End if
        else
        {
            currentDialogue.setBlipSource(null);
            PlayerInteraction playerInteraction = GameObject.FindGameObjectWithTag("Player").gameObject.GetComponentInChildren <PlayerInteraction>();
            playerInteraction.setIsInteracting(false);
        } //End else
    }     //End runDialogue