Ejemplo n.º 1
0
        public void Play()
        {
            if (TriggerOnce && hasTriggered)
            {
                return;
            }

            if (String.IsNullOrEmpty(Event))
            {
                return;
            }

            if (eventDescription == null)
            {
                Lookup();
                eventDescription.isOneshot(out isOneshot);
            }

            // Let previous oneshot instances play out
            if (isOneshot && instance != null)
            {
                instance.release();
                instance = null;
            }

            if (instance == null)
            {
                eventDescription.createInstance(out instance);
            }

            instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, cachedRigidBody));
            foreach (var param in Params)
            {
                instance.setParameterValue(param.Name, param.Value);
            }
            instance.start();

            hasTriggered = true;

            // Only want to update if we need to set 3D attributes
            bool is3d = false;

            eventDescription.is3D(out is3d);
            if (is3d)
            {
                enabled = true;
            }
        }
Ejemplo n.º 2
0
        protected void PlayEvent()
        {
            if (!string.IsNullOrEmpty(eventName))
            {
                eventInstance = FMODUnity.RuntimeManager.CreateInstance(eventName);
                // Only attach to object if the game is actually playing, not auditioning.
                if (Application.isPlaying && TrackTargetObject)
                {
                    Rigidbody rb = TrackTargetObject.GetComponent <Rigidbody>();
                    if (rb)
                    {
                        FMODUnity.RuntimeManager.AttachInstanceToGameObject(eventInstance, TrackTargetObject.transform, rb);
                    }
                    else
                    {
                        FMODUnity.RuntimeManager.AttachInstanceToGameObject(eventInstance, TrackTargetObject.transform, TrackTargetObject.GetComponent <Rigidbody2D>());
                    }
                }
                else
                {
                    eventInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(Vector3.zero));
                }

                foreach (var param in parameters)
                {
                    eventInstance.setParameterByID(param.ID, param.Value);
                }

                eventInstance.start();
            }
        }
Ejemplo n.º 3
0
        public void Play()
        {
            if (TriggerOnce && hasTriggered)
            {
                return;
            }

            if (eventDescription == null)
            {
                Lookup();
            }

            eventDescription.createInstance(out instance);
            instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, cachedRigidBody));
            instance.start();

            hasTriggered = true;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Use this for overriding the event's 3D-attenuation settings (the min/max distance of the sound, usually set in the 3D-panner of the event).
        /// </summary>
        public static void PlayOneShot3D(string eventPath, Vector3 position, float minDistanceOverride, float maxDistanceOverride)
        {
            FMOD.Studio.EventInstance eventInstance = CreateFmodEventInstance(eventPath);

            Set3DAttenuationSettings(eventInstance, minDistanceOverride, maxDistanceOverride);

            eventInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(position));
            eventInstance.start();
            eventInstance.release();
        }
Ejemplo n.º 5
0
        public static void AttachInstanceToGameObject(FMOD.Studio.EventInstance instance, Transform transform, Rigidbody rigidBody)
        {
            instance.set3DAttributes(RuntimeUtils.To3DAttributes(transform, rigidBody));
            var attachedInstance = new AttachedInstance();

            attachedInstance.transform = transform;
            attachedInstance.instance  = instance;
            attachedInstance.rigidBody = rigidBody;
            Instance.attachedInstances.Add(attachedInstance);
        }
Ejemplo n.º 6
0
        public static void AttachInstanceToGameObject(FMOD.Studio.EventInstance instance, Transform transform, Rigidbody2D rigidBody2D)
        {
            var attachedInstance = new AttachedInstance();

            attachedInstance.transform   = transform;
            attachedInstance.instance    = instance;
            attachedInstance.rigidBody2D = rigidBody2D;
            attachedInstance.rigidBody   = null;
            instance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(transform, rigidBody2D));
            Instance.attachedInstances.Add(attachedInstance);
        }
 /// <summary>
 /// Play ambience in FMOD with defined Fade Time.
 /// </summary>
 /// <param name="ambienceEvent"></param>
 /// <param name="fadeTime"></param>
 public void PlayAmbience(string ambienceEvent, float fadeTime)
 {
     currentAmbienceEvent = ambienceEvent;
     ambience             = FMODUnity.RuntimeManager.CreateInstance(ambienceEvent);
     ambience.setParameterByName("Fade In", fadeTime);
     if (FMODUtils.IsInstance3D(ambience))
     {
         ambience.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(Camera.main.transform));
     }
     ambience.start();
 }
 /// <summary>
 /// Play music in FMOD with defined Fade Time.
 /// </summary>
 /// <param name="musicEvent"></param>
 /// <param name="fadeTime"></param>
 public void PlayMusic(string musicEvent, float fadeTime)
 {
     currentMusicEvent = musicEvent;
     music             = FMODUnity.RuntimeManager.CreateInstance(musicEvent);
     music.setParameterByName("Fade In", fadeTime);
     if (FMODUtils.IsInstance3D(music))
     {
         music.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(Camera.main.transform));
     }
     music.start();
 }
Ejemplo n.º 9
0
 public static void PreviewUpdatePosition(float distance, float orientation)
 {
     if (previewEventInstance != null)
     {
         // Listener at origin
         FMOD.ATTRIBUTES_3D pos = new FMOD.ATTRIBUTES_3D();
         pos.position.x = (float)Math.Sin(orientation) * distance;
         pos.position.y = (float)Math.Cos(orientation) * distance;
         pos.forward.x  = 1.0f;
         pos.up.z       = 1.0f;
         CheckResult(previewEventInstance.set3DAttributes(pos));
     }
 }
Ejemplo n.º 10
0
        public static void AttachInstanceToGameObject(FMOD.Studio.EventInstance instance, Transform transform)
        {
            AttachedInstance attachedInstance = Instance.attachedInstances.Find(x => x.instance.handle == instance.handle);

            if (attachedInstance == null)
            {
                attachedInstance = new AttachedInstance();
                Instance.attachedInstances.Add(attachedInstance);
            }

            instance.set3DAttributes(RuntimeUtils.To3DAttributes(transform));
            attachedInstance.transform = transform;
            attachedInstance.instance  = instance;
        }
Ejemplo n.º 11
0
        // Update is called once per frame
        protected override void Update()
        {
            float   tipHeight = transform.Find("Tip").transform.localScale.y - 0.33f;
            Vector3 tip       = transform.Find("Tip").transform.position;

            if (Physics.Raycast(tip, transform.up, out touch, tipHeight))
            {
                if (!(touch.collider.tag == "Ground"))
                {
                    return;
                }
                this.blackboard = touch.collider.GetComponent <BlackboardControllerCopy>();
                Debug.Log("Touching!");

                this.blackboard.SetColor(new Color(1, 1, 1, 1));
                this.blackboard.SetTouchPosition(touch.textureCoord.x, touch.textureCoord.y);
                this.blackboard.ToggleTouch(true);

                rigidbody.freezeRotation = true;

                if (!lastTouch)
                {
                    lastTouch = true;
                    chalk     = FMODUnity.RuntimeManager.CreateInstance(chalkEvent);
                    chalk.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
                    chalk.start();
                }
            }
            else
            {
                if (lastTouch)
                {
                    this.blackboard.ToggleTouch(false);
                }

                rigidbody.freezeRotation = false;
                chalk.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
                chalk.release();
                lastTouch = false;
            }

            if (this.IsGrabbed() && FrustumCheckerCharacter() && !voIsPlayed)
            {
                StartCoroutine(StareTimerCharacter());
            }
        }
Ejemplo n.º 12
0
        // -- //

        void Start()
        {
            if (_startEvent.Length > 0)
            {
                EventManager.AddListener(_startEvent, OnStartEvent);

                if (!_playOneShot)
                {
                    FMODEventInstance = FMODUnity.RuntimeManager.CreateInstance(_FMODEvent);
                    FMODEventInstance.set3DAttributes(spacePosition);

                    if (_stopEvent.Length > 0)
                    {
                        EventManager.AddListener(_stopEvent, OnStopEvent);
                    }
                }
            }
        }
Ejemplo n.º 13
0
        void SetupSpacePosition(bool playAtCustomPosition, Vector3 customPosition)
        {
            Vector3 position = customPosition;
            Vector3 up       = Vector3.zero;
            Vector3 forward  = Vector3.zero;

            if (_playOnThisObject || !playAtCustomPosition)
            {
                Transform target = _playOnThisObject || _customTarget == null ? transform : _customTarget;
                position = target.position;
                up       = target.up;
                forward  = target.forward;
            }

            spacePosition.position = FMODUnity.RuntimeUtils.ToFMODVector(position);
            spacePosition.up       = FMODUnity.RuntimeUtils.ToFMODVector(up);
            spacePosition.forward  = FMODUnity.RuntimeUtils.ToFMODVector(forward);

            FMODEventInstance.set3DAttributes(spacePosition);
        }
Ejemplo n.º 14
0
        private void FmodSoundEvent(string tag)
        {
            path = string.Empty;
            foreach (var e in events)
            {
                if (tag == e.tag)
                {
                    path = e.eventPath;
                }
            }
            if (path == string.Empty)
            {
                LLLog.LogE("Robot", string.Format("Event Tag [{0}] not found", tag));
                return;
            }

            fmodEvent = FMODUnity.RuntimeManager.CreateInstance(string.Format(path, robotIndex));
            fmodEvent.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(Vector3.zero));
            fmodEvent.start();
        }
Ejemplo n.º 15
0
        private void Awake()
        {
            if (!DOAwake())
            {
                return;
            }

            instance = this;

            debugDisplay.SetActive(false);

            levelValues.UpdateValuesByCSV(false);

            fmodEvent_StartGame = FMODUnity.RuntimeManager.CreateInstance("event:/Systeme/Jingle_Annonce_DébutJeu");
            fmodEvent_StartGame.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(Vector3.zero));
            fmodEvent_StartGame = FMODUnity.RuntimeManager.CreateInstance("event:/Systeme/Jingle_Annonce_Programme");
            fmodEvent_StartGame.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(Vector3.zero));

            productionText.text = "0";
        }
Ejemplo n.º 16
0
        protected void PlayEvent()
        {
            if (!eventReference.IsNull)
            {
                eventInstance = RuntimeManager.CreateInstance(eventReference);

                // Only attach to object if the game is actually playing, not auditioning.
                if (Application.isPlaying && TrackTargetObject)
                {
#if UNITY_PHYSICS_EXIST
                    if (TrackTargetObject.GetComponent <Rigidbody>())
                    {
                        RuntimeManager.AttachInstanceToGameObject(eventInstance, TrackTargetObject.transform, TrackTargetObject.GetComponent <Rigidbody>());
                    }
                    else
#endif
#if UNITY_PHYSICS2D_EXIST
                    if (TrackTargetObject.GetComponent <Rigidbody2D>())
                    {
                        RuntimeManager.AttachInstanceToGameObject(eventInstance, TrackTargetObject.transform, TrackTargetObject.GetComponent <Rigidbody2D>());
                    }
                    else
#endif
                    {
                        RuntimeManager.AttachInstanceToGameObject(eventInstance, TrackTargetObject.transform);
                    }
                }
                else
                {
                    eventInstance.set3DAttributes(RuntimeUtils.To3DAttributes(Vector3.zero));
                }

                foreach (var param in parameters)
                {
                    eventInstance.setParameterByID(param.ID, param.Value);
                }

                eventInstance.setVolume(currentVolume);
                eventInstance.start();
            }
        }
Ejemplo n.º 17
0
        public void PlayInstance()
        {
            if (!instance.isValid())
            {
                instance.clearHandle();
            }

            // Let previous oneshot instances play out
            if (isOneshot && instance.isValid())
            {
                instance.release();
                instance.clearHandle();
            }

            bool is3D;

            eventDescription.is3D(out is3D);

            if (!instance.isValid())
            {
                eventDescription.createInstance(out instance);

                // Only want to update if we need to set 3D attributes
                if (is3D)
                {
                    var transform = GetComponent <Transform>();
#if UNITY_PHYSICS_EXIST
                    if (GetComponent <Rigidbody>())
                    {
                        Rigidbody rigidBody = GetComponent <Rigidbody>();
                        instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody));
                        RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody);
                    }
                    else
#endif
#if UNITY_PHYSICS2D_EXIST
                    if (GetComponent <Rigidbody2D>())
                    {
                        var rigidBody2D = GetComponent <Rigidbody2D>();
                        instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody2D));
                        RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody2D);
                    }
                    else
#endif
                    {
                        instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject));
                        RuntimeManager.AttachInstanceToGameObject(instance, transform);
                    }
                }
            }

            foreach (var param in Params)
            {
                instance.setParameterByID(param.ID, param.Value);
            }

            foreach (var cachedParam in cachedParams)
            {
                instance.setParameterByID(cachedParam.ID, cachedParam.Value);
            }

            if (is3D && OverrideAttenuation)
            {
                instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, OverrideMinDistance);
                instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, OverrideMaxDistance);
            }

            instance.start();

            hasTriggered = true;
        }
Ejemplo n.º 18
0
 private void PlayVoiceFmodSoundEvent(List <string> voices)
 {
     fmodEvent_Voice = FMODUnity.RuntimeManager.CreateInstance(string.Format(voices[Random.Range(0, voices.Count)], robotIndex));
     fmodEvent_Voice.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(Vector3.zero));
     fmodEvent_Voice.start();
 }
        public void Play()
        {
            if (TriggerOnce && hasTriggered)
            {
                return;
            }

            if (String.IsNullOrEmpty(Event))
            {
                return;
            }

            if (!eventDescription.isValid())
            {
                Lookup();
            }

            if (!Event.StartsWith(SnapshotString, StringComparison.CurrentCultureIgnoreCase))
            {
                eventDescription.isOneshot(out isOneshot);
            }
            bool is3D;

            eventDescription.is3D(out is3D);

            if (!instance.isValid())
            {
                instance.clearHandle();
            }

            // Let previous oneshot instances play out
            if (isOneshot && instance.isValid())
            {
                instance.release();
                instance.clearHandle();
            }

            if (!instance.isValid())
            {
                eventDescription.createInstance(out instance);

                // Only want to update if we need to set 3D attributes
                if (is3D)
                {
                    var rigidBody   = GetComponent <Rigidbody>();
                    var rigidBody2D = GetComponent <Rigidbody2D>();
                    var transform   = GetComponent <Transform>();
                    if (rigidBody)
                    {
                        instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody));
                        RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody);
                    }
                    else
                    {
                        instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody2D));
                        RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody2D);
                    }
                }
            }

            foreach (var param in Params)
            {
                instance.setParameterValue(param.Name, param.Value);
            }

            if (is3D && OverrideAttenuation)
            {
                instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, OverrideMinDistance);
                instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, OverrideMaxDistance);
            }

            instance.start();

            hasTriggered = true;
        }
Ejemplo n.º 20
0
        public void Play()
        {
            if (TriggerOnce && hasTriggered)
            {
                return;
            }

            if (String.IsNullOrEmpty(Event))
            {
                return;
            }

            if (eventDescription == null)
            {
                Lookup();
            }

            bool isOneshot = false;

            if (!Event.StartsWith("snapshot", StringComparison.CurrentCultureIgnoreCase))
            {
                eventDescription.isOneshot(out isOneshot);
            }
            bool is3D;

            eventDescription.is3D(out is3D);

            if (instance != null && !instance.isValid())
            {
                instance = null;
            }

            // Let previous oneshot instances play out
            if (isOneshot && instance != null)
            {
                instance.release();
                instance = null;
            }

            if (instance == null)
            {
                eventDescription.createInstance(out instance);

                // Only want to update if we need to set 3D attributes
                if (is3D)
                {
                    var rigidBody = GetComponent <Rigidbody>();
                    var transform = GetComponent <Transform>();
                    instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody));
                    RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody);
                }
            }

            foreach (var param in Params)
            {
                instance.setParameterValue(param.Name, param.Value);
            }

            instance.start();

            hasTriggered = true;
        }
Ejemplo n.º 21
0
 private void PlayVoiceFmodSoundEvent(string voice)
 {
     fmodEvent_Voice = FMODUnity.RuntimeManager.CreateInstance(string.Format(voice, robotIndex));
     fmodEvent_Voice.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(Vector3.zero));
     fmodEvent_Voice.start();
 }
        public void Play(string audioFile)
        {
            if (String.IsNullOrEmpty(audioFile))
            {
                return;
            }

            if (TriggerOnce && hasTriggered)
            {
                return;
            }

            if (String.IsNullOrEmpty(Event))
            {
                return;
            }

            if (!eventDescription.isValid())
            {
                Lookup();
            }

            bool isOneshot = false;

            if (!Event.StartsWith("snapshot", StringComparison.CurrentCultureIgnoreCase))
            {
                eventDescription.isSnapshot(out isOneshot);
            }

            bool is3D = false;

            eventDescription.is3D(out is3D);

            if (!instance.isValid())
            {
                instance.clearHandle();
            }

            if (isOneshot && instance.isValid())
            {
                instance.release();
                instance.clearHandle();
            }

            if (!instance.isValid())
            {
                eventDescription.createInstance(out instance);

                if (is3D)
                {
                    var rigidBody   = GetComponent <Rigidbody>();
                    var rigidBody2D = GetComponent <Rigidbody2D>();
                    var transform   = GetComponent <Transform>();
                    if (rigidBody)
                    {
                        instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody));
                        RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody);
                    }
                    else
                    {
                        instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody2D));
                        RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody2D);
                    }
                }
            }

            foreach (var param in Params)
            {
                instance.setParameterValue(param.Name, param.Value);
            }

            if (is3D && OverrideAttenuation)
            {
                instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, OverrideMinDistance);
                instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, OverrideMaxDistance);
            }
            ExtensionsManager.PlayProgrammerSound(audioFile, this.instance);

            hasTriggered = true;
        }