Beispiel #1
0
    // private void DescriptionCheck()
    // {
    //     List<Collider2D> results = new List<Collider2D>();
    //     if(interactionPoint.OverlapCollider(new ContactFilter2D(), results) > 0)
    //     {
    //         //!Following line uses first result instead of iterating, see InteractionCheck() below
    //         foreach(Collider2D item in results)
    //         {
    //             Description target = item.gameObject.GetComponent<Description>();
    //             if(target != null)
    //             {
    //                 //callback  //!
    //                 //disable input //!
    //                 inputMode = InputMode.Text;
    //                 GameManager.instance.textbox.Open(target.description);
    //                 break;
    //             };
    //         }
    //     }
    // }


    private void InteractionCheck()
    {
        List <Collider2D> results = new List <Collider2D>();

        if (interactionPoint.OverlapCollider(new ContactFilter2D(), results) > 0)
        {
            foreach (Collider2D item in results)
            {
                Interaction target = item.gameObject.GetComponent <Interaction>();
                if (target != null)
                {
                    target.Activate();
                    break;
                }
                ;
            }
        }
    }
Beispiel #2
0
    protected override bool Activate()
    {
        UpdateClosestInteraction();
        if (closestInteraction != null)
        {
            if (playerController.IsCarryingObject())
            {
                playerController.UseCarriedObject(closestInteraction);
            }
            else if (closestInteraction.Activate())
            {
                closestInteraction.PlayAudio();
            }
            return(true);
        }

        return(false);
    }