private IEnumerator Fire() { while (true) { yield return(new WaitForSeconds(TimeToFire)); if (BossLife % 2 == 0 && PlayerInRange == true) //Used to switch fire state on hit on two { BossAnimationController.SetBool("isShooting", true); foreach (Transform t in GunsTransformListP1) { SoundsManager.PlayEnemyShootSound(); GameObject bullet = Instantiate(BulletPrefab, t.position, t.rotation); bullet.GetComponent <Rigidbody2D>().velocity = t.right * BulletVelocity; Destroy(bullet, TimeToDestroyBullet); } } if (BossLife % 2 == 1 && PlayerInRange == true) //Used to switch fire state on hit on two { BossAnimationController.SetBool("isShooting", true); foreach (Transform t in GunsTransformListP2) { SoundsManager.PlayEnemyShootSound(); GameObject bullet = Instantiate(BulletPrefab, t.position, t.rotation); bullet.GetComponent <Rigidbody2D>().velocity = t.right * BulletVelocity; Destroy(bullet, TimeToDestroyBullet); } } if (PlayerInRange == true) { DoorToClose.SetActive(true); BossHealthBar.SetActive(true); } } }
private IEnumerator Fire() { while (true) { yield return(new WaitForSeconds(TimeToFire)); if (CanAttack == true) { EnemyAnimationController.SetBool("isShooting", true); GameObject bullet = Instantiate(BulletPrefab, GunTransform.position, GunTransform.rotation); bullet.GetComponent <Rigidbody2D>().velocity = Direction * BulletVelocity; SoundsManager.PlayEnemyShootSound(); Destroy(bullet, 3); } } }