Example #1
0
    private void Update()
    {
        if (isActive && Input.GetKey(KeyCode.E))
        {
            if (waitSound == null)
            {
                waitSound = Stem.SoundManager.GrabSound("Place");
                waitSound.Play();
            }

            waitTime += Time.deltaTime;
            if (waitTime >= PlaceItemQuest.instance.timeToPlace)
            {
                Action();
            }
        }
        else
        {
            if (waitSound != null)
            {
                waitSound.Stop();
                waitSound = null;
            }
            waitTime = 0.0f;
        }

        if (isActive)
        {
            float procent = Mathf.Floor(100 * waitTime / PlaceItemQuest.instance.timeToPlace);
            InteractSystem.instance.SetText($"Hold <b>E</b> to place <b>({procent})</b>...");
        }
    }
Example #2
0
    private void SetText(string text, string voiceKey)
    {
        if (curBunkerVoice != null)
        {
            curBunkerVoice.Stop();
            curBunkerVoice = null;
        }

        if (curRadioVoice != null)
        {
            curRadioVoice.Stop();
            curRadioVoice = null;
        }

        isActive = true;

        curBunkerVoice = Stem.SoundManager.GrabSound("Bunker" + voiceKey);
        curRadioVoice  = Stem.SoundManager.GrabSound("Radio" + voiceKey);

        bool inTheWild = PlayerState.instance.inTheWild;

        currentRadioMode = inTheWild || (!inTheWild && PlayerState.instance.currentBunker != replicaCharachter);
        noiseTimer       = currentRadioMode ? 0.5f : -0.5f;
        if (currentRadioMode)
        {
            Stem.SoundManager.Play("LoudNoise");
            mixer.FindSnapshot("Radio").TransitionTo(0.0f);
        }
        else
        {
            mixer.FindSnapshot("Bunker").TransitionTo(0.0f);
            curBunkerVoice.Play();
            curRadioVoice.Play();
        }

        timer     = curBunkerVoice.Sound.Variations[0].Clip.length;
        textTimer = curBunkerVoice.Sound.Variations[0].Clip.length * lengthFactor;
        panel.SetActive(true);
        message.text = text;
    }
Example #3
0
        private void ReleaseSound(int index)
        {
            SoundInstance instance = usedSounds[index];

            instance.Stop();
            instance.Sound = null;

            int last = usedSounds.Count - 1;

            usedSounds[index] = usedSounds[last];
            usedSounds.RemoveAt(last);

            freeSounds.Add(instance);
        }
Example #4
0
        internal bool ReleaseSound(SoundInstance instance)
        {
            int index = usedSounds.IndexOf(instance);

            if (index == -1)
            {
                return(false);
            }

            instance.Stop();
            instance.Sound = null;

            int last = usedSounds.Count - 1;

            usedSounds[index] = usedSounds[last];
            usedSounds.RemoveAt(last);

            freeSounds.Add(instance);

            return(true);
        }
Example #5
0
    private void Update()
    {
        bool inTheWild = PlayerState.instance.inTheWild;
        bool radioMode = inTheWild || (!inTheWild && PlayerState.instance.currentBunker != replicaCharachter);

        if (isActive)
        {
            if (currentRadioMode != radioMode)
            {
                currentRadioMode = radioMode;
                if (currentRadioMode)
                {
                    mixer.FindSnapshot("Radio").TransitionTo(0.1f);
                    quietNoise.Play();
                }
                else
                {
                    mixer.FindSnapshot("Bunker").TransitionTo(0.1f);
                    quietNoise.Stop();
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            HideText();
            Stop();
        }

        if (noiseTimer > 0.0f)
        {
            noiseTimer -= Time.deltaTime;
            if (noiseTimer <= 0.0f)
            {
                if (curBunkerVoice != null)
                {
                    curBunkerVoice.Play();
                    curRadioVoice.Play();
                    if (currentRadioMode)
                    {
                        quietNoise.Play();
                    }
                }
            }
        }

        if (noiseTimer <= 0.0f && timer > 0.0f)
        {
            timer -= Time.deltaTime;
            if (timer <= 0.0f)
            {
                Stop();

                if (currentRadioMode)
                {
                    Stem.SoundManager.Play("LoudNoise");
                }
                noiseTimer = currentRadioMode ? 0.5f : -0.5f;
            }
        }

        if (textTimer > 0.0f)
        {
            textTimer -= Time.deltaTime;
            if (textTimer <= 0.0f)
            {
                HideText();
            }
        }
    }