コード例 #1
0
    private IEnumerator ScreamLoopAsync(float volumeScale, bool loop)
    {
        do
        {
            for (int i = 0; i < _screamSounds.Count; ++i)
            {
                ScreamSoundDefinition screamSound = _screamSounds[i];
                AudioSource           audioSource = GetAvailableAudioSource();
                AudioManager.ConfigureSourceForSound(audioSource, screamSound.Sound);
                AudioManager.PrepareSourceToPlay(audioSource, screamSound.Sound);
                audioSource.clip   = screamSound.Sound.RandomClip;
                audioSource.volume = 0;
                audioSource.Play();

                ScreamSoundPlayed?.Invoke(screamSound, volumeScale);

                // Wait for scream to be done or random interval
                float waitTime = _screamInterval.RandomValue;
                if (!loop)
                {
                    waitTime *= 0.5f;
                }
                while (waitTime > 0 && audioSource.isPlaying)
                {
                    waitTime          -= Time.unscaledDeltaTime;
                    audioSource.volume = Mathfx.Damp(audioSource.volume, volumeScale, 0.25f, Time.unscaledDeltaTime * 3);
                    yield return(null);
                }
            }

            yield return(null);
        } while (enabled && loop);

        _screamRoutine = null;
    }
コード例 #2
0
    public void SwapNotes(int sourceSlotIndex, int targetSlotIndex)
    {
        ScreamSoundDefinition temp = _targetBottleNotes[targetSlotIndex];

        _targetBottleNotes[targetSlotIndex] = _sourceBottleNotes[sourceSlotIndex];
        _sourceBottleNotes[sourceSlotIndex] = temp;
    }
コード例 #3
0
 public void AddScream(ScreamSoundDefinition screamSound)
 {
     _screamSounds.Add(screamSound);
     if (!_screamController.IsScreaming)
     {
         _screamController.StartScream(_screamSounds, loopScream: true, volumeScale: 0.25f);
     }
 }
コード例 #4
0
    private void OnScreamSoundPlayed(ScreamSoundDefinition screamSound, float volumeScale)
    {
        ScreamVisual screamVisual = Instantiate(_screamVisualPrefab);

        screamVisual.transform.position = SpawnPoint.position;
        screamVisual.Scream             = screamSound;
        screamVisual.Scale     = volumeScale * 2;
        screamVisual.Direction = _primaryScreamDir.HasValue ? _primaryScreamDir.Value : Vector3.zero;
    }
コード例 #5
0
    void RefreshSongButtonLabels()
    {
        for (int slotIdx = 0; slotIdx < 3; ++slotIdx)
        {
            ScreamSoundDefinition sourceScreamSound = _screamInventory.GetSourceBottleNote(slotIdx);
            _sourceScreamSongLabels[slotIdx].text = sourceScreamSound != null ? sourceScreamSound.Letters : "<empty>";

            ScreamSoundDefinition targetScreamSound = _screamInventory.GetTargetBottleNote(slotIdx);
            _targetScreamSongLabels[slotIdx].text = targetScreamSound != null ? targetScreamSound.Letters : "<empty>";
        }
    }
コード例 #6
0
    private void SpawnAtPoint(Transform spawnPoint)
    {
        ScreamContainer screamContainer = Instantiate(_screamBottlePrefab, spawnPoint);

        screamContainer.transform.position  = spawnPoint.position;
        screamContainer.transform.rotation  = Random.rotationUniform;
        screamContainer.transform.position += (Random.insideUnitSphere * 10).WithY(0);

        for (int i = 0; i < 3; ++i)
        {
            ScreamSoundDefinition chosenSound = _bottlePossibleScreams.Screams[Random.Range(0, _bottlePossibleScreams.Screams.Count)];
            screamContainer.AddScream(chosenSound);
        }

        _spawnedContainers.Add(screamContainer);
    }
コード例 #7
0
 public void SetTargetBottleNote(int slotIndex, ScreamSoundDefinition note)
 {
     _targetBottleNotes[slotIndex] = note;
 }
コード例 #8
0
 public void SetSourceBottleNote(int slotIndex, ScreamSoundDefinition note)
 {
     _sourceBottleNotes[slotIndex] = note;
 }