Skip to content

Commit

Permalink
Merge branch 'main' of github.com:holycanvas/Crazy-Circus
Browse files Browse the repository at this point in the history
  • Loading branch information
moshuying committed Jul 7, 2024
2 parents e4b7099 + 75c64f5 commit 47dd8d3
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 7 deletions.
Binary file added Assets/Audio/游戏结束.mp3
Binary file not shown.
23 changes: 23 additions & 0 deletions Assets/Audio/游戏结束.mp3.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Assets/Prefabs/AudioSystem.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
5 changes: 3 additions & 2 deletions Assets/Prefabs/Player1.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions Assets/Prefabs/Player2.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
25 changes: 22 additions & 3 deletions Assets/Scripts/AudioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class AudioSystem : MonoBehaviour
public AudioClip start;
// 循环背景音乐
public AudioClip background;
// 游戏结束音效
public AudioClip end;
// 陷阱
public AudioClip trap;
// 道具
Expand All @@ -28,16 +30,26 @@ void Start()
audioSource = GetComponent<AudioSource>();
effectSource = GameObject.Find("AudioEffect").GetComponent<AudioSource>();

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();
}
Expand Down Expand Up @@ -84,4 +96,11 @@ public void PlayJump()
effectSource.PlayOneShot(jump, 1);
}
}

public void PlayGameEnd()
{
audioSource.Stop();
audioSource.clip = end;
audioSource.Play();
}
}

0 comments on commit 47dd8d3

Please sign in to comment.