diff --git "a/Assets/Audio/\346\270\270\346\210\217\347\273\223\346\235\237.mp3" "b/Assets/Audio/\346\270\270\346\210\217\347\273\223\346\235\237.mp3" new file mode 100644 index 0000000..7ccf00c Binary files /dev/null and "b/Assets/Audio/\346\270\270\346\210\217\347\273\223\346\235\237.mp3" differ diff --git "a/Assets/Audio/\346\270\270\346\210\217\347\273\223\346\235\237.mp3.meta" "b/Assets/Audio/\346\270\270\346\210\217\347\273\223\346\235\237.mp3.meta" new file mode 100644 index 0000000..1ec5c45 --- /dev/null +++ "b/Assets/Audio/\346\270\270\346\210\217\347\273\223\346\235\237.mp3.meta" @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 419c04cfaaced4ed89fe6bd410af9ada +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: diff --git a/Assets/Prefabs/AudioSystem.prefab b/Assets/Prefabs/AudioSystem.prefab index ff0d748..74b02fc 100644 --- a/Assets/Prefabs/AudioSystem.prefab +++ b/Assets/Prefabs/AudioSystem.prefab @@ -144,6 +144,7 @@ MonoBehaviour: m_EditorClassIdentifier: start: {fileID: 8300000, guid: 9e3abcae91e5d4976800c4bb89aa4c2b, type: 3} background: {fileID: 8300000, guid: 053f96f50958c4c9db8459c7e64a2c07, type: 3} + end: {fileID: 8300000, guid: 419c04cfaaced4ed89fe6bd410af9ada, type: 3} trap: {fileID: 8300000, guid: 473b4c4e9bf9645ecb97f1ea5d6e42c3, type: 3} prop: {fileID: 8300000, guid: 473b4c4e9bf9645ecb97f1ea5d6e42c3, type: 3} footLeft: {fileID: 8300000, guid: 74dfebaa0141bcf47baeb7f4e6683a44, type: 3} diff --git a/Assets/Prefabs/Player1.prefab b/Assets/Prefabs/Player1.prefab index e692f1f..d5088d4 100644 --- a/Assets/Prefabs/Player1.prefab +++ b/Assets/Prefabs/Player1.prefab @@ -294,7 +294,7 @@ MonoBehaviour: carriedCratePrefab: {fileID: 8444238979230049489, guid: 46f10c127c0848946ae31345d863aef2, type: 3} moveLeftKey: 97 moveRightKey: 100 - jump: 32 + jump: 119 grabKey: 115 horizontalSpeed: 2 moveSpeed: 2 @@ -305,8 +305,9 @@ MonoBehaviour: rightFootAnchor: {fileID: 7319513830124477421} leftFootAudio: {fileID: 8300000, guid: 74dfebaa0141bcf47baeb7f4e6683a44, type: 3} rightFootAudio: {fileID: 8300000, guid: 1dd1c7b2920534043bebac2e322c1d68, type: 3} - jumpAudio: {fileID: 8300000, guid: 235a548266b2c438ca6563a38b04c97b, type: 3} + allCarriedCrates: [] rigidBody: {fileID: 0} + grablist: [] --- !u!82 &9016137575395165826 AudioSource: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Player2.prefab b/Assets/Prefabs/Player2.prefab index 65fbe7c..b4eb822 100644 --- a/Assets/Prefabs/Player2.prefab +++ b/Assets/Prefabs/Player2.prefab @@ -2044,7 +2044,7 @@ MonoBehaviour: carriedCratePrefab: {fileID: 8444238979230049489, guid: 46f10c127c0848946ae31345d863aef2, type: 3} moveLeftKey: 276 moveRightKey: 275 - jump: 48 + jump: 273 grabKey: 274 horizontalSpeed: 2 moveSpeed: 2 @@ -2055,8 +2055,9 @@ MonoBehaviour: rightFootAnchor: {fileID: 2098970189250627752} leftFootAudio: {fileID: 8300000, guid: 74dfebaa0141bcf47baeb7f4e6683a44, type: 3} rightFootAudio: {fileID: 8300000, guid: 1dd1c7b2920534043bebac2e322c1d68, type: 3} - jumpAudio: {fileID: 8300000, guid: 235a548266b2c438ca6563a38b04c97b, type: 3} + allCarriedCrates: [] rigidBody: {fileID: 0} + grablist: [] --- !u!82 &1887630252337677242 AudioSource: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/AudioSystem.cs b/Assets/Scripts/AudioSystem.cs index 9f38ea5..e83b7fa 100644 --- a/Assets/Scripts/AudioSystem.cs +++ b/Assets/Scripts/AudioSystem.cs @@ -8,6 +8,8 @@ public class AudioSystem : MonoBehaviour public AudioClip start; // 循环背景音乐 public AudioClip background; + // 游戏结束音效 + public AudioClip end; // 陷阱 public AudioClip trap; // 道具 @@ -28,16 +30,26 @@ void Start() audioSource = GetComponent(); effectSource = GameObject.Find("AudioEffect").GetComponent(); - this.PlayBackground(); + // this.PlayBackground(); - // Invoke("PlayBackground", 5f); + // Invoke("PlayGameEnd", 5f); // Invoke("PlayTrap", 6f); } // Update is called once per frame void Update() { - if (!audioSource.isPlaying && audioSource.clip != null) { + if (audioSource.isPlaying) + { + return; + } + if (audioSource.clip == end) + { + audioSource.clip = start; + audioSource.Play(); + } + else + { audioSource.clip = background; audioSource.Play(); } @@ -84,4 +96,11 @@ public void PlayJump() effectSource.PlayOneShot(jump, 1); } } + + public void PlayGameEnd() + { + audioSource.Stop(); + audioSource.clip = end; + audioSource.Play(); + } }