void Update()
    {
        // Actualizamos las posiciones de los sonidos que tienen efecto Estéreo
        if (positionEvents != null && positionEvents.Count > 0)
        {
            for (int i = 0; i < positionEvents.Count; i++)
            {
                PLAYBACK_STATE state;
                EventInstance  eventInst = positionEvents[i].GetEventInstance();
                eventInst.getPlaybackState(out state);
                if (state == PLAYBACK_STATE.STOPPED)
                {
                    positionEvents.RemoveAt(i);
                }
                else
                {
                    if (!eventInst.Equals(null) && positionEvents.Count > i)
                    {
                        if (!positionEvents[i].Equals(null))
                        {
                            if (positionEvents[i].GetTransform() != null)
                            {
                                eventInst.set3DAttributes(RuntimeUtils.To3DAttributes(positionEvents[i].GetTransform().position));
                            }
                        }
                    }
                }
            }
        }

        SetFXVolume();
        SetMusicVolume();
    }
 public void StopEvent(EventInstance soundEvent, bool fadeout = true)
 {
     if (eventsList.Remove(soundEvent))
     {
         if (fadeout)
         {
             soundEvent.stop(STOP_MODE.ALLOWFADEOUT);
         }
         else
         {
             soundEvent.stop(STOP_MODE.IMMEDIATE);
         }
     }
     else
     {
         if (!soundEvent.Equals(null))
         {
             if (fadeout)
             {
                 soundEvent.stop(STOP_MODE.ALLOWFADEOUT);
             }
             else
             {
                 soundEvent.stop(STOP_MODE.IMMEDIATE);
             }
         }
     }
 }
Esempio n. 3
0
    public void PlayMusic()
    {
        credits_Event = RuntimeManager.CreateInstance(creditsMusic);

        if (!credits_Event.Equals(null))
        {
            credits_Event.start();
        }
    }
Esempio n. 4
0
    public void PlayMusic()
    {
        mainMenu_Event = RuntimeManager.CreateInstance(mainMenuMusic);

        if (!mainMenu_Event.Equals(null))
        {
            mainMenu_Event.start();
        }
    }
Esempio n. 5
0
    public void PlayMusic()
    {
        cutscene_Event = RuntimeManager.CreateInstance(cutsceneMusic);

        if (!cutscene_Event.Equals(null))
        {
            cutscene_Event.start();
        }
    }
Esempio n. 6
0
    public EventInstance PlayMusic(string path)
    {
        EventInstance soundEvent = RuntimeManager.CreateInstance(path);

        if (!soundEvent.Equals(null))
        {
            soundEvent.start();
        }
        return(soundEvent);
    }
Esempio n. 7
0
    //Sonidos que no se mueven
    public void PlayOneShotSound(string path, Vector3 position)
    {
        EventInstance soundEvent = RuntimeManager.CreateInstance(path);

        if (!soundEvent.Equals(null))
        {
            soundEvent.set3DAttributes(RuntimeUtils.To3DAttributes(position));
            soundEvent.start();
            soundEvent.release();
        }
    }
Esempio n. 8
0
    public void PlaySong(int songId)
    {
        if (songId != prevSongId)
        {
            if (!musicEvent.Equals(null))
            {
                musicEvent.stop(STOP_MODE.ALLOWFADEOUT);
            }
            musicEvent = SoundManager.Instance.PlayMusic("event:/Music/song" + songId.ToString(), transform.position);
            prevSongId = songId;
            SoundManager.Instance.music = musicEvent;

            FMOD.RESULT result = musicEvent.getParameter("Dawn", out dawnParameter);

            //Debug.Log(result);


            //Debug.Log("PlaySong");
        }
    }
Esempio n. 9
0
    public EventInstance PlayEvent(string path, Vector3 pos)
    {
        EventInstance soundEvent = RuntimeManager.CreateInstance(path);

        if (!soundEvent.Equals(null))
        {
            soundEvent.set3DAttributes(RuntimeUtils.To3DAttributes(pos));
            soundEvent.start();
            eventsList.Add(soundEvent);
        }
        return(soundEvent);
    }
Esempio n. 10
0
    public void PlayOneShotSound(string path, Transform transform)
    {
        EventInstance soundEvent = RuntimeManager.CreateInstance(path);

        if (!soundEvent.Equals(null))
        {
            soundEvent.set3DAttributes(RuntimeUtils.To3DAttributes(transform.position));
            soundEvent.start();
            SoundManagerMovingSound movingSound = new SoundManagerMovingSound(transform, soundEvent);
            positionEvents.Add(movingSound);
            soundEvent.release();
        }
    }
Esempio n. 11
0
    //Sonidos que queramos controlar des de fuera
    public EventInstance PlayEvent(string path, Vector3 position, float volume)
    {
        EventInstance soundEvent = RuntimeManager.CreateInstance(path);

        if (!soundEvent.Equals(null))
        {
            soundEvent.set3DAttributes(RuntimeUtils.To3DAttributes(position));
            soundEvent.setVolume(volume);
            soundEvent.start();
        }

        return(soundEvent);
    }
Esempio n. 12
0
    public EventInstance PlayEvent(string path, Transform transform)
    {
        EventInstance soundEvent = RuntimeManager.CreateInstance(path);

        if (!soundEvent.Equals(null))
        {
            soundEvent.set3DAttributes(RuntimeUtils.To3DAttributes(transform.position));
            soundEvent.start();
            SoundManagerMovingSound movingSound = new SoundManagerMovingSound(transform, soundEvent);
            positionEvents.Add(movingSound);
            eventsList.Add(soundEvent);
        }
        return(soundEvent);
    }
Esempio n. 13
0
    //Sonidos que se mueven con Entity
    public void PlayOneShotSound(string path, Entity entity)
    {
        EventInstance soundEvent = RuntimeManager.CreateInstance(path);
        Vector3       position   = _entityManager.GetComponentData <Translation>(entity).Value;

        if (!soundEvent.Equals(null))
        {
            soundEvent.set3DAttributes(RuntimeUtils.To3DAttributes(position));
            soundEvent.start();
            MovingSound movingSound = new MovingSound(soundEvent, entity);
            movingEvents.Add(movingSound);
            soundEvent.release();
        }
    }
    public void StopSustainedSoundEffect(int soundId)
    {
        EventInstance sustainedSound = _sustainedEventInstances[soundId];

        if (sustainedSound.Equals(default(EventInstance)))
        {
            throw new Exception("Unable to find sustained sound");
        }

        RESULT result = sustainedSound.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);

        if (result != RESULT.OK)
        {
            throw new Exception("Unable to stop sustained sound " + result);
        }
    }
Esempio n. 15
0
    public void PlayOneShotSound(string path, Vector3 pos, List <SoundManagerParameter> parameters = null)
    {
        EventInstance soundEvent = RuntimeManager.CreateInstance(path);

        if (!soundEvent.Equals(null))
        {
            if (parameters != null)
            {
                for (int i = 0; i < parameters.Count; i++)
                {
                    soundEvent.setParameterByName(parameters[i].GetName(), parameters[i].GetValue());
                }
            }

            soundEvent.set3DAttributes(RuntimeUtils.To3DAttributes(pos));
            soundEvent.start();
            soundEvent.release();
        }
    }