Esempio n. 1
0
    }//End Player Speaking Display Getter

    #endregion

    private void Start()
    {
        //Create blank currentDialogue
        currentDialogue = null;
        //Get the player speaker data
        playerData = JSONHolder.getSpeaker("Player");
        //Get the portrait, name, and line objects from the UI
        for (int i = 0; i < convoHUDObject.transform.childCount; i++)
        {
            var child = convoHUDObject.transform.GetChild(i);
            switch (child.name)
            {
            case "NPC Dialogue Box":
                npcSpeakingDisplay = child.gameObject;
                for (int j = 0; j < npcSpeakingDisplay.transform.childCount; j++)
                {
                    var npcChild = npcSpeakingDisplay.transform.GetChild(j);
                    switch (npcChild.name)
                    {
                    case "Portrait": portraitNPCDisplay = npcChild.gameObject.GetComponent <Image>(); break;

                    case "Name": speakerNameNPCDisplay = npcChild.gameObject.GetComponent <TextMeshProUGUI>(); break;

                    case "Line": lineInBoxNPCDisplay = npcChild.gameObject.GetComponent <TextMeshProUGUI>(); break;
                    } //End switch
                }     //End for
                break;

            case "Player Choices":
                playerSpeakingDisplay = child.gameObject;
                var playerDialogueBox = playerSpeakingDisplay.transform.GetChild(0);
                for (int j = 0; j < playerDialogueBox.transform.childCount; j++)
                {
                    var playerChild = playerDialogueBox.transform.GetChild(j);
                    switch (playerChild.name)
                    {
                    case "Portrait":
                        portraitPlayerDisplay = playerChild.gameObject.GetComponent <Image>();
                        setPlayerPortrait(playerData.portrait);
                        break;

                    case "Name":
                        speakerNamePlayerDisplay = playerChild.gameObject.GetComponent <TextMeshProUGUI>();
                        setPlayerName(playerData.speakerName);
                        break;

                    case "Line":
                        lineInBoxPlayerDisplay = playerChild.gameObject.GetComponent <TextMeshProUGUI>();
                        setPlayerLineInBox("");
                        break;
                    } //End switch
                }     //End for
                break;
            }//End switch
        }//End for
        playerSpeakingDisplay.SetActive(false);
        npcSpeakingDisplay.SetActive(false);
    }//End Start
Esempio n. 2
0
 //Get the values that will always need to be carried by the dialogue manager
 private void Start()
 {
     nextPressed        = false;
     currentIndex       = -1;
     finishedLine       = false;
     conversationIsOver = true;
     playerData         = JSONHolder.getSpeaker("Player");
     uiManager          = GameObject.FindGameObjectWithTag("HUD").GetComponent <UIManager>();
     audioSource        = GameObject.FindGameObjectWithTag("Audio Source").GetComponent <AudioSource>();
 }//End Start
Esempio n. 3
0
    }                 //End Update

    //Start a new conversation with an NPC
    public void startDialogue(GameObject npcGameObject)
    {
        currentIndex = 0;
        //Set the conversation being over variable to false
        conversationIsOver = false;
        //Get NPC speaker data
        NPCData = JSONHolder.getSpeaker(npcGameObject.GetComponent <Interactive>().getID());
        //Attach an audio source to the NPC if they don't have one already
        if (!npcGameObject.GetComponent <AudioSource>())
        {
            npcGameObject.AddComponent <AudioSource>();
        }//End if
        //Horrendous workaround
        currentDialogue = gameObject.AddComponent <CurrentDialogue>();
        currentDialogue.setBlipSource(npcGameObject.GetComponent <AudioSource>());
        DestroyImmediate(currentDialogue);
        //Find the relevant conversation
        conversation = JSONHolder.findConversation(NPCData);
        set          = null;
        lines        = new List <Line>();
        runDialogue(null);
    }//End startDialogue
Esempio n. 4
0
    }//End Is Interacting Setter

    #endregion

    //Initialise variables on player start
    private void Start()
    {
        //Set the player to whatever is currently set as the player
        player = GameObject.FindGameObjectWithTag("Player");
        //Find camera
        playerCam = FindObjectOfType <Camera>();
        //Set the interaction range to a test value of ten
        interactRange = 1.5f;
        //Set the interaction layer to... the interaction layer
        interactLayer = LayerMask.GetMask("Interactible");
        //Set the HUD Handler to the correct object
        HUDHandler = GameObject.FindGameObjectWithTag("HUD").GetComponent <ExplorationHUD>();
        //Set player voice
        GameObject.FindGameObjectWithTag("MainCamera").GetComponentInChildren <AudioSource>().clip = JSONHolder.getSpeaker("Player").voice;
    }//End Start