Ejemplo n.º 1
0
 public static void PreviewUpdateParameter(string paramName, float paramValue)
 {
     if (previewEventInstance != null)
     {
         CheckResult(previewEventInstance.setParameterValue(paramName, paramValue));
     }
 }
Ejemplo n.º 2
0
 void SetParameter(string name, float value)
 {
     if (instance != null)
     {
         instance.setParameterValue(name, value);
     }
 }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
0
    //music for level 1, I'm call this function when my stage starts(level game)
    public void LevelMusic()
    {
        musicEv.setParameterValue("FIGHT MUSIC", 100f);
        musicEv.getParameter("HEALTH", out musicPar);
        musicPar.setValue(100);

        musicEv.start();
    }
Ejemplo n.º 5
0
 // Based on Ksliders sounds
 // Minor bug: the pitch is a little too high
 public void PlayMoveSound()
 {
     if (KInputManager.isFocused)
     {
         float timeSinceLast = Time.unscaledTime - lastMoveTime;
         if (!(timeSinceLast < movePlayRate))
         {
             float  inverseLerpValue = Mathf.InverseLerp(slider.minValue, slider.maxValue, slider.value);
             string sound_path       = null;
             if (inverseLerpValue == 1f && lastMoveValue == 1f)
             {
                 if (!playedBoundaryBump)
                 {
                     sound_path         = UISoundHelper.SliderBoundaryHigh;
                     playedBoundaryBump = true;
                 }
             }
             else
             {
                 if (inverseLerpValue == 0f && lastMoveValue == 0f)
                 {
                     if (!playedBoundaryBump)
                     {
                         sound_path         = UISoundHelper.SliderBoundaryLow;
                         playedBoundaryBump = true;
                     }
                 }
                 else if (inverseLerpValue >= 0f && inverseLerpValue <= 1f)
                 {
                     sound_path         = UISoundHelper.SliderMove;
                     playedBoundaryBump = false;
                 }
             }
             if (sound_path != null && sound_path.Length > 0)
             {
                 lastMoveTime  = Time.unscaledTime;
                 lastMoveValue = inverseLerpValue;
                 FMOD.Studio.EventInstance ev = KFMOD.BeginOneShot(sound_path, Vector3.zero, 1f);
                 ev.setParameterValue("sliderValue", inverseLerpValue);
                 ev.setParameterValue("timeSinceLast", timeSinceLast);
                 KFMOD.EndOneShot(ev);
             }
         }
     }
 }
        // Update is called once per frame
        void Update()
        {
            UpdateCameraData();

            foreach (ParameterData parameterDataInstance in _parameters)
            {
                _thisEvent.setParameterValue(parameterDataInstance._fmodParameter, parameterDataInstance.GetParameterValue(_cameraAngle));
            }
        }
Ejemplo n.º 7
0
        void FeedParameters(EventPayload data)
        {
            int floatLoop = data.GetParametersOfType <float>(ref floatParameters);
            int boolLoop  = data.GetParametersOfType <bool>(ref boolParameters);

            for (int i = 0; i < _parameters.Length; ++i)
            {
                FMODEventInstance.setParameterValue(_parameters[i].name, _parameters[i].value);
            }

            for (int i = 0; i < floatLoop; ++i)
            {
                FMODEventInstance.setParameterValue(floatParameters[i], data.Get <float>(floatParameters[i]));
            }

            for (int i = 0; i < boolLoop; ++i)
            {
                // All bool are converted to float. True = 1.0f, False = 0.0f
                FMODEventInstance.setParameterValue(boolParameters[i], data.Get <bool>(boolParameters[i]) ? 1.0f : 0.0f);
            }

            SetupSpacePosition(data.Has(_customPositionInEventPayload), data.Get <Vector3>(_customPositionInEventPayload));
        }
Ejemplo n.º 8
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();
            }
        }
        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.º 10
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;
        }
        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;
        }
Ejemplo n.º 12
0
        void Update()
        {
            if (shooter.canShoot)
            {
                _haloEvent.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
            }

            switch (phase)
            {
            case AIM_PHASE:
                if (startAiming && Input.GetMouseButton(0))
                {
                    // TODO: initiate aim prediction
                    shooter.Shoot(TeleBallPredictorPrefab);
                    GetComponentInChildren <Animator>().Play("Aim");
                }
                else if (Input.GetMouseButtonDown(0))
                {
                    startAiming = true;
                }
                else if (Input.GetMouseButtonUp(0) && startAiming)
                {
                    startAiming = false;
                    // TODO: shoot at mouse

                    _haloEvent = FMODUnity.RuntimeManager.CreateInstance(_haloSoundPath);
                    _haloEvent.start();
                    foreach (var predictor in GameObject.FindGameObjectsWithTag("TelePredictor"))
                    {
                        Destroy(predictor.gameObject);
                    }

                    shooter.Shoot(TeleBallPrefab, true);
                    GetComponentInChildren <Animator>().Play("Throw");

                    phase                  = TELE_PHASE;
                    shooter.canShoot       = false;
                    teleporter.canTeleport = true;
                }
                break;

            case TELE_PHASE:
                if (teleBallRef == null || !teleBallRef.gameObject.activeSelf)
                {
                    phase                   = AIM_PHASE;
                    teleBallRef             = null;
                    teleBallRefAnim         = null;
                    shooter.canShoot        = true;
                    teleBallPositionIsValid = false;
                }
                else if (Input.GetMouseButton(0))
                {
                    // TODO: allow physics to proceed?
                    if (teleBallRef)
                    {
                        teleBallRefAnim.SetOn(false);
                        _haloEvent.setParameterValue("Active", 0);
                    }
                }
                else
                {
                    if (teleBallRef)
                    {
                        teleBallRefAnim.SetOn(true);
                        _haloEvent.setParameterValue("Active", 1);
                    }
                    if (teleBallPositionIsValid)
                    {
                        // TODO: teleport once position on teleBall is valid
                        TeleportToBall();
                    }
                }
                break;
            }
        }