Exemple #1
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());
            }
        }
        private void StartAmbience()
        {
            if (ambienceStarted)
            {
                return;
            }

            baseAmbienceInstance = FMODUnity.RuntimeManager.CreateInstance(baseAmbience);

            if (baseAmbienceInstance.isValid())
            {
                baseAmbienceInstance.setVolume(InsideStatus);
                baseAmbienceInstance.start();
            }

            ambienceStarted = true;
        }
Exemple #3
0
        public static void PreviewEvent(EditorEventRef eventRef)
        {
            bool load = true;

            if (previewEventDesc.isValid())
            {
                Guid guid;
                previewEventDesc.getID(out guid);
                if (guid == eventRef.Guid)
                {
                    load = false;
                }
                else
                {
                    PreviewStop();
                }
            }

            if (load)
            {
                masterBanks.Clear();

                foreach (EditorBankRef masterBankRef in EventManager.MasterBanks)
                {
                    FMOD.Studio.Bank masterBank;
                    CheckResult(System.loadBankFile(masterBankRef.Path, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out masterBank));
                    masterBanks.Add(masterBank);
                }

                if (!EventManager.MasterBanks.Exists(x => eventRef.Banks.Contains(x)))
                {
                    CheckResult(System.loadBankFile(eventRef.Banks[0].Path, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out previewBank));
                }
                else
                {
                    previewBank.clearHandle();
                }

                CheckResult(System.getEventByID(eventRef.Guid, out previewEventDesc));
                CheckResult(previewEventDesc.createInstance(out previewEventInstance));
            }

            CheckResult(previewEventInstance.start());
            previewState = PreviewState.Playing;
        }
Exemple #4
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;
        }
        /// <summary>
        /// set up listeners on start
        /// </summary>
        private void Start()
        {
            buttonPressed_SFX = FMODUnity.RuntimeManager.CreateInstance("event:/Interface/InGame_ButtonPressed");

            // fire stoke button gives small boost to temperature on click and can only be clicked every fireStokeButtonWaitTime
            fireStokeButton.onClick.AddListener(() => {
                buttonPressed_SFX.start();
                if (Resources.Instance.FuelAmount > 0)
                {
                    Resources.Instance.Temperature += fireStokeIncrease;
                    fireStokeButton.interactable    = false;
                    fireStokeIndicatorText.text     = "Cannot stoke right now";
                    // we're calling startcoroutine from manager because the GO FireRefueling is attached to
                    // can be SetActive(false), which breaks coroutines
                    manager.StartCoroutine(WaitToReactivateButton());
                }
            });
        }
Exemple #6
0
        void Start()
        {
            TotalPointsWon = 0;
            ChickensSaved  = 0;
            DontDestroyOnLoad(this);
            FiredNoiseLimit = false;
            Assert.IsNotNull(NoiseMeter);
            TotalNoise = 0;
            Events.Noise.IncreaseNoise += OnNoiseIncreased;
            NoiseLimit = DEFAULT_NOISE_LIMIT;
            Events.Noise.NoiseLimitReached += OnNoiseLimitReached;

            recruitingSound = FMODUnity.RuntimeManager.CreateInstance(RecruitingSoundEvent);

            escapeSound = FMODUnity.RuntimeManager.CreateInstance(EscapeSoundEvent);
            recruitingSound.start();

            Events.Recruitment.Nirvana += OnNir;
        }
Exemple #7
0
 /// <summary>
 /// Toggles the bucket's UI element
 /// </summary>
 /// <param name="state">The new state of the bucket's UI element</param>
 public void ToggleBucket(bool state)
 {
     if (state)
     {
         waterBoiling_sfx.start();
     }
     else
     {
         waterBoiling_sfx.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
     }
     bucketBtn.interactable = state;
     bucketImg.sprite       = manager.GetBucketSprite(manager.BucketFillState);
     if (!state && manager.BucketFillState == BucketState.BOILED)
     {
         waterSplashing_sfx.start();
         Resources.Instance.AddWater(Constants.WATER_PER_BUCKET);
         manager.BucketFillState = BucketState.EMPTY;
     }
 }
Exemple #8
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();
        }
Exemple #9
0
        public void Play(float volume = 1.0f, GameObject parent = null, Rigidbody rb = null, FmodParamData[] paramData = null)
        {
            //print("PLAY FMOD EVENT " + eventName + " INDEX " + index);
            fmodEvent.setVolume(volume);
            if (parent != null && rb != null)
            {
                FMODUnity.RuntimeManager.AttachInstanceToGameObject(fmodEvent, parent.transform, rb);
            }
            if (paramData != null)
            {
                for (int i = 0; i < paramData.Length; i++)
                {
                    FmodFacade.instance.SetFmodParameterValue(fmodEvent, paramData[i].paramName, paramData[i].paramValue);
                }
            }

            fmodEvent.start();
            isReadyToPlay = false;
        }
Exemple #10
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();
            }
        }
Exemple #11
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();
        }
Exemple #12
0
 /// <summary>
 /// Plays the passed in fmod event as a one shot event, meaning it is set to release the event automatically as soon as it stops playing.
 /// This allows for instanced fmod events without letting them infinitely build up.
 /// </summary>
 /// <param name="fmodEvent"> The name of the event we want to play as a one shot event </param>
 /// <param name="volume"> The volume of the event we want to play as a one shot event </param>
 /// <param name="paramData"> An array of param data that should be passed to our fmod event before playing it </param>
 public void PlayOneShotFmodEvent(FMOD.Studio.EventInstance fmodEvent, float volume = 1.0f, FmodParamData[] paramData = null)
 {
     if (paramData != null)
     {
         for (int i = 0; i < paramData.Length; i++)
         {
             SetFmodParameterValue(fmodEvent, paramData[i].paramName, paramData[i].paramValue);
         }
     }
     fmodEvent.setVolume(volume);
     if (debugOneShotEvents)
     {
         Debug.Log("1. START ONE SHOT EVENT");
         FMOD.Studio.EVENT_CALLBACK stoppedOneShotEventCallback;
         stoppedOneShotEventCallback = new FMOD.Studio.EVENT_CALLBACK(StoppedOneShotEventCallback);
         fmodEvent.setCallback(stoppedOneShotEventCallback, FMOD.Studio.EVENT_CALLBACK_TYPE.STOPPED);
     }
     fmodEvent.start();
     fmodEvent.release();
 }
Exemple #13
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();
            }
        }
Exemple #14
0
        public override void OnEnter()
        {
            if (soundClip == null)
            {
                Continue();
                return;
            }

            soundEventInstance = FMODUnity.RuntimeManager.CreateInstance(soundClip);
            soundEventInstance.start();

            if (waitUntilFinished)
            {
                int         length;
                FMOD.RESULT res = FMODUnity.RuntimeManager.GetEventDescription(soundClip).getLength(out length);
                Invoke("DoWait", length / 1000);
            }
            else
            {
                Continue();
            }
        }
Exemple #15
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;
        }
        public static void PreviewEvent(EditorEventRef eventRef)
        {
            bool load = true;

            if (previewEventDesc != null)
            {
                Guid guid;
                previewEventDesc.getID(out guid);
                if (guid == eventRef.Guid)
                {
                    load = false;
                }
                else
                {
                    PreviewStop();
                }
            }

            if (load)
            {
                CheckResult(System.loadBankFile(EventManager.MasterBank.Path, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out masterBank));
                if (eventRef.Banks[0] != EventManager.MasterBank)
                {
                    CheckResult(System.loadBankFile(eventRef.Banks[0].Path, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out previewBank));
                }
                else
                {
                    previewBank = null;
                }

                CheckResult(System.getEventByID(eventRef.Guid, out previewEventDesc));
                CheckResult(previewEventDesc.createInstance(out previewEventInstance));
            }

            CheckResult(previewEventInstance.start());
            previewState = PreviewState.Playing;
        }
Exemple #17
0
        /// <summary>
        /// Sets up event listener for snow on start
        /// </summary>
        private void Start()
        {
            // Init audio
            snowballGeneration_sfx = FMODUnity.RuntimeManager.CreateInstance("event:/SFX/SnowballGeneration");
            dropSnowInBucket_sfx   = FMODUnity.RuntimeManager.CreateInstance("event:/SFX/DropSnowInBucket");

            snowBtn.onClick.AddListener(() => {
                snowballGeneration_sfx.start();
                if (spawnedDraggables.Count < 3)
                {
                    RectTransform parentTransform = snowDraggableTemplate.transform.parent.GetComponent <RectTransform>();
                    for (int i = 0; i < 3; i++)
                    {
                        GameObject instance = Instantiate(snowDraggableTemplate.gameObject, snowDraggableTemplate.transform.parent);
                        instance.SetActive(true);
                        RectTransform instanceRT = instance.GetComponent <RectTransform>();
                        switch (i)
                        {
                        case 0:
                            instanceRT.anchoredPosition += parentTransform.rect.size / 2 * new Vector2(1, -1) - new Vector2(-300, -100);
                            break;

                        case 1:
                            instanceRT.anchoredPosition += parentTransform.rect.size / 2 * new Vector2(1, -1) - new Vector2(-150, -50);
                            break;

                        case 2:
                            instanceRT.anchoredPosition += parentTransform.rect.size / 2 * new Vector2(1, -1) - new Vector2(0, -100);
                            break;
                        }
                        spawnedDraggables.Add(instance.GetComponent <DraggableSprite>());
                    }
                }
            });
            ResetMinigame();
        }
Exemple #18
0
        public void Start()
        {
            checkReady();

            Utilities.checkResult(_instance.start());
        }
Exemple #19
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 static void PreviewEvent(EditorEventRef eventRef, Dictionary <string, float> previewParamValues)
        {
            bool load = true;

            if (previewEventDesc.isValid())
            {
                Guid guid;
                previewEventDesc.getID(out guid);
                if (guid == eventRef.Guid)
                {
                    load = false;
                }
                else
                {
                    PreviewStop();
                }
            }

            if (load)
            {
                masterBanks.Clear();
                previewBanks.Clear();

                foreach (EditorBankRef masterBankRef in EventManager.MasterBanks)
                {
                    FMOD.Studio.Bank masterBank;
                    CheckResult(System.loadBankFile(masterBankRef.Path, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out masterBank));
                    masterBanks.Add(masterBank);
                }

                if (!EventManager.MasterBanks.Exists(x => eventRef.Banks.Contains(x)))
                {
                    string bankName = eventRef.Banks[0].Name;
                    var    banks    = EventManager.Banks.FindAll(x => x.Name.Contains(bankName));
                    foreach (var bank in banks)
                    {
                        FMOD.Studio.Bank previewBank;
                        CheckResult(System.loadBankFile(bank.Path, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out previewBank));
                        previewBanks.Add(previewBank);
                    }
                }
                else
                {
                    foreach (var previewBank in previewBanks)
                    {
                        previewBank.clearHandle();
                    }
                }

                CheckResult(System.getEventByID(eventRef.Guid, out previewEventDesc));
                CheckResult(previewEventDesc.createInstance(out previewEventInstance));
            }

            foreach (EditorParamRef param in eventRef.Parameters)
            {
                FMOD.Studio.PARAMETER_DESCRIPTION paramDesc;
                CheckResult(previewEventDesc.getParameterDescriptionByName(param.Name, out paramDesc));
                param.ID = paramDesc.id;
                PreviewUpdateParameter(param.ID, previewParamValues[param.Name]);
            }

            CheckResult(previewEventInstance.start());
            previewState = PreviewState.Playing;
        }
Exemple #21
0
        /// <summary>
        /// Updates the current phone UI state
        /// </summary>
        /// <param name="next">The state to update to</param>
        private void UpdatePhoneState(PhoneState next)
        {
            phoneTapped_sfx.start();
            switch (next)
            {
            case PhoneState.CONTACTS:
                // get current status information
                UpdateContacts();

                containerHome.gameObject.SetActive(false);
                containerContacts.gameObject.SetActive(true);
                containerMessages.gameObject.SetActive(false);
                containerNews.gameObject.SetActive(false);
                containerTasklist.gameObject.SetActive(false);
                break;

            case PhoneState.MESSAGES:
                // get current messages information based on current character
                // the current character isn't updated from the messages icon, but from the contacts buttons
                UpdateMessages();

                containerHome.gameObject.SetActive(false);
                containerContacts.gameObject.SetActive(false);
                containerMessages.gameObject.SetActive(true);
                containerNews.gameObject.SetActive(false);
                containerTasklist.gameObject.SetActive(false);
                break;

            case PhoneState.NEWS:
                // get random news
                UpdateNews();

                containerHome.gameObject.SetActive(false);
                containerContacts.gameObject.SetActive(false);
                containerMessages.gameObject.SetActive(false);
                containerNews.gameObject.SetActive(true);
                containerTasklist.gameObject.SetActive(false);
                break;

            case PhoneState.TASKLIST:
                // get current task information
                UpdateTaskProgress();

                containerHome.gameObject.SetActive(false);
                containerContacts.gameObject.SetActive(false);
                containerMessages.gameObject.SetActive(false);
                containerNews.gameObject.SetActive(false);
                containerTasklist.gameObject.SetActive(true);
                break;

            case PhoneState.HOME:
            default:
                containerHome.gameObject.SetActive(true);
                containerContacts.gameObject.SetActive(false);
                containerMessages.gameObject.SetActive(false);
                containerNews.gameObject.SetActive(false);
                containerTasklist.gameObject.SetActive(false);
                break;
            }

            currentState = next;
        }
Exemple #22
0
 void OnNoiseLimitReached()
 {
     recruitingSound.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
     escapeSound.start();
 }
Exemple #23
0
 /// <summary>
 /// Plays the passed in fmod event
 /// </summary>
 /// <param name="fmodEvent"> The name of the fmod event we want to play </param>
 /// <param name="volume"> The volume of the fmod event we want to play </param>
 public void PlayFmodEvent(FMOD.Studio.EventInstance fmodEvent, float volume = 1.0f)
 {
     fmodEvent.setVolume(volume);
     fmodEvent.start();
 }
        /// <summary>
        /// setup ui on start
        /// </summary>
        private void Start()
        {
            // Initializing sounds
            bucketPlacedOnSnow_sfx = FMODUnity.RuntimeManager.CreateInstance("event:/SFX/BucketPlacedOnSnow");
            throwWoodToFire_sfx    = FMODUnity.RuntimeManager.CreateInstance("event:/SFX/ThrowWoodToFire");
            startStove_sfx         = FMODUnity.RuntimeManager.CreateInstance("event:/SFX/StartStove");

            bucket.button.onClick.AddListener(() => {
                switch (GameStateMachine.Instance.CurrentMinigame)
                {
                case Minigame.SNOW_GATHERING:
                    bucketPlacedOnSnow_sfx.start();
                    if (minigameSnowGathering.BucketState)
                    {
                        if (minigameSnowGathering.BucketIsFull)
                        {
                            BucketFillState = BucketState.SNOWY;
                        }
                        minigameSnowGathering.BucketState = false;
                    }
                    else if (bucket.state == BucketState.EMPTY)
                    {
                        minigameSnowGathering.BucketState = true;
                    }
                    break;

                case Minigame.SNOW_MELTING:
                    if (BucketFillState != BucketState.EMPTY)
                    {
                        if (!minigameSnowMelting.BucketPlaced)
                        {
                            startStove_sfx.start();
                        }
                        minigameSnowMelting.ToggleBucket(!minigameSnowMelting.BucketPlaced);
                        if (BucketFillState == BucketState.BOILED)
                        {
                            Resources.Instance.AddWater(Constants.WATER_PER_BUCKET);
                            BucketFillState = BucketState.EMPTY;
                        }
                    }
                    break;
                }
            });

            furniturePieces.button.onClick.AddListener(() => {
                if (GameStateMachine.Instance.CurrentMinigame == Minigame.FIRE_REFUELING)
                {
                    if (minigameFireRefueling.AddToFire())
                    {
                        // play wood throwing sound effects
                        throwWoodToFire_sfx.start();
                        FurniturePieceCount--;
                    }
                }
            });

            BucketFillState     = BucketState.EMPTY;
            FurniturePieceCount = 0;

            blurContainerMaterialInstance = new Material(blurContainer.material);
            blurContainer.material        = blurContainerMaterialInstance;

            DisableAllMinigames();
            StartCoroutine(DelayedStart());
        }
Exemple #25
0
 private void PlayVO()
 {
     reactionVOInstance = FMODUnity.RuntimeManager.CreateInstance(reactionVO);
     FMODUnity.RuntimeManager.AttachInstanceToGameObject(reactionVOInstance, this.transform, this.GetComponent <Rigidbody>());
     reactionVOInstance.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;
        }
Exemple #27
0
 /// <summary>
 /// Removes a snow draggable from the list
 /// </summary>
 /// <param name="toRemove">The draggable to remove</param>
 public void RemoveSnowFromList(DraggableSprite toRemove)
 {
     dropSnowInBucket_sfx.start();
     spawnedDraggables.Remove(toRemove);
     Destroy(toRemove.gameObject);
 }
		// Use this for initialization
		void Start ()
		{
			_event = FMODUnity.RuntimeManager.CreateInstance (Event);
			_event.getParameter (Parameter_name, out _varSound);
			_event.start ();
		}
Exemple #29
0
 public void Enable()
 {
     instance = FMODUnity.RuntimeManager.CreateInstance(fmodEvent);
     instance.start();
 }
        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;
        }
Exemple #31
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;
                }
            }
        }