示例#1
0
    private void Die()
    {
        float deathVolume = Mathf.Clamp(OptionController.GetMasterVolume(), 0f, deathSoundVolume);

        FindObjectOfType <Level>().LoadGameOver();
        Destroy(gameObject);
        AudioSource.PlayClipAtPoint(deathSound, Camera.main.transform.position, deathVolume);
    }
示例#2
0
    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);
    }
示例#3
0
    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);
    }
示例#4
0
    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));
        }
    }
示例#5
0
 // Start is called before the first frame update
 void Awake()
 {
     audioSource        = GetComponent <AudioSource>();
     audioSource.volume = OptionController.GetMasterVolume();
     SetUpSingleton();
 }