private IEnumerator MeleeAttack(float meleeInterval) { if (_canMelee) { _canMelee = false; _attackAnimator.SetTrigger("MeleeAttack"); FindObjectOfType <SoundManager>().Play("MeleeAttack"); Collider2D[] hitList = Physics2D.OverlapCircleAll( _attackPoint.position, _attackRange ); StartCoroutine(VibratePad(0.2f, 0.1f)); foreach (Collider2D hit in hitList) { if (hit.tag == "ENEMY") { _enemyDamage = hit.gameObject.GetComponent <EnemyRobotDamage>(); _enemyDamage.DestroyEnemy(_enemyDamage.gameObject); StartCoroutine(VibratePad(1.0f, 0.3f)); } } yield return(new WaitForSeconds(meleeInterval)); _canMelee = true; } }
private IEnumerator Shoot() { FindObjectOfType <SoundManager>().Play("GunAttack"); RaycastHit2D hit = Physics2D.Raycast(_attackAim.position, _attackAim.transform.up); if (hit) { _enemyDamage = hit.transform.GetComponent <EnemyRobotDamage>(); _enemyDamage.DestroyEnemy(_enemyDamage.gameObject); StartCoroutine(VibratePad(1.0f, 0.3f)); } CreateGunTracer(_attackAim.localPosition, Vector2.up * 100); _lineRenderer.enabled = true; yield return(new WaitForSeconds(0.02f)); _lineRenderer.enabled = false; }