매치 실패 시 나오는 효과음이 사라진 이슈.
GameManager 함수에 FailAudio 라는 오디오 클립을 선언하고
GameManager 함수의 Matched() 함수에서
FirstCard.idx != SecondCard.idx 일 때 실행되는 else문에
<aside> 💡 audioSource.PlayOneShot(FailAudio);
</aside>
을 넣어 해결하였습니다.
Matched() 전체 코드
public void Matched()
{
// 같은 카드라면
if (FirstCard.idx == SecondCard.idx)
{
// 매칭된 카드의 이미지에 해당하는 텍스트 표시
displayText.text = cardNames[FirstCard.idx]; // 카드의 idx에 해당하는 이름을 가져와서 표시
audioSource.PlayOneShot(matchAudio);
FirstCard.DestroyCard();
SecondCard.DestroyCard();
CardCount -= 2;
// 매칭이 이루어지면 텍스트를 활성화하고 displayTime 이후에 다시 비활성화합니다.
displayText.gameObject.SetActive(true);
displayTimer = displayTime; // 텍스트 표시 타이머 초기화
if (CardCount == 0)
{
float shortTime = maxTime - timer;
DifficultyManager.instance.UnLock(shortTime);
GameEnd();
}
}
else // 같지 않다면
{
FirstCard.CloseCard();
SecondCard.CloseCard();
MatchFailText.SetActive(true);
timer -= 2;
Match_Fail.Fail();
Text_Animator.SetTrigger("Fail");
audioSource.PlayOneShot(FailAudio);
}
matchingCount++; // 매칭 시도 횟수 ++
FirstCard = null;
SecondCard = null;
}