Beispiel #1
0
    void OnTriggerStay2D(Collider2D collider)
    {
        if (collider.gameObject.CompareTag("Checkout"))
        {
            message = "Press E or Mouse 2 to Checkout";
            if (Input.GetKeyDown(KeyCode.Mouse1) || Input.GetKeyDown(KeyCode.E))
            {
                UIManager.instance.EndGame(true, collider.gameObject.name);
                message = "";
            }
        }

        else
        {
            if (collider.CompareTag("WeaponGround"))
            {
                message = "Press E or Mouse 2 to Equip";
                if (Input.GetKeyDown(KeyCode.Mouse1) || Input.GetKeyDown(KeyCode.E))
                {
                    IPickupable itemComponent = collider.GetComponent <IPickupable>();
                    if (itemComponent != null)
                    {
                        DropWeapon();
                        itemComponent.pickUp();
                        defaultWeapon.gameObject.SetActive(false);
                        message = "";
                    }
                }
            }
            else
            {
                IPickupable itemComponent = collider.GetComponent <IPickupable>();
                if (itemComponent != null)
                {
                    itemComponent.pickUp();
                }
            }
        }
    }