Music JUNGE
This commit is contained in:
parent
b378c4e834
commit
762628304d
|
@ -9421,10 +9421,124 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: c18f377723b64fd8a8d0261b85b3ba48, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_daysUntilRelease: 20
|
||||
_secondsPerDay: 48
|
||||
_daysUntilRelease: 7
|
||||
_secondsPerDay: 60
|
||||
_totalTime: 0
|
||||
_sun: {fileID: 124226107}
|
||||
--- !u!114 &322315147
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 322315138}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8f523547bf5e54c4989863475e2bdbaf, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_ambientMusic:
|
||||
- {fileID: 8300000, guid: 680bb3ce77c09334998b4c94313049d0, type: 3}
|
||||
- {fileID: 8300000, guid: 71646a2bfa6761d47ace4395791decfe, type: 3}
|
||||
- {fileID: 8300000, guid: 95f03e199fce21c4c92959821c685f3d, type: 3}
|
||||
_showDownMusic: {fileID: 8300000, guid: 608315f6bbecbd94e8e3bc4e16f7a429, type: 3}
|
||||
_musicTimer: 5
|
||||
--- !u!82 &322315148
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 322315138}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 0}
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 0.6
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
Mute: 0
|
||||
Spatialize: 0
|
||||
SpatializePostEffects: 0
|
||||
Priority: 128
|
||||
DopplerLevel: 1
|
||||
MinDistance: 1
|
||||
MaxDistance: 500
|
||||
Pan2D: 0
|
||||
rolloffMode: 0
|
||||
BypassEffects: 0
|
||||
BypassListenerEffects: 0
|
||||
BypassReverbZones: 0
|
||||
rolloffCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
panLevelCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
spreadCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
reverbZoneMixCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
--- !u!1 &324516778
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -19334,6 +19448,12 @@ PrefabInstance:
|
|||
- targetCorrespondingSourceObject: {fileID: 2703668081068178613, guid: e1e33f0b2075b5c40817665dd8a86f31, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 322315144}
|
||||
- targetCorrespondingSourceObject: {fileID: 2703668081068178613, guid: e1e33f0b2075b5c40817665dd8a86f31, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 322315147}
|
||||
- targetCorrespondingSourceObject: {fileID: 2703668081068178613, guid: e1e33f0b2075b5c40817665dd8a86f31, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 322315148}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: e1e33f0b2075b5c40817665dd8a86f31, type: 3}
|
||||
--- !u!1001 &604231830
|
||||
PrefabInstance:
|
||||
|
@ -27086,74 +27206,6 @@ MeshFilter:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 843581767}
|
||||
m_Mesh: {fileID: -942445950811305749, guid: 06922b963b921e44cbadd739dab73ab0, type: 3}
|
||||
--- !u!1 &844245209
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 844245212}
|
||||
- component: {fileID: 844245211}
|
||||
- component: {fileID: 844245210}
|
||||
m_Layer: 0
|
||||
m_Name: EventSystem (1)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &844245210
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 844245209}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_SendPointerHoverToParent: 1
|
||||
m_HorizontalAxis: Horizontal
|
||||
m_VerticalAxis: Vertical
|
||||
m_SubmitButton: Submit
|
||||
m_CancelButton: Cancel
|
||||
m_InputActionsPerSecond: 10
|
||||
m_RepeatDelay: 0.5
|
||||
m_ForceModuleActive: 0
|
||||
--- !u!114 &844245211
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 844245209}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_FirstSelected: {fileID: 0}
|
||||
m_sendNavigationEvents: 1
|
||||
m_DragThreshold: 10
|
||||
--- !u!4 &844245212
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 844245209}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &846377969
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -57662,54 +57714,6 @@ MeshFilter:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1788854034}
|
||||
m_Mesh: {fileID: -8834847623697427935, guid: fb5b599722b688841bd8273ae8e0c667, type: 3}
|
||||
--- !u!1 &1791928785
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1791928787}
|
||||
- component: {fileID: 1791928786}
|
||||
m_Layer: 0
|
||||
m_Name: Time Manager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1791928786
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1791928785}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: c18f377723b64fd8a8d0261b85b3ba48, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_daysUntilRelease: 20
|
||||
_secondsPerDay: 30
|
||||
_totalTime: 0
|
||||
_sun: {fileID: 124226107}
|
||||
--- !u!4 &1791928787
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1791928785}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 1.466824, y: 5.1305547, z: 5.283371}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &1793902827
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -66527,6 +66531,7 @@ MonoBehaviour:
|
|||
- {fileID: 8300000, guid: e541b41adf0d8e542baa93445dca7816, type: 3}
|
||||
ZombiePrefab: {fileID: 856601670117699726, guid: a34b2d22562c7214f9daf0d3dea8d85c, type: 3}
|
||||
_spawnRate: 10
|
||||
_dontSpawnForLastSeconds: 3
|
||||
_spawnTimer: 0
|
||||
_enabledTimer: 0
|
||||
--- !u!1 &2088863179
|
||||
|
@ -88547,8 +88552,6 @@ SceneRoots:
|
|||
- {fileID: 617063560}
|
||||
- {fileID: 995627549}
|
||||
- {fileID: 1781738510}
|
||||
- {fileID: 844245212}
|
||||
- {fileID: 1791928787}
|
||||
- {fileID: 1383098703}
|
||||
- {fileID: 1480589467}
|
||||
- {fileID: 1958946714}
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using Utility;
|
||||
|
||||
public class MusicManager : MonoBehaviourSingleton<MusicManager>
|
||||
{
|
||||
[SerializeField]
|
||||
private List<AudioClip> _ambientMusic;
|
||||
[SerializeField]
|
||||
private AudioClip _showDownMusic;
|
||||
|
||||
[SerializeField, ShowOnly]
|
||||
private float _musicTimer = 5f;
|
||||
private float _musicCheckInterval = 30f;
|
||||
private AudioSource _audioSource;
|
||||
private AudioClip _currentlyPlaying;
|
||||
private float _defaultVolume;
|
||||
private bool _showDownTime = false;
|
||||
private bool _doneFading = false;
|
||||
private bool _showDownIsPlaying = false;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_audioSource = GetComponent<AudioSource>();
|
||||
_defaultVolume = _audioSource.volume;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
CheckForFinalMusic();
|
||||
|
||||
if (!_showDownTime)
|
||||
{
|
||||
_musicTimer -= Time.deltaTime;
|
||||
|
||||
if (_musicTimer <= 0)
|
||||
{
|
||||
_musicTimer = _musicCheckInterval;
|
||||
if (!_audioSource.isPlaying)
|
||||
{
|
||||
PlayNewMusic();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_doneFading)
|
||||
{
|
||||
if (!_showDownIsPlaying)
|
||||
PlayShowDownMusic();
|
||||
}
|
||||
else
|
||||
{
|
||||
FadeOutMusic();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FadeOutMusic()
|
||||
{
|
||||
_audioSource.volume -= _audioSource.volume * Time.deltaTime;
|
||||
_audioSource.volume = _audioSource.volume <= 0.05f ? 0.0f : _audioSource.volume;
|
||||
_doneFading = _audioSource.volume <= 0.05f;
|
||||
}
|
||||
|
||||
private void CheckForFinalMusic()
|
||||
{
|
||||
float timeLeft = (float)GameManager.Instance.ExpectedRemainingGameDuration;
|
||||
_showDownTime = timeLeft < 0.9 * _showDownMusic.length;
|
||||
}
|
||||
|
||||
private void PlayNewMusic()
|
||||
{
|
||||
if (_currentlyPlaying == null)
|
||||
{
|
||||
_audioSource.clip = _ambientMusic.GetRandomElement();
|
||||
_audioSource.Play();
|
||||
}
|
||||
else
|
||||
{
|
||||
_ambientMusic.Remove(_currentlyPlaying);
|
||||
AudioClip newMusic = _ambientMusic.GetRandomElement();
|
||||
_ambientMusic.Add(_currentlyPlaying);
|
||||
_audioSource.clip = newMusic;
|
||||
_audioSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayShowDownMusic()
|
||||
{
|
||||
_showDownIsPlaying = true;
|
||||
_audioSource.Stop();
|
||||
_audioSource.volume = _defaultVolume;
|
||||
_audioSource.clip = _showDownMusic;
|
||||
_audioSource.loop = true;
|
||||
_audioSource.Play();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8f523547bf5e54c4989863475e2bdbaf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 30f91070128daa148a63a01cc9542601
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,23 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 680bb3ce77c09334998b4c94313049d0
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 7
|
||||
defaultSettings:
|
||||
serializedVersion: 2
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
preloadAudioData: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,23 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 71646a2bfa6761d47ace4395791decfe
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 7
|
||||
defaultSettings:
|
||||
serializedVersion: 2
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
preloadAudioData: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,23 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 95f03e199fce21c4c92959821c685f3d
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 7
|
||||
defaultSettings:
|
||||
serializedVersion: 2
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
preloadAudioData: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,23 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 608315f6bbecbd94e8e3bc4e16f7a429
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 7
|
||||
defaultSettings:
|
||||
serializedVersion: 2
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
preloadAudioData: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue