Esempio n. 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);
         }
     }
 }
Esempio n. 2
0
 void Start()
 {
     controller = GetComponent <PlayerController>();
     attack     = GetComponent <PlayerAttackBehaviour>();
     sprIdle    = transform.Find("spr_player").GetComponent <SpriteRenderer>();
     sprRoll    = transform.Find("spr_player_rolling").GetComponent <SpriteRenderer>();
     sprRoll.gameObject.SetActive(false);
 }
Esempio n. 3
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);
            }
        }
    }
Esempio n. 4
0
 // Start is called before the first frame update
 void Start()
 {
     _rigidbody    = GetComponent <Rigidbody>();
     _agent        = GetComponent <NavMeshAgent>();
     _playerAttack = GetComponent <PlayerAttackBehaviour>();
 }