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); } } }
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); }
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); } } }
// Start is called before the first frame update void Start() { _rigidbody = GetComponent <Rigidbody>(); _agent = GetComponent <NavMeshAgent>(); _playerAttack = GetComponent <PlayerAttackBehaviour>(); }