void Awake() { time = 0f; contador = 0; enemyBehav = GetComponent <EnemyBehav>(); ripple = Camera.main.GetComponent <RipplePostProcess>(); }
// Use this for initialization public void Awake() { currentVida = MAX_VIDA; anim = this.GetComponent <Animator>(); enemyBehav = this.GetComponent <EnemyBehav>(); enemySounds = this.GetComponent <AudioSource>(); isDead = false; }
private void OnTriggerEnter2D(Collider2D collision) { EnemyBehav enemyBehav = collision.GetComponent <EnemyBehav>(); if (collision.tag == "Enemy" && !PlayerBehav.Instance.enemyList.Contains(enemyBehav)) { PlayerBehav.Instance.enemyList.Add(collision.GetComponent <EnemyBehav>()); } }
private void OnTriggerExit2D(Collider2D collision) { if (collision.tag == "Enemy") { EnemyBehav enemyBehav = collision.GetComponent <EnemyBehav>(); if (PlayerBehav.Instance.enemyList.Contains(enemyBehav)) { PlayerBehav.Instance.enemyList.Remove(enemyBehav); } } }
void MeleeAttack(float damage, float range) { Collider[] colliders = Physics.OverlapBox(transform.position + transform.forward * (range / 2), new Vector3(1, 1, range / 2), GlobalRef.cameraPos.rotation); for (int i = 0; i < colliders.Length; i++) { if (colliders[i].tag == "Enemy") { Debug.Log("Hit Enemy"); EnemyBehav enemy = colliders[i].gameObject.GetComponent <EnemyBehav>(); enemy.Hit(damage); } } }