public override void Shot() { if (m_bulletNum <= 0 || m_bulletSpeed <= 0f) { Debug.LogWarning("Cannot shot because BulletNum or BulletSpeed is not set."); return; } m_holeCenterAngle = Utils2D.GetNormalizedAngle(m_holeCenterAngle); float startAngle = m_holeCenterAngle - (m_holeSize / 2f); float endAngle = m_holeCenterAngle + (m_holeSize / 2f); float shiftAngle = 360f / (float)m_bulletNum; for (int i = 0; i < m_bulletNum; i++) { float angle = shiftAngle * i; if (startAngle <= angle && angle <= endAngle) { continue; } var bullet = GetBullet(transform.position); if (bullet == null) { break; } ShotBullet(bullet, m_bulletSpeed, angle); } FiredShot(); FinishedShot(); }
private IEnumerator ShotCoroutine() { if (base.bulletNum <= 0 || base.bulletSpeed <= 0f) { Debug.LogWarning("Cannot shot because BulletNum or BulletSpeed is not set."); yield break; } if (base.isShooting) { yield break; } base.isShooting = true; for (int i = 0; i < base.bulletNum; i++) { if (0 < i && 0f < this.betweenDelay) { FiredShot(); yield return(new WaitForSeconds(this.betweenDelay)); } var bullet = GetBullet(transform.position); if (bullet == null) { break; } float shootingAngle = Random.Range(0, 360); if (Mathf.Abs(shootingAngle - prevAngle) <= this.minimumAngleDistance) { shootingAngle = Random.Range(0.0f, 1.0f) >= 0.5f ? shootingAngle + this.minimumAngleSeparation : shootingAngle - this.minimumAngleSeparation; shootingAngle = Utils2D.GetNormalizedAngle(shootingAngle); } ShotBullet(bullet, bulletSpeed, shootingAngle); this.prevAngle = shootingAngle; } FiredShot(); FinishedShot(); }