Beispiel #1
0
 private void Play(FMODEvent sound, AudioChannel channel)
 {
     if (GetEventID(channel) == sound.Name)
     {
         _channels[channel].getPlaybackState(out PLAYBACK_STATE state);
         if (state == PLAYBACK_STATE.STOPPING)
         {
             Stop(channel, false);
         }
         else
         {
             Array.ForEach(sound.Parameters, p => _channels[channel].setParameterByName(p.Name, p.Value));
             return;
         }
     }
     else
     {
         Stop(channel);
     }
     if (!string.IsNullOrWhiteSpace(sound.Name))
     {
         _channels[channel] = FMODUnity.RuntimeManager.CreateInstance(sound.Name);
         _channels[channel].start();
         Array.ForEach(sound.Parameters, p => _channels[channel].setParameterByName(p.Name, p.Value));
     }
 }
Beispiel #2
0
        private void HandlePlay(FMODEvent music)
        {
            if (default(FMODEvent).Equals(music))
            {
                return;
            }
            bool instantiate = GetInstantiatedEventName(_playing) != music.Name;

            //If it's not the same FMOD Event, then switch over
            if (instantiate)
            {
                HandleStop();
                _playing = FMODUnity.RuntimeManager.CreateInstance(music.Name);
            }

            //Handle all the parameters
            foreach (FMODEventParameterConfig param in music.Parameters)
            {
                _playing.setParameterValue(param.Name, param.Value);
            }

            //Actually start the FMOD Event
            if (instantiate)
            {
                _playing.start();
            }
        }
Beispiel #3
0
 private void SetParam(FMODEvent e, string id, int value)
 {
     if (e.Parameters != null)
     {
         int index = Array.FindIndex(e.Parameters, p => p.Name == id);
         if (index >= 0)
         {
             e.Parameters[index].Value = value;
         }
     }
 }
        public FMODEvent GetFMODEvent(string faction)
        {
            List <PartyMusic> factionPartyMusics = new List <PartyMusic>();

            foreach (PartyMusic p in PartyMusics)
            {
                if (p.Faction == faction)
                {
                    factionPartyMusics.Add(p);
                }
            }
            FMODEvent fmodEvent = factionPartyMusics[UnityEngine.Random.Range(0, factionPartyMusics.Count)].Event;

            return(fmodEvent);
        }
Beispiel #5
0
 void Awake()
 {
     AmbitionApp.Subscribe(PartyMessages.SHOW_ROOM, ConversationMusicStart);
     AmbitionApp.Subscribe(PartyMessages.END_CONVERSATION, ConversationVictorySound);
     AmbitionApp.Subscribe(PartyMessages.FLEE_CONVERSATION, ConversationDefeatSound);
     AmbitionApp.Subscribe <CharacterVO>(PartyMessages.GUEST_REACTION_POSITIVE, GuestPositiveReaction);
     AmbitionApp.Subscribe <CharacterVO>(PartyMessages.GUEST_REACTION_NEUTRAL, GuestNeutralReaction);
     AmbitionApp.Subscribe <CharacterVO>(PartyMessages.GUEST_REACTION_NEGATIVE, GuestNegativeReaction);
     AmbitionApp.Subscribe <CharacterVO>(PartyMessages.GUEST_CHARMED, GuestCharmedReaction);
     AmbitionApp.Subscribe <CharacterVO>(PartyMessages.GUEST_OFFENDED, GuestPutOffReaction);
     AmbitionApp.Subscribe <CharacterVO>(PartyMessages.GUEST_REACTION_BORED, GuestBoredReaction);
     AmbitionApp.Subscribe <string>(GameMessages.SCENE_LOADED, HandleShowMap);
     AmbitionApp.Subscribe <RoomVO>(MapMessage.GO_TO_ROOM, HandleRoomSFX);
     _partyMusic = MusicCollection.GetFMODEvent(partyModel.Party.Faction.ToString());
 }
Beispiel #6
0
        private void HandlePlay(FMODEvent ambientSFX)
        {
            //Is there AmbientSFX currently playing?
            FMOD.Studio.PLAYBACK_STATE playbackState;
            CurrentAmbientSFX.getPlaybackState(out playbackState);
            bool isPlaying = playbackState != FMOD.Studio.PLAYBACK_STATE.STOPPED;

            //If so, wind down the old SFX, then switch in the new FMOD Event
            if (string.IsNullOrEmpty(ambientSFX.Name))
            {
                HandleStop();
            }
            else if (isPlaying)
            {
                //If it's not the same FMOD Event, then switch over
                if (GetInstantiatedEventName(CurrentAmbientSFX) != ambientSFX.Name)
                {
                    HandleStop();
                    CurrentAmbientSFX = FMODUnity.RuntimeManager.CreateInstance(ambientSFX.Name);
                    //Handle all the parameters
                    foreach (FMODEventParameterConfig param in ambientSFX.Parameters)
                    {
                        CurrentAmbientSFX.setParameterValue(param.Name, param.Value);
                    }
                    //Actually start the FMOD Event
                    CurrentAmbientSFX.start();
                }
                //If it is the same track, just adjust the parameters
                else
                {
                    foreach (FMODEventParameterConfig param in ambientSFX.Parameters)
                    {
                        CurrentAmbientSFX.setParameterValue(param.Name, param.Value);
                    }
                }
            }
            else
            {
                CurrentAmbientSFX = FMODUnity.RuntimeManager.CreateInstance(ambientSFX.Name);
                CurrentAmbientSFX.start();
            }
        }
Beispiel #7
0
 private void HandlePlay(FMODEvent ambientSFX)
 {
     FMODUnity.RuntimeManager.PlayOneShot(ambientSFX.Name);
 }
Beispiel #8
0
        public void GuestBoredReaction(GuestVO guest)
        {
            FMODEvent selectedBark = GuestBarkCollection.GetFMODEvent(guest.Gender, "bored");

            AmbitionApp.SendMessage(AudioMessages.PLAY_ONESHOTSFX, selectedBark);
        }
Beispiel #9
0
        public void GuestPutOffReaction(GuestVO guest)
        {
            FMODEvent selectedBark = GuestBarkCollection.GetFMODEvent(guest.Gender, "negative"); //Still waiting on a Put Off Sound Effect

            AmbitionApp.SendMessage(AudioMessages.PLAY_ONESHOTSFX, selectedBark);
        }
Beispiel #10
0
 private void HandlePlayMusic(FMODEvent e) => Play(e, AudioChannel.Music);
Beispiel #11
0
 private void HandlePlayAmbient(FMODEvent e) => Play(e, AudioChannel.Ambient);
Beispiel #12
0
 private void HandlePlaySound(FMODEvent sound) => RuntimeManager.PlayOneShot(sound.Name);
Beispiel #13
0
        public void GuestCharmedReaction(CharacterVO guest)
        {
            FMODEvent selectedBark = GuestBarkCollection.GetFMODEvent(guest.Gender, "charmed");

            AmbitionApp.SendMessage(AudioMessages.PLAY, selectedBark);
        }