스테이지에 따른 BGM 추가

This commit is contained in:
Mingu Kim
2025-03-01 20:51:18 +09:00
parent ef558d0a48
commit d29101526e
3 changed files with 143 additions and 0 deletions

View File

@@ -40,6 +40,11 @@ namespace TON
[SerializeField]
public TextMeshProUGUI waveCounter;
public AudioClip _13StageSound;
public AudioClip _46StageSound;
public AudioClip _79StageSound;
public AudioClip _10StageSound;
// Start is called before the first frame update
void Start()
{
@@ -89,6 +94,15 @@ namespace TON
isWaitingForNextWave = true;
StartCoroutine(StartNextWaveWithDelay());
}
// 플레이어 존재 여부 확인
var player = GameObject.Find("TON.Player").GetComponentInChildren<CharacterBase>();
if (player == null && gameStarted)
{
// 플레이어가 죽었을 때
SoundManager.instance.BgSoundPlay(null);
// 필요하다면 gameStarted = false; 등을 설정하여 한 번만 실행되게 함
}
}
private void SpawnBossMonster()
@@ -110,6 +124,23 @@ namespace TON
StageManager.Singleton.SetWaveData(currentWave); // 웨이브 정보 전달.
currentWave++;
if (0 < currentWave && currentWave <= 3)
{
SoundManager.instance.BgSoundPlay(_13StageSound); // 1~3스테이지 배경음
}
else if (3 < currentWave && currentWave <= 6)
{
SoundManager.instance.BgSoundPlay(_46StageSound); // 4~6스테이지 배경음
}
else if (6 < currentWave && currentWave <= 9)
{
SoundManager.instance.BgSoundPlay(_79StageSound); // 7~9스테이지 배경음
}
else if(currentWave == 10)
{
SoundManager.instance.BgSoundPlay(_10StageSound); // 10스테이지 배경음
}
if (currentWave > TOTAL_WAVES)
{

View File

@@ -6,6 +6,8 @@ namespace TON
{
public class SoundManager : MonoBehaviour
{
public AudioSource bgSound;
public static SoundManager instance;
private void Awake()
@@ -31,5 +33,13 @@ namespace TON
Destroy(go, clip.length);
}
public void BgSoundPlay(AudioClip clip)
{
bgSound.clip = clip;
bgSound.loop = true;
bgSound.volume = 1f;
bgSound.Play();
}
}
}