Esempio n. 1
0
        private void AudioTriggerArea_OnTriggerAreaEvent(object sender, AudioTriggerAreaEventArgs e)
        {
            if (e.triggerEventType == AudioTriggerAreaEventArgs.TriggerEventType.TriggerEnter)
            {
                insideCount++;

                if (insideCount == 1 && initializationSuccesfull)
                {
                    snapshotInstance = FMODUnity.RuntimeManager.CreateInstance(snapshotPath);

                    if (snapshotInstance.isValid())
                    {
                        snapshotInstance.start();
                    }
                    else
                    {
                        Debug.LogError("Snapshot event path is invalid for Reverb Zone " + gameObject.name + ".");
                    }
                }
            }
            else
            {
                insideCount--;

                if (insideCount == 0 && initializationSuccesfull)
                {
                    if (snapshotInstance.isValid())
                    {
                        snapshotInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
                        snapshotInstance.release();
                    }
                }
            }
        }
 /// <summary>
 /// Stop running music and ambience with fade out.
 /// </summary>
 public void StopMusicAmbience()
 {
     music.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
     music.release();
     ambience.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
     ambience.release();
     currentAmbienceEvent = null;
     currentMusicEvent    = null;
 }
Esempio n. 3
0
 /// <summary>
 /// Resets the state of the minigame
 /// </summary>
 public void ResetMinigame()
 {
     waterBoiling_sfx.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
     waterBoiling_sfx.setParameterByName("BucketState", 0);
     bucketBtn.interactable = false;
     timer           = 0;
     bucketImg.color = Color.white;
     bucketTxt.text  = "Place bucket from inventory to continue";
 }
Esempio n. 4
0
        public int PlayVoiceover(string key, string dialogueName, float overrideDuration)
        {
            if (!initializationSuccesfull || string.IsNullOrEmpty(key) || string.IsNullOrEmpty(dialogueName))
            {
                return(-1);
            }

            if (!isSpeaking)
            {
                bool didSucceed = PlayProtocol(key, dialogueName, overrideDuration);

                if (didSucceed)
                {
                    return(1);
                }
                else
                {
                    return(-1);
                }
            }
            else if (eventInstance.isValid())
            {
                // Stop the current dialogue with a quick fade out and then start the new line.
                // <- No click/pop stops, but also enforces the speaker monophony.
                eventInstance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);

                if (coroutineRunning)
                {
                    StopAllCoroutines();
                    coroutineRunning = false;
                }

                // Inform the voiceover manager that the playback handler is busy stopping the previous dialogue line and it should queue the line.
                return(0);
            }
            else // If we are on a customly assigned pacing wait after a line has stopped playing let's abort this wait and start the new line immediately.
            {
                if (coroutineRunning)
                {
                    StopAllCoroutines();
                    coroutineRunning = false;
                    isSpeaking       = false;
                    currentDialogue  = null;
                }

                bool didSucceed = PlayProtocol(key, dialogueName, overrideDuration);

                if (didSucceed)
                {
                    return(1);
                }
                else
                {
                    return(-1);
                }
            }
        }
Esempio n. 5
0
        public void Play(float t)
        {
            Evaluate(t);

            if (!ps.isPlaying)
            {
                ps.Play();
                spiralSoundInstance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
                spiralSoundInstance = FMODUnity.RuntimeManager.CreateInstance(spiralSFX);
                spiralSoundInstance.start();
            }
        }
 IEnumerator WaitForStop(string audio)
 {
     FMOD.Studio.PLAYBACK_STATE state;
     instance.getPlaybackState(out state);
     instance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
     while (state != FMOD.Studio.PLAYBACK_STATE.STOPPED)
     {
         instance.getPlaybackState(out state);
         yield return(null);
     }
     Play(audio);
     yield return(null);
 }
Esempio n. 7
0
 public void OnExit()
 {
     if (isPlayheadInside)
     {
         if (eventInstance.isValid())
         {
             if (stopType != STOP_MODE.None)
             {
                 eventInstance.stop(stopType == STOP_MODE.Immediate ? FMOD.Studio.STOP_MODE.IMMEDIATE : FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
             }
             eventInstance.release();
         }
         isPlayheadInside = false;
     }
 }
Esempio n. 8
0
        public void Restart()
        {
            //print("RESTART FMOD EVENT " + eventName + " INDEX " + index);

            fmodEvent.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
            isReadyToPlay = true;
        }
        public void StopSpotAmbience()
        {
            if (!IsInitialized)
            {
                return;
            }

            if (InstanceAlreadyPlaying && spotAmbienceInstance.isValid())
            {
                spotAmbienceInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
                spotAmbienceInstance.release();
                InstanceAlreadyPlaying = false;
            }
            else
            {
                InstanceAlreadyPlaying = false;
            }
        }
Esempio n. 10
0
 public void Stop()
 {
     if (instance != null)
     {
         instance.stop(AllowFadeout ? FMOD.Studio.STOP_MODE.ALLOWFADEOUT : FMOD.Studio.STOP_MODE.IMMEDIATE);
         instance.release();
         instance = null;
     }
 }
 public void Stop()
 {
     if (instance.isValid())
     {
         instance.stop(AllowFadeout ? FMOD.Studio.STOP_MODE.ALLOWFADEOUT : FMOD.Studio.STOP_MODE.IMMEDIATE);
         instance.release();
         instance.clearHandle();
     }
 }
Esempio n. 12
0
        // -- LISTENERS -- //

        void OnStartEvent(EventPayload data)
        {
            if (_playOneShot)
            {
                if (!_cumulatePlayOneShot)
                {
                    FMODEventInstance.stop(_stopMode);
                }

                PlayOneShot(_FMODEvent, data);
                return;
            }

            playing        = true;
            currentPayload = data;

            FeedParameters(data);
            FMODEventInstance.start();
        }
Esempio n. 13
0
 public static void PreviewStop()
 {
     if (previewEventInstance != null)
     {
         previewEventInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
         previewEventInstance.release();
         previewEventInstance = null;
         previewEventDesc     = null;
         previewBank.unload();
         masterBank.unload();
     }
 }
Esempio n. 14
0
 public static void PreviewStop()
 {
     if (previewEventInstance.isValid())
     {
         previewEventInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
         previewEventInstance.release();
         previewEventInstance.clearHandle();
         previewEventDesc.clearHandle();
         previewBanks.ForEach(x => { x.unload(); x.clearHandle(); });
         masterBanks.ForEach(x => { x.unload(); x.clearHandle(); });
         previewState = PreviewState.Stopped;
     }
 }
        public override void RunLine(LocalizedLine dialogueLine, System.Action onDialogueDeliveryComplete)
        {
            StartCoroutine(DoRunLine(dialogueLine, onDialogueDeliveryComplete));

            IEnumerator DoRunLine(LocalizedLine dialogueLine, System.Action onDialogueDeliveryComplete)
            {
                interrupted = false;

                // Check if this instance is currently playing back another
                // voice over in which case we stop it
                if (lastVoiceOverEvent.isValid())
                {
                    lastVoiceOverEvent.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
                }

                // Create playback event
                FMOD.Studio.EventInstance dialogueInstance;
                try
                {
                    dialogueInstance = FMODUnity.RuntimeManager.CreateInstance(fmodEvent);
                }
                catch (Exception)
                {
                    UnityEngine.Debug.LogWarning("FMOD: Voice over playback failed.", gameObject);
                    throw;
                }

                lastVoiceOverEvent = dialogueInstance;

                // Pin the key string in memory and pass a pointer through the
                // user data
                GCHandle stringHandle = GCHandle.Alloc(dialogueLine.TextID.Remove(0, 5), GCHandleType.Pinned);

                dialogueInstance.setUserData(GCHandle.ToIntPtr(stringHandle));

                dialogueInstance.setCallback(dialogueCallback, FMOD.Studio.EVENT_CALLBACK_TYPE.ALL);
                dialogueInstance.start();
                dialogueInstance.release();

                while (!interrupted && dialogueInstance.isValid())
                {
                    yield return(null);
                }

                if (dialogueInstance.isValid())
                {
                    dialogueInstance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
                }
            }
        }
Esempio n. 16
0
        public void StopInstance()
        {
            if (TriggerOnce && hasTriggered)
            {
                RuntimeManager.DeregisterActiveEmitter(this);
            }

            if (instance.isValid())
            {
                instance.stop(AllowFadeout ? FMOD.Studio.STOP_MODE.ALLOWFADEOUT : FMOD.Studio.STOP_MODE.IMMEDIATE);
                instance.release();
                instance.clearHandle();
            }
        }
Esempio n. 17
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());
            }
        }
Esempio n. 18
0
        void Update()
        {
            // visual smoke shooting out of the gun
            float currentAmmoRatio = m_Weapon.CurrentAmmoRatio;

            if (currentAmmoRatio != m_LastAmmoRatio)
            {
                m_OverheatMaterialPropertyBlock.SetColor("_EmissionColor",
                                                         OverheatGradient.Evaluate(1f - currentAmmoRatio));

                foreach (var data in m_OverheatingRenderersData)
                {
                    data.Renderer.SetPropertyBlock(m_OverheatMaterialPropertyBlock, data.MaterialIndex);
                }

                m_SteamVfxEmissionModule.rateOverTimeMultiplier = SteamVfxEmissionRateMax * (1f - currentAmmoRatio);
            }

            // cooling sound
            if (!coolingSoundPlaying &&
                currentAmmoRatio != 1 &&
                m_Weapon.IsWeaponActive &&
                m_Weapon.IsCooling)
            {
                coolingEvent.start();
                coolingSoundPlaying = true;
            }
            else if (coolingSoundPlaying &&
                     (currentAmmoRatio == 1 || !m_Weapon.IsWeaponActive || !m_Weapon.IsCooling))
            {
                coolingEvent.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
                coolingSoundPlaying = false;
                return;
            }
            coolingEvent.setParameterByName("AmmoRatio", 1 - currentAmmoRatio);

            m_LastAmmoRatio = currentAmmoRatio;
        }
        private void StopAmbience(FMOD.Studio.STOP_MODE stopMode)
        {
            if (!ambienceStarted)
            {
                return;
            }

            if (baseAmbienceInstance.isValid())
            {
                baseAmbienceInstance.stop(stopMode);
                baseAmbienceInstance.release();
            }

            foreach (var spotAmbience in enteredSpotAmbienceAreas)
            {
                if (spotAmbience != null)
                {
                    spotAmbience.StopSpotAmbience();
                }
            }

            ambienceStarted = false;
        }
Esempio n. 20
0
 void OnNoiseLimitReached()
 {
     recruitingSound.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
     escapeSound.start();
 }
Esempio n. 21
0
 //I'm call this function when stages is close up
 public void StopMusic()
 {
     musicEv.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
 }
Esempio n. 22
0
 private void HandleStop()
 {
     CurrentAmbientSFX.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
 }
Esempio n. 23
0
 private void OnDisable()
 {
     instance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
 }
Esempio n. 24
0
 private void HandleStop()
 {
     _playing.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
 }
Esempio n. 25
0
 /// <summary>
 /// Stops the passed in fmod event
 /// </summary>
 /// <param name="fmodEvent"> The name of the event we want to stop </param>
 public void StopFmodEvent(FMOD.Studio.EventInstance fmodEvent)
 {
     fmodEvent.setUserData(IntPtr.Zero);
     fmodEvent.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
     fmodEvent.release();
 }
Esempio n. 26
0
        //private void OnEnable()
        //{
        //    if (m_currState == ManHoleState.Attack)
        //        m_attackSoundInstance
        //}

        private void OnDisable()
        {
            m_attackSoundInstance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
        }
Esempio n. 27
0
        public void Stop()
        {
            checkReady();

            Utilities.checkResult(_instance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT));
        }
Esempio n. 28
0
        void Update()
        {
            // jetpack can only be used if not grounded and jump has been pressed again once in-air
            if (IsPlayergrounded())
            {
                m_CanUseJetpack = false;
            }
            else if (!m_PlayerCharacterController.HasJumpedThisFrame && m_InputHandler.GetJumpInputDown())
            {
                m_CanUseJetpack = true;
            }

            // jetpack usage
            bool jetpackIsInUse = m_CanUseJetpack && IsJetpackUnlocked && CurrentFillRatio > 0f &&
                                  m_InputHandler.GetJumpInputHeld();

            if (jetpackIsInUse)
            {
                // store the last time of use for refill delay
                m_LastTimeOfUse = Time.time;

                float totalAcceleration = JetpackAcceleration;

                // cancel out gravity
                totalAcceleration += m_PlayerCharacterController.GravityDownForce;

                if (m_PlayerCharacterController.CharacterVelocity.y < 0f)
                {
                    // handle making the jetpack compensate for character's downward velocity with bonus acceleration
                    totalAcceleration += ((-m_PlayerCharacterController.CharacterVelocity.y / Time.deltaTime) *
                                          JetpackDownwardVelocityCancelingFactor);
                }

                // apply the acceleration to character's velocity
                m_PlayerCharacterController.CharacterVelocity += Vector3.up * totalAcceleration * Time.deltaTime;

                // consume fuel
                CurrentFillRatio = CurrentFillRatio - (Time.deltaTime / ConsumeDuration);

                for (int i = 0; i < JetpackVfx.Length; i++)
                {
                    var emissionModulesVfx = JetpackVfx[i].emission;
                    emissionModulesVfx.enabled = true;
                }

                if (!playingJetpackSound)
                {
                    jetpackEvent.start();
                    playingJetpackSound = true;
                }
            }
            else
            {
                // refill the meter over time
                if (IsJetpackUnlocked && Time.time - m_LastTimeOfUse >= RefillDelay)
                {
                    float refillRate = 1 / (m_PlayerCharacterController.IsGrounded
                        ? RefillDurationGrounded
                        : RefillDurationInTheAir);
                    CurrentFillRatio = CurrentFillRatio + Time.deltaTime * refillRate;
                }

                for (int i = 0; i < JetpackVfx.Length; i++)
                {
                    var emissionModulesVfx = JetpackVfx[i].emission;
                    emissionModulesVfx.enabled = false;
                }

                // keeps the ratio between 0 and 1
                CurrentFillRatio = Mathf.Clamp01(CurrentFillRatio);

                if (playingJetpackSound)
                {
                    jetpackEvent.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
                    playingJetpackSound = false;
                }
            }
        }
Esempio n. 29
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;
            }
        }