// Use this for initialization public void Init(LevelManager lm, float t) { _levelManager = lm; timeShowing = t; // Event description for creating the scream event instance FMOD.Studio.EventDescription screamDescription; SoundSystem.instance.ErrorCheck(SoundSystem.instance.GetStudioSoundSystem().getEvent("event:/Scream", out screamDescription)); SoundSystem.instance.ErrorCheck(screamDescription.createInstance(out _screamInstance)); // Event description for creating the spawn event instance FMOD.Studio.EventDescription spawnDescription; SoundSystem.instance.ErrorCheck(SoundSystem.instance.GetStudioSoundSystem().getEvent("event:/HelloCivil", out spawnDescription)); SoundSystem.instance.ErrorCheck(spawnDescription.createInstance(out _spawnInstance)); // Set the 3d attributes of this sound depending on this script's owner _attributes3D = FMODUnity.RuntimeUtils.To3DAttributes(this.gameObject, this.gameObject.GetComponent <Rigidbody>()); _screamInstance.set3DAttributes(_attributes3D); _spawnInstance.set3DAttributes(_attributes3D); // Set the minimum and maximum distances for this sound event SoundSystem.instance.ErrorCheck(_screamInstance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, 3.0f)); SoundSystem.instance.ErrorCheck(_screamInstance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, 30.0f)); // Set the minimum and maximum distances for scream event instance SoundSystem.instance.ErrorCheck(_spawnInstance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, 3.0f)); SoundSystem.instance.ErrorCheck(_spawnInstance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, 30.0f)); _spawnInstance.start(); }
public float this[EventProperty index] { get { float value; _eventInstance.getProperty((EVENT_PROPERTY)index, out value).Check(); return(value); } set { _eventInstance.setProperty((EVENT_PROPERTY)index, value); } }
void Update() { if (enemyList.Count == 0) { maxNumOfEnemies += 1; EnemyDrop(); if (maxNumOfEnemies > maxZombiesInWave) { maxZombiesInWave = maxNumOfEnemies; } } ambience.setProperty(0, maxZombiesInWave / enemyList.Count); }
public void Play() { if (_HasTriggered && _TriggerOnce) { return; } if (string.IsNullOrEmpty(_EventMusic)) { return; } if (_EventDescription == null) { GetEvent(); } bool isOneshot = false; if (!_EventMusic.StartsWith("snapshot", System.StringComparison.CurrentCultureIgnoreCase)) { _EventDescription.isOneshot(out isOneshot); } bool is3D; _EventDescription.is3D(out is3D); if (_EventInstance != null && !_EventInstance.isValid()) { _EventInstance = null; } // Let previous oneshot instances play out if (isOneshot && _EventInstance != null) { _EventInstance.release(); _EventInstance = null; } if (_EventInstance == null) { _EventDescription.createInstance(out _EventInstance); if (is3D) { var rigidBody = GetComponent <Rigidbody>(); var rigidBody2D = GetComponent <Rigidbody2D>(); var transform = GetComponent <Transform>(); if (rigidBody) { _EventInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject, rigidBody)); FMODUnity.RuntimeManager.AttachInstanceToGameObject(_EventInstance, transform, rigidBody); } else { _EventInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject, rigidBody2D)); FMODUnity.RuntimeManager.AttachInstanceToGameObject(_EventInstance, transform, rigidBody2D); } } } foreach (var param in Params) { _EventInstance.setParameterValue(param.Name, param.Value); } if (is3D && _OverrideAttenuation) { _EventInstance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, _OverrideMinDistance); _EventInstance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, _OverrideMaxDistance); } /*_EventCallback = new FMOD.Studio.EVENT_CALLBACK(StudioEventCallback); * _EventInstance.setCallback(_EventCallback, FMOD.Studio.EVENT_CALLBACK_TYPE.TIMELINE_BEAT);*/ _EventInstance.start(); //add 3d attributes here when converting to a more base script _HasTriggered = true; }