示例#1
0
    void CollectPickups()
    {
        _canPickup = Time.time + _rateOfPickup;

        Collider2D[] pickups = Physics2D.OverlapCircleAll(transform.position, 10f);

        foreach (Collider2D collider in pickups)
        {
            if (collider.CompareTag("Powerup") || collider.CompareTag("Collectible"))
            {
                if (collider.CompareTag("Powerup"))
                {
                    Powerup pickup = collider.GetComponent <Powerup>();
                    pickup.ActivatePickupCollect();
                }
                else
                {
                    Collectible pickup = collider.GetComponent <Collectible>();
                    pickup.ActivatePickupCollect();
                }
            }
        }
    }