Пример #1
0
    /// <summary>
    /// Plays a sound.
    /// </summary>
    /// <param name="typeOfSound">Type of sound.</param>
    public void PlaySound(ShooterAIAudioOptions typeOfSound)
    {
        //test if we're even allowed to play sounds
        if (soundEnabled == false)
        {
            return;
        }

        //check if the chances come together
        if (Random.Range(0f, 1f) > chanceForSound)
        {
            return;
        }

        //initiate the sound that we will play
        AudioClip soundToPlay = null;

        //find out which sound to play
        switch (typeOfSound)
        {
        case ShooterAIAudioOptions.Patrol: soundToPlay = patrolSounds[(int)Random.Range(0, patrolSounds.Length)]; break;

        case ShooterAIAudioOptions.Investigate: soundToPlay = investigateSounds[(int)Random.Range(0, investigateSounds.Length)]; break;

        case ShooterAIAudioOptions.Engage: soundToPlay = engageSounds[(int)Random.Range(0, engageSounds.Length)]; break;

        case ShooterAIAudioOptions.Cover: soundToPlay = coverSounds[(int)Random.Range(0, coverSounds.Length)]; break;

        case ShooterAIAudioOptions.Panic: soundToPlay = panicSounds[(int)Random.Range(0, panicSounds.Length)]; break;

        case ShooterAIAudioOptions.Charge: soundToPlay = chargeSounds[(int)Random.Range(0, chargeSounds.Length)]; break;
        }


        //play the sound
        c_Audio.PlayOneShot(soundToPlay);
    }
Пример #2
0
	/// <summary>
	/// Plays a sound.
	/// </summary>
	/// <param name="typeOfSound">Type of sound.</param>
	public void PlaySound( ShooterAIAudioOptions typeOfSound)
	{
		//test if we're even allowed to play sounds
		if( soundEnabled == false)
		{
			return;
		}
		
		//check if the chances come together
		if( Random.Range(0f, 1f) > chanceForSound )
		{
			return;
		}
		
		//initiate the sound that we will play
		AudioClip soundToPlay = null;
		
		//find out which sound to play
		switch( typeOfSound)
		{
		case ShooterAIAudioOptions.Patrol: soundToPlay = patrolSounds[ (int)Random.Range(0, patrolSounds.Length) ]; break;
		case ShooterAIAudioOptions.Investigate: soundToPlay = investigateSounds[ (int)Random.Range(0, investigateSounds.Length) ]; break;
		case ShooterAIAudioOptions.Engage: soundToPlay = engageSounds[ (int)Random.Range(0, engageSounds.Length) ]; break;
		case ShooterAIAudioOptions.Cover: soundToPlay = coverSounds[ (int)Random.Range(0, coverSounds.Length) ]; break;
		case ShooterAIAudioOptions.Panic: soundToPlay = panicSounds[ (int)Random.Range(0, panicSounds.Length) ]; break;
		case ShooterAIAudioOptions.Charge: soundToPlay = chargeSounds[ (int)Random.Range(0, chargeSounds.Length) ]; break;
			
		}
		
		
		//play the sound
		c_Audio.PlayOneShot( soundToPlay);
		
	}