示例#1
0
    public void StopRecord(GameEnums.TurnTable turntable)
    {
        AudioSource turntableAudioSource = null;

        switch (turntable)
        {
        case GameEnums.TurnTable.Left:
            turntableAudioSource = _leftTurnTableAudioSource;
            break;

        case GameEnums.TurnTable.Right:
            turntableAudioSource = _rightTurnTableAudioSource;
            break;

        default:
            Debug.LogWarning("Invalid turntable: " + turntable.ToString());
            break;
        }

        if (turntableAudioSource == null)
        {
            Debug.LogWarning("An AudioSource component for the turntable is missing. Please add both AudioSource components to the AudioManager object.");
            return;
        }

        turntableAudioSource.Stop(); // TO DO : Should be crossfaded
    }
示例#2
0
 public void PlayDefaultRecord(GameEnums.TurnTable turntable)
 {
     if (defaultMusicSample != null)
     {
         PlaySample(turntable, defaultMusicSample);
     }
 }
示例#3
0
    public void PlayRecord(GameEnums.TurnTable turntable, GameEnums.MusicColor recordType)
    {
        Sound musicSample = GetMusicSample(recordType);

        if (musicSample == null)
        {
            return;
        }

        PlaySample(turntable, musicSample);
    }
示例#4
0
    private void PlaySample(GameEnums.TurnTable turntable, Sound sample)
    {
        AudioSource turntableAudioSource      = null;
        AudioSource otherTurntableAudioSource = null;

        if (sample == null)
        {
            return;
        }

        switch (turntable)
        {
        case GameEnums.TurnTable.Left:
            turntableAudioSource      = _leftTurnTableAudioSource;
            otherTurntableAudioSource = _rightTurnTableAudioSource;
            break;

        case GameEnums.TurnTable.Right:
            turntableAudioSource      = _rightTurnTableAudioSource;
            otherTurntableAudioSource = _leftTurnTableAudioSource;
            break;

        default:
            Debug.LogWarning("Invalid turntable: " + turntable.ToString());
            break;
        }

        if (turntableAudioSource == null || otherTurntableAudioSource == null)
        {
            Debug.LogWarning("An AudioSource component for the turntable is missing. Please add both AudioSource components to the AudioManager object.");
            return;
        }

        otherTurntableAudioSource.Stop(); // TO DO : Should be crossfaded

        turntableAudioSource.clip   = sample.clip;
        turntableAudioSource.volume = sample.volume;
        turntableAudioSource.pitch  = sample.pitch;
        turntableAudioSource.loop   = sample.loop;
        turntableAudioSource.Play();

        playedRecord = true;
        _currentTurnTableAudioSource = turntableAudioSource;
    }