Esempio n. 1
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        PlayerWeaponAimHandler player = collision.gameObject.GetComponent <PlayerWeaponAimHandler>();

        //Checks if it has collided with a player
        if (collision.CompareTag("Player") && player.isWeaponThere() == false && gameObject.CompareTag("weapon"))
        {
            //Calls the update function passing the game object this script is attached to
            player.updateWeapon(gameObject);
        }
    }
Esempio n. 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //Collects the necessary data from the collision object and holds them in a global variables
        player      = collision.GetComponent <PlayerController>();
        weaponCheck = collision.GetComponent <PlayerWeaponAimHandler>();
        ConsumableHandler consumer = collision.GetComponent <ConsumableHandler>();

        //Checks if it has collided with a player
        if (collision.CompareTag("Player"))
        {
            //Checks if the slot is occupyed
            if (weaponCheck.isWeaponThere() == false)
            {
                //If slot is free add the consumable object to the slot
                consumer.updateObject(gameObject);
            }
        }
    }