protected void ShootProjectile(BossProjectile_lsy bossProjectile, float speed, float angle, float acceleration) { if (bossProjectile == null) { return; } bossProjectile.Shoot(angle, speed, acceleration); }
protected BossProjectile_lsy GetBossProjectile(Vector3 newPosition) { GameObject bossProjectilePooled = pooler.GetObjectFromPool(); BossProjectile_lsy bossProjectile = bossProjectilePooled.GetComponent <BossProjectile_lsy>(); bossProjectile.transform.position = newPosition; bossProjectilePooled.SetActive(true); bossProjectile.EnableBossProjectile(); return(bossProjectile); }
private void Shoot() { if (isShooting == false) { return; } // This adds an extra check to only run the code below in a fixed time if (nextShotTime >= 0f) { nextShotTime -= Time.deltaTime; if (nextShotTime >= 0f) { return; } } BossProjectile_lsy bossProjectile = GetBossProjectile(transform.position); if (bossProjectile == null) { return; } // Get random Speed float speed = Random.Range(minRandomSpeed, maxRandomSpeed); // Get random angle float minAngle = startAngle - range / 2f; float maxAngle = startAngle + range / 2f; float angle = Random.Range(minAngle, maxAngle); // Shoot ShootProjectile(bossProjectile, speed, angle, projectileAcceleration); // Increase index shotIndex++; // Stop shooting if all the projectiles are used if (shotIndex >= projectileAmount) { DisableShooting(); } else { // Update time to Shoot nextShotTime = Time.time + Random.Range(minDelay, maxDelay); if (nextShotTime <= 0) { Update(); } } }
private void Shoot() { if (isShooting == false) { return; } // This adds an extra check to only run the code below in a fixed time if (nextShotTime >= 0f) { nextShotTime -= Time.deltaTime; if (nextShotTime >= 0f) { return; } } // Get projectile BossProjectile_lsy bossProjectile = GetBossProjectile(transform.position); // Get angle float angle = startAngle + shiftAngle * shotIndex; // Shoot ShootProjectile(bossProjectile, projectileSpeed, angle, projectileAcceleration); // Increase Shoot index shotIndex++; // Stop shooting if all the projectiles are used if (shotIndex >= projectileAmount) { DisableShooting(); } else { // Update time to Shoot nextShotTime = Time.time + shotDelay; if (nextShotTime <= 0) { Update(); } } }
private void Shoot() { if (isShooting == false) { return; } float shiftAngle = 360f / projectileAmount; for (int i = 0; i < projectileAmount; i++) { BossProjectile_lsy bossProjectile = GetBossProjectile(transform.position); if (bossProjectile == null) { break; } float angle = shiftAngle * i; ShootProjectile(bossProjectile, projectileSpeed, angle, projectileAcceleration); } DisableShooting(); }
private void Start() { projectile = GetComponent <Projectile_lsy>(); bossProjectile = GetComponent <BossProjectile_lsy>(); }