コード例 #1
0
    private void OnMouseUp()
    {
        mouseUpPosition = transform.position;
        onHold          = false;

        Collider2D collider = Physics2D.OverlapCircle(transform.position, berryCollider.bounds.extents.x, LayerMask.GetMask(BASKET_LAYER));

        if (collider != null)
        {
            Basket _foundBasket = collider.GetComponent <Basket>();

            if (_foundBasket != null)
            {
                if (fruitData.fruitType == _foundBasket.basket.basketFruitType)
                {
                    MinimizeBerry();
                    correctBasket = true;
                    _foundBasket.AddBerry();
                    OnCollected?.Invoke();
                }
                else
                {
                    wrongParticlesInstance.GetComponent <ParticleSystemRenderer>().material = fruitData.berryVFXMaterial;
                    Instantiate(wrongParticlesInstance, this.transform.position, Quaternion.identity);
                    ReturnBerry();
                }
            }
        }
        else
        {
            ReturnBerry();
        }
    }
コード例 #2
0
    private void OnMouseUp()
    {
        onHold = false;
        Collider2D collider = Physics2D.OverlapCircle(transform.position, basketCollider.bounds.extents.x, LayerMask.GetMask(BASKET_LAYER));

        if (collider != null)
        {
            Basket _foundBasket = collider.GetComponent <Basket>();

            if (_foundBasket != null)
            {
                if (fruitType == _foundBasket.basketFruitType)
                {
                    _foundBasket.AddBerry();
                    GameManager.Instance.CheckIfWon();
                    Destroy(this.gameObject);
                }
            }
        }
        ReturnBerry();
    }