Example #1
0
 void Attack()
 {
     if (gameObject.tag == "GatoBruxo" && Input.GetKeyDown(KeyCode.Space) && _time > attackTime)
     {
         if (Atk != null)
         {
             Destroy(Atk);
         }
         attacking = true;
         an.SetTrigger("Atacando");
         _time = 0f;
     }
     if (attacking)
     {
         _time += Time.deltaTime;
         if (_time >= attackDelay)
         {
             SoundEffectsScript.Instance.MakeBolaEnergiaSound();
             Atk = Instantiate(AttackObject, (Vector3)Rigid.position + transform.up, transform.rotation);
             PlayerAttackBehaviour a = Atk.GetComponent <PlayerAttackBehaviour>();
             a.setSpeed(attackSpeed);
             _time     = 0f;
             attacking = false;
         }
     }
     else
     {
         _time += Time.deltaTime;
         if (Atk != null && _time > attackTime)
         {
             Destroy(Atk);
         }
     }
 }
Example #2
0
    void Attack()
    {
        AllCatsBehaviour allCats = GetComponentInParent <AllCatsBehaviour>();

        if (Input.GetKeyDown(KeyCode.Space) && _time > attackTime && CatSwitchScript.Instance.canBruxoAttack)
        {
            if (Atk != null)
            {
                Destroy(Atk);
            }
            attacking = true;
            allCats.an.SetTrigger("Atacando");
            _time = 0f;
        }
        if (attacking)
        {
            _time += Time.deltaTime;
            if (_time >= attackDelay)
            {
                SoundEffectsScript.Instance.MakeFireCastingSound();
                Atk = Instantiate(AttackObject, (Vector3)allCats.Rigid.position + transform.up, transform.rotation);
                PlayerAttackBehaviour a = Atk.GetComponent <PlayerAttackBehaviour>();
                a.setSpeed(attackSpeed);
                _time     = 0f;
                attacking = false;
            }
        }
        else
        {
            _time += Time.deltaTime;
            if (Atk != null && _time > attackTime)
            {
                Destroy(Atk);
            }
        }
    }