示例#1
0
    // Start is called before the first frame update
    void Start()
    {
        uiManager_   = UIManager.Instance;
        flagManager_ = FlagManager.Instance;

        // If NPC still has dialogue, show it as interactible.
        UnityAction <FlagManager.EventFlag> checkStillInteractible =
            new UnityAction <FlagManager.EventFlag>((FlagManager.EventFlag flag) =>
        {
            if (currTalkableNPC_ == null)
            {
                return;
            }

            currTalkableNPC_.SetInteractable(currTalkableNPC_.HasAvailableModel());
        });

        flagManager_.AddListener(checkStillInteractible);
        uiManager_.Player = this;

        isWeb = Application.platform != RuntimePlatform.WebGLPlayer;


        dialogueCompletedCb_ = () =>
        {
            state_ = PlayerDialogueState.Inactive;
            return(true);
        };
    }
    public override void Interact(GameObject interactor)
    {
        if (isLocked)
        {
            if (interactor.tag == "Player")
            {
                FMODUnity.RuntimeManager.PlayOneShot(sfxDoorLocked, transform.position);

                /* (Bernardo) TODO: Adicionar dialogo de "trancado"
                 *
                 * interactor.GetComponentInChildren<PlayerDialogueState>().dialogue = lockedDialogue;
                 * interactor.transform.GetChild(2).GetComponent<ConcurrentStateMachine>().ChangeState(typeof(PlayerDialogueState));*/
            }
        }
        else
        {
            if (!hasBeenOpened)
            {
                FMODUnity.RuntimeManager.PlayOneShot(sfxChestOpening, transform.position);
                hasBeenOpened = true;
                animator.SetTrigger("Open");
                ObjectCollector collector = interactor.GetComponent <ObjectCollector>();

                collector.GetItem(containedItem);
                FMODUnity.RuntimeManager.PlayOneShot(sfxCollectingItem, transform.position);
            }
            else
            {
                PlayerDialogueState dialogueState = interactor.GetComponentInChildren <PlayerDialogueState>();

                dialogueState.dialogue = emptyDialogue;
                dialogueState.GetComponent <ConcurrentStateMachine>().ChangeState(typeof(PlayerDialogueState));
            }
        }
    }
示例#3
0
    public void SetTalking(DialogueModel model)
    {
        if (state_ == PlayerDialogueState.InDialogue)
        {
            return;
        }

        if (uiManager_.SetAndShowDialogue(model, dialogueCompletedCb_))
        {
            state_ = PlayerDialogueState.InDialogue;
        }
    }
    public override void Interact(GameObject player)
    {
        PlayerDialogueState dialogueState = player.GetComponentInChildren <PlayerDialogueState>();

        if (alreadyInteracted)
        {
            dialogueState.dialogue = alreadyInteractedDialogue;
        }
        else
        {
            dialogueState.dialogue = initialDialogue;
            alreadyInteracted      = true;
        }

        dialogueState.GetComponent <ConcurrentStateMachine>().ChangeState(typeof(PlayerDialogueState));
    }
    public override void Interact(GameObject player)
    {
        ObjectCollector collector = player.GetComponent <ObjectCollector>();

        if (isLocked && collector.CheckQty(keyType) == 0)
        {
            FMODUnity.RuntimeManager.PlayOneShot(sfxDoorLocked, transform.position);
            PlayerDialogueState dialogueState = player.GetComponentInChildren <PlayerDialogueState>();
            dialogueState.dialogue = lockedDialogue;
            dialogueState.GetComponent <ConcurrentStateMachine>().ChangeState(typeof(PlayerDialogueState));
        }
        else if (isLocked && collector.CheckQty(keyType) > 0)
        {
            FMODUnity.RuntimeManager.PlayOneShot(sfxDoorUnlocked, transform.position);
            isLocked = false;
            collector.UseItem(keyType);
            lockObject.SetActive(false);
        }
        else if (!isLocked)
        {
            animator.SetTrigger("Open");
            FMODUnity.RuntimeManager.PlayOneShot(sfxDoorOpening, transform.position);
        }
    }