private void Die() { float deathVolume = Mathf.Clamp(OptionController.GetMasterVolume(), 0f, deathSoundVolume); FindObjectOfType <Level>().LoadGameOver(); Destroy(gameObject); AudioSource.PlayClipAtPoint(deathSound, Camera.main.transform.position, deathVolume); }
private void Fire() { float shootVolume = Mathf.Clamp(OptionController.GetMasterVolume(), 0f, shootSoundVolume); GameObject laser = Instantiate(projectile, transform.position, Quaternion.identity) as GameObject; laser.GetComponent <Rigidbody2D>().velocity = new Vector2(0, -projectileSpeed); AudioSource.PlayClipAtPoint(shootSound, Camera.main.transform.position, shootVolume); }
private void Die() { float deathVolume = Mathf.Clamp(OptionController.GetMasterVolume(), 0f, deathSoundVolume); FindObjectOfType <GameSession>().AddToScore(scoreValue); Destroy(gameObject); GameObject explosion = Instantiate(deathVFX, transform.position, Quaternion.identity); Destroy(explosion, durationOfExplosion); AudioSource.PlayClipAtPoint(deathSound, Camera.main.transform.position, deathVolume); }
IEnumerator FireContinuously() { float shootVolume = Mathf.Clamp(OptionController.GetMasterVolume(), 0f, shootSoundVolume); while (true) { if (canTripleShot == true) { GameObject laser = Instantiate(tripleShotPrefab, transform.position, Quaternion.identity) as GameObject; laser.GetComponent <Rigidbody2D>().velocity = new Vector2(0, projectileSpeed); } else if (canTripleShot == false) { GameObject laser = Instantiate(laserPrefab, transform.position, Quaternion.identity) as GameObject; laser.GetComponent <Rigidbody2D>().velocity = new Vector2(0, projectileSpeed); } AudioSource.PlayClipAtPoint(shootSound, Camera.main.transform.position, shootVolume); yield return(new WaitForSeconds(projectileFiringPeriod)); } }
// Start is called before the first frame update void Awake() { audioSource = GetComponent <AudioSource>(); audioSource.volume = OptionController.GetMasterVolume(); SetUpSingleton(); }