Esempio n. 1
0
    public GameObject PlayTrackMusic_NoLocation_RandomTrackList(List <RARC_Audio_SO> audioSO_List)
    {
        //Stop Other Music
        StopTrackMusic_All();

        //Filter the Possible Tracks First
        List <RARC_Audio_SO> filterdAudioSO_List = new List <RARC_Audio_SO>(audioSO_List);

        filterdAudioSO_List = FilterCurrentTrackOutOfList(filterdAudioSO_List);

        //Random Choice
        int randomChoice = Random.Range(0, audioSO_List.Count);

        //Instantiate New Audio Source Unser Container
        GameObject newTrack = Instantiate(audioTrack_Prefab, audioTrack_Container.transform);

        newTrack.name = audioSO_List[randomChoice].name;

        //SFX Setup
        newTrack.GetComponent <RARC_AudioTab>().SetupAudioTrack(audioSO_List[randomChoice], RARC_DatabaseController.Instance.player_SaveData.settings_MusicVolume, RARC_DatabaseController.Instance.player_SaveData.settings_isMusicMuted);

        //Record The current Track
        currentMusicTrack_SO = audioSO_List[randomChoice];

        //Return Track
        return(newTrack);
    }
Esempio n. 2
0
    public GameObject PlayTrackSFX_NoLocation_SingleTrack(RARC_Audio_SO audioSO)
    {
        //Instantiate New Audio Source Unser Container
        GameObject newTrack = Instantiate(audioTrack_Prefab, audioTrack_Container.transform);

        //SFX Setup
        newTrack.GetComponent <RARC_AudioTab>().SetupAudioTrack(audioSO, RARC_DatabaseController.Instance.player_SaveData.settings_SFXVolume, RARC_DatabaseController.Instance.player_SaveData.settings_isSFXMuted);
        newTrack.name = audioSO.name;

        //Return Track
        return(newTrack);
    }
Esempio n. 3
0
    public void PlayTrackMusic_NoLocation(RARC_Audio_SO audioSO)
    {
        //Stop Other Music
        StopTrackMusic_All();

        //Instantiate New Audio Source User Container
        GameObject newTrack = Instantiate(audioTrack_Prefab, audioTrack_Container.transform);

        newTrack.name = audioSO.name;

        //Record The current Track
        currentMusicTrack_SO = audioSO;

        //Music Setup
        newTrack.GetComponent <RARC_AudioTab>().SetupAudioTrack(audioSO, RARC_DatabaseController.Instance.player_SaveData.settings_MusicVolume, RARC_DatabaseController.Instance.player_SaveData.settings_isMusicMuted);
    }
Esempio n. 4
0
    /////////////////////////////////////////////////////////////////

    public void SetupAudioTrack(RARC_Audio_SO audioSO, float audioTypeSettingsVolume, bool isMuted)
    {
        //Save Scriptable
        currentAudio_SO = audioSO;

        //Save Settings
        isMusic                  = audioSO.isMusic;
        isSFX                    = audioSO.isSFX;
        audioSource.clip         = audioSO.audioClip;
        audioSource.loop         = audioSO.canLoop;
        audioSource.pitch        = audioSO.pitch + (Random.Range(-audioSO.pitchRange, audioSO.pitchRange));
        audioSource.spatialBlend = audioSO.spatialAudioRange;

        //Create a non-linear exponental increae for the voule as audio drop on a logarithmic Rate (Not using the ideal soultion but a close match)
        //float logarithmicFalloffAudio = Mathf.Pow((audioTypeSettingsVolume / 100), 2);
        //audioSource.volume = ((currentAudio_SO.volume + logarithmicFalloffAudio) / 2);
        audioSource.volume = (currentAudio_SO.volume * audioTypeSettingsVolume);

        //Muted Volume
        if (isMuted)
        {
            audioSource.volume = 0;
        }

        //Play Audio
        audioSource.Play();

        //Begin lerping volume of sound
        if (audioSO.canFadeIn == true)
        {
            //Skip If Muted
            if (!isMuted)
            {
                //Begin lerping volume of sound
                StartCoroutine(IAudioVolumeDampeningOnLoad((audioSource.volume / 60), audioSource.volume, currentAudio_SO.fadeInSpeed));
            }
        }

        //Begin Audio Destruction Countdown
        if (audioSO.canLoop == false)
        {
            //Begin Audio Destruction Countdown
            StartCoroutine(IAutoDestoryCountdown(currentAudio_SO.audioClip.length));
        }
    }