IsPlaying() public method

public IsPlaying ( ) : bool
return bool
    // Update is called once per frame
    protected override void Update()
    {
        base.Update();
        if (_isBeingGrabbed)
        {
            float fwdDotProduct   = Vector3.Dot(transform.forward, velocity);
            float upDotProduct    = Vector3.Dot(transform.up, velocity);
            float rightDotProduct = Vector3.Dot(transform.right, velocity);

            Vector3 velocityVector = new Vector3(rightDotProduct, upDotProduct, fwdDotProduct);
            if (velocity.magnitude > _shakeSensitivity)
            {
                if (!_sandShakeSoundEmitter.IsPlaying())
                {
                    _sandShakeSoundEmitter.Play();
                }
            }
        }
        if (this.transform.worldToLocalMatrix[1, 1] < 0 && _isBeingGrabbed == true)
        {
            SpawnSand();
            fadeStartTime = Time.time;
        }
        else if (_sandPourSoundEmitter.IsPlaying())
        {
            FadeOutSandPour();
        }
    }
Esempio n. 2
0
    void CloseDialogue()
    {
        if (dialogueOpen)
        {
            StartCoroutine(DelayedAllowInput(0.25f));
            dialogueOpen = false;

            int childCount = textPanel.childCount;

            for (int i = childCount; i > 0; i--)
            {
                Destroy(textPanel.GetChild(i - 1).gameObject);
            }

            namePanel.text = "";
            animator.Play("Close");


            previewTriggers = null;

            if (emitter.IsPlaying())
            {
                emitter.Stop();
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (terrorist == null)
        {
            terrorist = GameObject.Find("Terrorist(Clone)");
        }
        if (player == null)
        {
            player = GameObject.Find("Server_FPS(Clone)");
            return;
        }

        // Parameters: InGame / Death / Intensity / Victory

        float param_InGame    = player.GetComponent <MoveFPS> ().enabled ? 1f : 0f;
        float param_Death     = Global.GameOver ? 1f : 0f;
        float param_Intensity = 0f;

        if (terrorist != null)
        {
            param_Intensity = 1f - ((transform.position - terrorist.transform.position).magnitude / 20f);
        }
        float param_Victory = (Global.victory) ? 1f : 0f;

        MusicLoop.SetParameter("InGame", param_InGame);
        MusicLoop.SetParameter("Death", param_Death);
        MusicLoop.SetParameter("Intensity", param_Intensity);
        MusicLoop.SetParameter("Victory", param_Victory);

        HeartBeats.SetParameter("Intensity", param_Intensity);
        HeartBeats.SetParameter("Death", Mathf.Min(1f, param_Death + param_Victory));

        float param_Timer = 1f - Global.timeLeft / Global.duration;

        if (Global.GameOver || Global.victory)
        {
            param_Timer = 0f;
        }

        if (!CopsSounds.IsPlaying())
        {
            CopsSounds.Play();
        }
        CopsSounds.SetParameter("Timer", param_Timer);

        if (Global.phoneRing && !phoneRing.IsPlaying())
        {
            phoneRing.Play();
        }
        if (!Global.phoneRing && phoneRing.IsPlaying())
        {
            phoneRing.Stop();
        }
    }
        public static void UpdateActiveEmitter(StudioEventEmitter emitter, bool force = false)
        {
            // If at least once listener is within the max distance, ensure an event instance is playing
            bool playInstance = false;

            for (int i = 0; i < Listeners.Count; i++)
            {
                if (Vector3.Distance(emitter.transform.position, Listeners[i].transform.position) <= emitter.MaxDistance)
                {
                    playInstance = true;
                    break;
                }
            }

            if (force || playInstance != emitter.IsPlaying())
            {
                if (playInstance)
                {
                    emitter.PlayInstance();
                }
                else
                {
                    emitter.StopInstance();
                }
            }
        }
Esempio n. 5
0
 public void PlayEmitterOnce(FMODUnity.StudioEventEmitter fmodComponent)
 {
     if (!fmodComponent.IsPlaying())
     {
         fmodComponent.Play();
     }
 }
 void ObjectReleased(object sender, InteractableObjectEventArgs e)
 {
     if (_overHalfWay && !_leverResetSound.IsPlaying())
     {
         _leverResetSound.Play();
     }
 }
 public void PlayEndClickSound()
 {
     if (!_leverEndClickSound.IsPlaying())
     {
         _leverEndClickSound.Play();
         goingBack = true;
     }
 }
 protected override void ObjectGrabbed(object sender, InteractableObjectEventArgs e)
 {
     base.ObjectGrabbed(sender, e);
     if (!_sliderSoundSoundEmitter.IsPlaying())
     {
         _sliderSoundSoundEmitter.Play();
     }
 }
Esempio n. 9
0
 protected override void ObjectGrabbed(object sender, InteractableObjectEventArgs e)
 {
     base.ObjectGrabbed(sender, e);
     if (!_bottlePickUpSound.IsPlaying())
     {
         _bottlePickUpSound.Play();
     }
 }
Esempio n. 10
0
 protected virtual void OnCollisionEnter(Collision collision)
 {
     if (ImpactSound != null)
     {
         if (!ImpactSound.IsPlaying() && Time.time > _spawnTime + 0.5f)
         {
             ImpactSound.Play();
         }
     }
 }
Esempio n. 11
0
 /// <summary> Start audio if it isn't already playing. </summary>
 private void PlayMusicAndAmbience()
 {
     if (!musicController.IsPlaying())
     {
         musicController.Play();
     }
     if (!ambienceController.IsPlaying())
     {
         ambienceController.Play();
     }
 }
 private IEnumerator SetInteractibleCoroutine(bool isInteractible)
 {
     if (isInteractible)//If you want to make it interactible again you need to wait for the sound to end
     {
         while (_crystal_sound.IsPlaying())
         {
             yield return(null);
         }
     }
     _brazier.SetActive(!isInteractible);
     this.enabled = isInteractible;
 }
Esempio n. 13
0
    // Update is called once per frame
    void Update()
    {
        //Outdoor ambiancen stängs av i Indoor Large

        /*if (audioManager.material <= 4 && !outdoorEmitter.IsPlaying())
         * {
         *      outdoorEmitter.Play ();
         *      Debug.Log ("Outdoor_Play");
         * }
         * if (audioManager.material >= 4 && outdoorEmitter.IsPlaying ())
         * {
         *      outdoorEmitter.Stop ();
         *      Debug.Log ("Outdoor_Stop");
         * }*/

        //Small Cave Ambiance spelas upp i indoor small
        if (audioManager.material == 3 && !indoorSmallEmitter.IsPlaying())
        {
            indoorSmallEmitter.Play();
            Debug.Log("IndoorSmall_Play");
        }
        if (audioManager.material != 3 && indoorSmallEmitter.IsPlaying())
        {
            indoorSmallEmitter.Stop();
            Debug.Log("IndoorSmall_Stop");
        }

        if (audioManager.material == 4 && !indoorLargeEmitter.IsPlaying())
        {
            indoorLargeEmitter.Play();
            Debug.Log("IndoorLarge_Play");
        }
        if (audioManager.material != 4 && indoorLargeEmitter.IsPlaying())
        {
            indoorLargeEmitter.Stop();
            Debug.Log("IndoorLarge_Stop");
        }
    }
Esempio n. 14
0
 public void OnTriggerEnter(Collider col)
 {
     if (Time.time > _lastScoreTime + 0.01f)
     {
         if (!_scoreSound.IsPlaying())
         {
             _scoreSound.Play();
         }
         particleEmitter.GetComponent <ParticleSystem>().Play();
         _lastScoreTime = Time.time;
         _score++;
         if (_score > _highScore)
         {
             _highScore = _score;
         }
         text.text = _score.ToString();
         if (!_scoreSound.IsPlaying())
         {
             _scoreSound.Play();
         }
     }
     timeText.text = 30.ToString();
     _timertext    = 30f;
 }
 public void PlayClickingSound(int pValue)
 {
     if (pValue >= 4)
     {
         _overHalfWay = true;
     }
     else
     {
         _overHalfWay = false;
     }
     if (!goingBack)
     {
         if (!_leverClickSound.IsPlaying())
         {
             _leverClickSound.Play();
         }
     }
 }
Esempio n. 16
0
    public void PlayRepeatingVideo(int pIndex)
    {
        vp.isLooping = true;
        if (!_monitorSwitchClip.IsPlaying())
        {
            _monitorSwitchClip.Play();
        }
        if (vp == null)
        {
            return;
        }

        if (vp.isPlaying)
        {
            vp.Stop();
        }

        vp.clip = VideosRepeating[pIndex];
        vp.Play();
    }
Esempio n. 17
0
    // Update is called once per frame
    void Update()
    {
        isEnable = activable.isOpened();

        if (isEnable != prev_state)
        {
            EnableLight(gameObject, isEnable);
            EnableLightMesh(gameObject, isEnable);
            prev_state = isEnable;
        }

        if (activable.isClosing() && soundOff != null && !soundOff.IsPlaying())
        {
            soundOff.Play();
        }
        if (activable.isOpening() && soundOn != null && !soundOn.IsPlaying())
        {
            soundOn.Play();
        }
    }
Esempio n. 18
0
    // Update is called once per frame
    void Update()
    {
        if (soundEmitter != null && soundWhenOpened && (isOpen || isOpening()) && !soundEmitter.IsPlaying())
        {
            soundEmitter.Play();
        }
        if (soundEmitter != null && soundWhenOpened && (isClose || isClosing()) && soundEmitter.IsPlaying() && !playAllsound)
        {
            soundEmitter.Stop();
        }
        if (soundEmitter != null && !soundWhenOpened && (isOpen || isOpening()) && soundEmitter.IsPlaying() && !playAllsound)
        {
            soundEmitter.Stop();
        }
        if (soundEmitter != null && !soundWhenOpened && (isClose || isClosing()) && !soundEmitter.IsPlaying())
        {
            soundEmitter.Play();
        }

        if (movableObject == null && autoClose && isOpen)
        {
            isOpen  = !isOpen;
            isClose = !isClose;
        }


        if (!isActionEnded)
        {
            if (needOpen)
            {
                if (amplitudeActual >= amplitudeMaxAbs)
                {
                    isActionEnded   = true;
                    amplitudeActual = amplitudeMaxAbs;
                    isOpen          = true;
                    isClose         = false;
                    if (autoClose)
                    {
                        Action(lastActionner);
                    }
                }
                else
                {
                    amplitudeActual += Time.deltaTime * movementSpeed;
                }
            }
            else
            {
                if (amplitudeActual <= 0.0f)
                {
                    isActionEnded   = true;
                    amplitudeActual = 0.0f;
                    isClose         = true;
                    isOpen          = false;
                }
                else
                {
                    amplitudeActual -= Time.deltaTime * movementSpeed;
                }
            }
        }

        if (movableObject)
        {
            if (movementIsRotation)
            {
                movableObject.transform.localEulerAngles = initialLocalEulerAngles + amplitudeMaxSigne * new Vector3(direction.x * amplitudeActual, direction.y * amplitudeActual, direction.z * amplitudeActual);
            }
            else
            {
                movableObject.transform.position = initialPosition + amplitudeMaxSigne * new Vector3(direction.x * amplitudeActual, direction.y * amplitudeActual, direction.z * amplitudeActual);
            }
        }

        if (activeWhenOpened)
        {
            if (particuleSystem && !isClose && needOpen && !particuleSystem.isPlaying)
            {
                particuleSystem.Play();
            }
            if (particuleSystem && !isOpen && !needOpen && !particuleSystem.isStopped)
            {
                particuleSystem.Stop();
            }
        }
        else
        {
            if (particuleSystem && !isOpen && !needOpen && !particuleSystem.isPlaying)
            {
                particuleSystem.Play();
            }
            if (particuleSystem && !isClose && needOpen && !particuleSystem.isStopped)
            {
                particuleSystem.Stop();
            }
        }

        if (enableWhenOpened)
        {
            for (int i = 0; i < dependences.Length; i++)
            {
                dependences [i].SetActive(isOpen);
            }
        }
        else
        {
            for (int i = 0; i < dependences.Length; i++)
            {
                dependences [i].SetActive(isClose);
            }
        }
    }
    public void changeSoundsVolumes(float volume)
    {
        FMODUnity.StudioEventEmitter[] emitters = GameObject.FindObjectsOfType <FMODUnity.StudioEventEmitter>();

        Citizen[]    citizens = GameObject.FindObjectsOfType <Citizen>();
        GameObject[] trees    = GameObject.FindGameObjectsWithTag("RessourceTank");

        foreach (Citizen cit in citizens)
        {
            FMODUnity.StudioEventEmitter emitter = cit.GetComponent <FMODUnity.StudioEventEmitter>();
            emitter.EventInstance.setVolume(volume);
        }
        foreach (GameObject tree in trees)
        {
            AudioSource source = tree.GetComponent <AudioSource>();
            source.volume = volume;
        }

        Building[] buildings = GameObject.FindObjectsOfType <Building>();
        foreach (Building building in buildings)
        {
            if (building.tag == "Statue")
            {
                foreach (AudioSource clip in building.GetComponents <AudioSource>())
                {
                    clip.volume = volume;
                }
            }

            else
            {
                AudioSource source = building.GetComponent <AudioSource>();
                source.volume = volume;
            }
        }

        errorSound.GetComponent <AudioSource>().volume = volume;
        GameObject.Find("SoundTree").GetComponent <AudioSource>().volume    = volume;
        GameObject.Find("ButtonCamp").GetComponent <AudioSource>().volume   = volume;
        GameObject.Find("ButtonHouse").GetComponent <AudioSource>().volume  = volume;
        GameObject.Find("ButtonStatue").GetComponent <AudioSource>().volume = volume;

        eventSound.GetComponent <AudioSource>().volume = volume;

        GameObject birds = GameObject.Find("BirdsSound");

        FMODUnity.StudioEventEmitter emitBirds = birds.GetComponent <FMODUnity.StudioEventEmitter>();
        emitBirds.EventInstance.setVolume(volume);


        foreach (Transform child in GameObject.Find("WaveSound").transform)
        {
            FMODUnity.StudioEventEmitter emitter = child.GetComponent <FMODUnity.StudioEventEmitter>();
            emitter.EventInstance.setVolume(volume);
        }

        //GameObject.Find("WaveN").GetComponent<FMODUnity.StudioEventEmitter>();

        foreach (FMODUnity.StudioEventEmitter emitter in emitters)
        {
            //FMOD.Studio.PLAYBACK_STATE state;
            //emitter.EventInstance.getPlaybackState(out state);
            //float vol;
            //float finalvol;
            //emitter.EventInstance.getVolume(out vol, out finalvol);
            if (emitter.tag.Equals("MainCamera") && volumeTheme.value <= 0)
            {
                emitter.Stop();
            }
            else if (!emitter.tag.Equals("MainCamera") && volume <= 0)
            {
                //emitter.EventInstance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
                //emitter.EventInstance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
                emitter.Stop();
            }
            else if (!(emitter.IsPlaying()))
            {
                emitter.Play();
            }
        }
    }
Esempio n. 20
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F5))
        {
            Debug.Log("Complete tutorial");
            _currentStage    = 6;
            readyToComplete  = true;
            isSwitchingStage = true;
            CompleteStage(6);
            videos[0].PlayChladniVideo(7);
            videos[1].PlayChladniVideo(7);
            videos[0].clipIndex = 7;
            videos[1].clipIndex = 7;
            _spotLightHandler.SwitchLights(SpotlightHandler.LightState.JARS);
            _spotLightHandler.SwitchLights(SpotlightHandler.LightState.PLATE);
            _spotLightHandler.SwitchLights(SpotlightHandler.LightState.SLIDERA);
            _spotLightHandler.SwitchLights(SpotlightHandler.LightState.SLIDERF);
            _spotLightHandler.SwitchLights(SpotlightHandler.LightState.FINISHED);
        }
        if (_chladniTalkBoard.Event == _tutorialSounds[0] && !_chladniTalkBoard.IsPlaying() && _welcomeSoundHasPlayed)
        {
            _soundTargetString = _tutorialSounds[1];
            _soundShouldChange = true;
        }
        if (_chladniTalkBoard.Event == _tutorialSounds[3] && !_chladniTalkBoard.IsPlaying() && _sandMoveSoundHasPlayed)
        {
            _soundTargetString = _tutorialSounds[4];
            _soundShouldChange = true;
        }
        if (_chladniTalkBoard.Event == _tutorialSounds[4] && !_chladniTalkBoard.IsPlaying() && _fsliderSoundHasPlayed)
        {
            _soundTargetString = _tutorialSounds[5];
            _soundShouldChange = true;
        }
        if (_chladniTalkBoard.Event == _tutorialSounds[7] && !_chladniTalkBoard.IsPlaying() && _goodbyeHasPlayed && !_soundAfterTutorial.IsPlaying())
        {
            _soundAfterTutorial.Play();
        }
        if (_currentStage <= 0)
        {
            if (Time.time - SceneStartTime >= StartDelay)
            {
                ResetTutorial();
            }
            else
            {
                return;
            }
        }
        if (isSwitchingStage)
        {
            if (Time.time - stageSwitchTime >= NextStageDelay)
            {
                _currentStage++;
                if (_currentStage == 3)
                {
                    _spotLightHandler.ChangeLight((SpotlightHandler.LightState)_currentStage, 10);
                }
                else if (_currentStage == 4)
                {
                    _spotLightHandler.ChangeLight((SpotlightHandler.LightState)_currentStage, 4);
                    CompleteDelay = 5.5f;
                }
                else
                {
                    _spotLightHandler.ChangeLight((SpotlightHandler.LightState)_currentStage);
                }
                isSwitchingStage = false;
                if (CompleteDelay > 0)
                {
                    stageStartTime  = Time.time;
                    readyToComplete = false;
                }
            }
        }
        if (!readyToComplete)
        {
            if (Time.time - stageStartTime >= CompleteDelay)
            {
                readyToComplete = true;
            }
        }

        if (!_sceneStarting)
        {
            if (Time.time > _startupTime + _delayOnStart)
            {
                _sceneStarting = true;
            }
        }
        if (_soundShouldChange)
        {
            ChangeSounds(_soundTargetString, true);
            _soundAfterTutorial.Stop();
            //For some reason it justs randomly starts.
        }
    }
Esempio n. 21
0
    // Update is called once per frame
    void Update()
    {
        if (!openRight && !openLeft)
        {
            isLocked = true;
        }

        if (needClose)
        {
            if (!SoundClose.IsPlaying())
            {
                SoundClose.Play();
            }

            if (left_true_right_false)               // door on left size (positive angle)
            {
                angle -= angular_speed * Time.deltaTime;
                if (angle < 0)
                {
                    angle       = 0;
                    needClose   = false;
                    actionEnded = true;
                }
            }
            else                 // door on right size (negative angle)
            {
                angle += angular_speed * Time.deltaTime;
                if (angle > 0)
                {
                    angle       = 0;
                    needClose   = false;
                    actionEnded = true;
                }
            }
        }

        if (needOpen)
        {
            if (!SoundOpen.IsPlaying())
            {
                SoundOpen.Play();
            }

            if (left_true_right_false)               // door on left size (positive angle)
            {
                angle += angular_speed * Time.deltaTime;
                if (angle >= angle_max_left)
                {
                    angle       = angle_max_left;
                    needOpen    = false;
                    actionEnded = true;
                }
            }
            else                 // door on right size (negative angle)
            {
                angle -= angular_speed * Time.deltaTime;
                if (angle < angle_max_right)
                {
                    angle       = angle_max_right;
                    needOpen    = false;
                    actionEnded = true;
                }
            }
        }

        if (timePoignee < durationPoignee)
        {
            timePoignee += Time.deltaTime;
        }
        else
        {
            timePoignee = durationPoignee;
        }

        if (timePoignee >= durationPoignee * openingTimeRatio && timePoignee < durationPoignee && needAction)
        {
            DoorAction(character);
        }

        if (timePoignee < durationPoignee)
        {
            float u = ((isLocked)?2.0f:1.0f) * 2.0f * Mathf.PI * timePoignee / durationPoignee;

            float a = 45.0f * (Mathf.Cos(u) - 1.0f) / 2.0f;

            transform.GetChild(0).localEulerAngles = new Vector3(0, -a, 0);
        }

        transform.localEulerAngles = new Vector3(angleBase.x, angleBase.y, angleBase.z + angle);
    }
Esempio n. 22
0
    // Update is called once per frame
    void Update()
    {
        DisableAllTexts();

        // Stage
        switch (stage)
        {
        case 1:
            //id = idInput.text;
            //group = groupDropdown.value + 1;
            idObj.SetActive(false);
            //emotionAnalyzer.SetID (id);

            texts [0].enabled = true;
            break;

        case 2:
            if (!hasStartedStage2)
            {
                StartMedia();
                hasStartedStage2 = true;
            }
            break;

        case 3:
            texts [2].enabled = true;
            break;

        case 4:
            if (!hasStartedStage4)
            {
                StartMedia();
                hasStartedStage4 = true;
            }
            if (!emitter.IsPlaying())
            {
                emitter.Play();
                //float sectionNum = (group == 2) ? 5f : 1f;
                //emitter.SetParameter("section_num", sectionNum);
            }
            else
            {
                CheckAndStopEmitterFromTimelinePosition();
            }

            break;

        case 5:
            texts [4].enabled = true;
            break;

        case 6:
            if (!hasStartedStage6)
            {
                StartMedia();
                hasStartedStage6 = true;
            }
            if (!emitter.IsPlaying())
            {
                emitter.Play();
                //float sectionNum = (group == 2) ? 5f : 1f;
                //emitter.SetParameter("section_num", sectionNum);
            }
            else
            {
                CheckAndStopEmitterFromTimelinePosition();
            }
            break;

        case 7:
            texts [6].enabled = true;
            //continueButton.gameObject.SetActive(false);
            break;
        }

        // Media
//		if (shouldStartMedia) {
//			StartMedia ();
//			shouldStartMedia = false;
//		}
    }