Exemplo n.º 1
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        isTriggerd = true;

        if (Input.GetMouseButtonDown(0))
        {
            Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            RaycastHit2D hit = Physics2D.Raycast(mousePos, Vector2.zero);

            if (hit.collider != null)
            {
                if (hit.collider.gameObject.name == gameObject.name)
                {
                    FruitController fruit = collision.gameObject.GetComponent <FruitController>();

                    if (fruit == null)
                    {
                        return;
                    }

                    fruit.Die();
                    AwardScore(fruit);

                    ISpecialPower special = collision.gameObject.GetComponent <ISpecialPower>();

                    if (special != null)
                    {
                        special.InvokeSpecialPower(gameObject.GetComponent <CatcherController>());
                    }
                    else
                    {
                        RightClick();
                    }
                    Destroy(collision.gameObject, dieDelayTime);
                }
            }
        }

        //isHandleFruit = false;
        isTriggerd = false;
    }