Пример #1
0
    void Start()
    {
        transition = GetComponent <SceneTransition>();

        currentImage   = 0;
        Display.sprite = Images[currentImage];
        Dialogue.SetTree(DialogueName);
        DialogueText.text = Dialogue.GetCurrentDialogue();
    }
Пример #2
0
    public void ShowOther()
    {
        //Currently showing text, wanting to show buttons
        if (showingText)
        {
            topText.text = dialogues.GetChoices()[0];
            if (dialogues.GetChoices().Length > 1)
            {
                middleText.text = dialogues.GetChoices()[1];
            }
            if (dialogues.GetChoices().Length > 2)
            {
                bottomText.text = dialogues.GetChoices()[2];
            }

            if (dialogues.GetChoices().Length > 1)
            {
                middleText.transform.parent.gameObject.SetActive(true);
            }
            else
            {
                middleText.transform.parent.gameObject.SetActive(false);
            }

            if (dialogues.GetChoices().Length > 2)
            {
                bottomText.transform.parent.gameObject.SetActive(true);
            }
            else
            {
                bottomText.transform.parent.gameObject.SetActive(false);
            }
        }
        else
        {
            dialogueText.text = dialogues.GetCurrentDialogue();
        }

        showingText = !showingText;
        buttonContainer.SetActive(!showingText);
        dialogueContainer.SetActive(showingText);
    }
Пример #3
0
    public void NextDialogue()
    {
        if (npc.End())
        {
            DialogueBox.SetActive(false);
            npc = null;

            PlayerStatus pStatus = GetComponent <Player>().PlayerStatus;
            pStatus.CanWalk     = true;
            pStatus.canInteract = true;
            pStatus.isTalking   = false;

            return;
        }
        npc.Next();
        text.text = npc.GetCurrentDialogue();
    }
Пример #4
0
 public void StartInteraction(GameObject obj, string str, int random_responses, int index = -1)
 {
     active       = true;
     interactable = obj.GetComponent <Interactable>();
     if (interactable.isPerson)
     {
         portrait.GetComponent <Image>().sprite = interactable.portrait;
         portraitItem.SetActive(false);
         portrait.SetActive(true);
     }
     else
     {
         portraitItem.GetComponent <Image>().sprite = interactable.portrait;
         portraitItem.SetActive(true);
         portrait.SetActive(false);
     }
     interactable.Interact();
     dialogues = interactable.GetComponent <Dialogues>();
     if (index == -1)
     {
         if (random_responses > 0)
         {
             int ind = Random.Range(0, random_responses);
             dialogues.SetTree(ind.ToString());
         }
         else
         {
             dialogues.SetTree(str);
         }
     }
     else
     {
         dialogues.SetTree(index.ToString());
     }
     dialogues.Reset();
     dialogueText.text = dialogues.GetCurrentDialogue();
     dialogueUI.SetActive(true);
 }
Пример #5
0
    public void StartConversation(Dialogues npc, string dialogueTree, Sprite image)
    {
        DialogueBox.SetActive(true);
        this.npc = npc;
        this.npc.SetTree(dialogueTree);
        text.text = npc.GetCurrentDialogue();

        if (image != null)
        {
            DialogueImage.gameObject.SetActive(true);
            DialogueImage.sprite = image;
        }
        else
        {
            DialogueImage.gameObject.SetActive(false);
        }

        PlayerStatus pStatus = GetComponent <Player>().PlayerStatus;

        pStatus.CanWalk     = false;
        pStatus.canInteract = false;
        pStatus.isTalking   = true;
        //pStatus.isInteracting =
    }
Пример #6
0
    public void Display()
    {
        if (nextEnd == true)
        {
            backPanel.SetActive(false);
            nextTreeButton.SetActive(true);
        }
        else
        {
            backPanel.SetActive(true);
            nextTreeButton.SetActive(false);
        }

        //Sets our text to the current text
        dialogueText.text = npc.GetCurrentDialogue();
        //Just debug log our triggers for example purposes
        if (npc.HasTrigger())
        {
            Debug.Log("Triggered: " + npc.GetTrigger());
        }
        //This checks if there are any choices to be made
        if (npc.GetChoices().Length != 0)
        {
            //Setting the text's of the buttons to the choices text, in my case I know I'll always have a max of three choices for this example.
            leftText.text   = npc.GetChoices()[0];
            middleText.text = npc.GetChoices()[1];
            //If we only have two choices, adjust accordingly
            if (npc.GetChoices().Length > 2)
            {
                rightText.text = npc.GetChoices()[2];
            }
            else
            {
                rightText.text = npc.GetChoices()[1];
            }
            //Setting the appropriate buttons visability
            leftText.transform.parent.gameObject.SetActive(true);
            rightText.transform.parent.gameObject.SetActive(true);
            if (npc.GetChoices().Length > 2)
            {
                middleText.transform.parent.gameObject.SetActive(true);
            }
            else
            {
                middleText.transform.parent.gameObject.SetActive(false);
            }
        }
        else
        {
            middleText.text = "Continue";
            //Setting the appropriate buttons visability
            leftText.transform.parent.gameObject.SetActive(false);
            rightText.transform.parent.gameObject.SetActive(false);
            middleText.transform.parent.gameObject.SetActive(true);
        }

        if (npc.End()) //If this is the last dialogue, set it so the next time we hit "Continue" it will hide the panel
        {
            nextEnd = true;
        }
    }