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;
    }
Exemple #2
0
        public static void AddPowers(IAttacker character, ICollection <INormalAttack> attacks, ISpecialPower specialPower)
        {
            foreach (var attack in attacks)
            {
                character.Attacks.Add(attack);
            }

            character.SpecialAttack = specialPower;
        }
Exemple #3
0
 public void SpecialAttack(ISpecialPower specialPower)
 {
     _characterAction = new SpecialAttack(specialPower);
     _characterAction.Execute(_characterTo);
 }