필수요소
- 퍼즐 디자인
- 플레이어 캐릭터 및 컨트롤
- 퍼즐 해결 시스템
- 장애물 및 트랩
- 목표 지점
- 게임 진행 상태 및 저장
- 사운드 및 음악
private AudioSource audioSource;
private AudioSource audioSource;
public void PlayWalkSound()
{
//걷기 사운드 배열에서 무작위 소리를 재생
int walkSoundIndex = Random.Range(0, walkSounds.Length);
audioSource.PlayOneShot(walkSounds[walkSoundIndex]);
}
IEnumerator PlayRandomWalkSound()
{
//지정된 시간이 지날 때까지 대기
yield return new WaitForSeconds(walkSoundDelay);
//무작위 걷기 소리를 재생
int walkSoundIndex = Random.Range(0, walkSounds.Length);
audioSource.PlayOneShot(walkSounds[walkSoundIndex]);
}
yield return null : 다음 프레임에 이어서 다시 시작
yield return new WaitForSeconds(seconds) : seconds만큼의 초가 흐른 후 다시 시작
yield return new WaitForEndOfFrame : 모든 Update가 실행된 후 다시 시작
public void PlayWalkSound()
{
//사운드 재생 코루틴이 비어있을 때
if (walkSoundCorutine == null)
{
//걷기 사운드 배열에서 무작위 소리를 재생
int walkSoundIndex = Random.Range(0, walkSounds.Length);
audioSource.PlayOneShot(walkSounds[walkSoundIndex]);
//코루틴을 시작
walkSoundCorutine = StartCoroutine(PlayRandomWalkSound());
}
}
IEnumerator PlayRandomWalkSound()
{
//지정된 시간이 지날 때까지 대기
yield return new WaitForSeconds(walkSoundDelay);
//무작위 걷기 소리를 재생
int walkSoundIndex = Random.Range(0, walkSounds.Length);
audioSource.PlayOneShot(walkSounds[walkSoundIndex]);
//지정된 시간이 지날 때까지 대기
yield return new WaitForSeconds(walkSoundDelay);
walkSoundCorutine = null;
}