Exemple #1
0
    // //NOTE: objects are perceived both when NPC enters and exits their range of perceptability
    // public void OnTriggerExit2D(Collider2D other) {
    // }

    // called when Character enters the trigger collider of an object
    public void OnTriggerEnter(Collider other)
    {
        if (!locked)
        {
            Perceivable po = other.GetComponent <Perceivable>();

            if (po != null)
            {
                // Debug.Log(name + " sees " + po);
                po.SendPercept(this);
            }

            Perceivable[] childrenPOs = GetComponentsInChildren <Perceivable>();
            for (int i = 0; i < childrenPOs.Length; i++)
            {
                // Debug.Log(name + " sees " + childrenPOs[i]);
                childrenPOs[i].SendPercept(this);
            }

            if (other.CompareTag("Interactable"))
            {
                currentInteractObject = other.gameObject;
            }

            locked = true;
            StartCoroutine("Waiting");
        }
    }
Exemple #2
0
    // called when Character enters the trigger collider of an object
    public void OnTriggerEnter(Collider other)
    {
        Perceivable po = other.GetComponent <Perceivable>();

        if (po != null)
        {
            po.isInRoom = true;
        }

        Perceivable[] childrenPOs = GetComponentsInChildren <Perceivable>();
        for (int i = 0; i < childrenPOs.Length; i++)
        {
            childrenPOs[i].isInRoom = true;
        }

        NPC npc = other.GetComponent <NPC>();

        if (npc != null)
        {
            npc.ReceivePercept(new Phrase(Expression.IN_THE_ROOM, Expression.SELF));
        }
    }