Пример #1
0
    public void showMessage(int index)
    {
        NPCButton.disableButtons();
        dialogueText.text = npcDialogueText.Get_Messages[index].Get_Message;

        var optionsList = npcDialogueText.Get_Messages[index].Get_Options;

        for (int i = 0; i < optionsList.Count; i++)
        {
            var    count        = i;
            var    response     = optionsList[count].Response;
            Button optionButton = NPCButton.SetButtonText(optionsList[i].Option);

            if (response < 0)
            {
                optionButton.onClick.AddListener(delegate() { closeConversation(); });
            }

            else
            {
                optionButton.onClick.AddListener(delegate() { this.showMessage(response); });
            }
        }
        ui.ToggleDialogueWindow(true);
    }
Пример #2
0
    protected void Update()
    {
        if (!enableUpdate)
        {
            return;
        }
        // This line fixed a wierd bug that for some reason fixes that the player is able to talk with other npcs.
        if (!CheckRange.CheckRangeBetweenObjects(this.gameObject.transform, player.gameObject.transform, max_interactionRange * 2))
        {
            npcLookAtObject.LookAtVector(lookAt, rotationSpeed);
            return;
        }

        if (!CheckRange.CheckRangeBetweenObjects(this.gameObject.transform, player.gameObject.transform, max_interactionRange))
        {
            ui.ToggleInteractionText("");
            ui.ToggleDialogueWindow(false);
            isInConversation = false;
            return;
        }
        if (isInConversation)
        {
            return;
        }

        ui.ToggleInteractionText("Press E to chat with " + npcName);
        npcLookAtObject.LookAtObject(player);
        CheckPlayerInput();
    }