공hannah부
CJ UNIT 7기 게임TF #7(급식실 게임 - 결과창) 본문
오늘의 내용
게임이 끝난 후 화면에 perfect / cool / good / bad / miss의 갯수와 최종 점수를 띄어주기
- EffectManager에서 각 판정 p,c,g,b,m이 몇번 쓰였는지 가져와야함
- ScoreManager에서 currentScore을 가져와야함
EffectManager
- JudegementEffect 함수에 judgementRecord[p_num]++; 넣어주어 각 배열에 p,c,g,b,m가 쓰인 갯수 저장하기
public void JudgementEffect(int p_num)
{
judgementImage.sprite = judgementSprite[p_num];
judgementAnimator.SetTrigger(hit);
judgementRecord[p_num]++; //판정 기록
}
- judgementRecord 반환해주는 함수 만들기
public int[] GetJudgementRecord()
{
return judgementRecord;
}
ScoreManager
- currentScore 반환해주는 함수 만들기
public int GetCurrentScore()
{
return currentScore;
}
Result
- p,c,g,b,m 텍스트와 score 텍스트 각각 0으로 초기화
- EffectManager와 ScoreManager에서 GetJudgementRecord 함수와 GetCurrentScore 함수 불러와 judgementRecord, cuurentscore 값 가져오기
- 가져온 값을 p,c,g,b,m 텍스트와 score 텍스트에 넣어주기
- false 시켜놓은 결과창을 true로 바꿔주기
public void ShowResult()
{
goUI.SetActive(true);
for(int i = 0; i < txtCount.Length; i++)
txtCount[i].text = "0";
txtScore.text = "0";
int[] t_judgement = theEffect.GetJudgementRecord();
int t_currentScore = theScore.GetCurrentScore();
for(int i = 0; i < txtCount.Length; i++)
{
txtCount[i].text = string.Format("{0:#,##0}", t_judgement[i]);
}
txtScore.text = string.Format("{0:#,##0}", t_currentScore);
}
StartBGM
음악이 play되고 있지않으면 Result에서 ShowResult 함수 불러오기
void Update()
{
if(musicStart)
{
if (myAudio.isPlaying)
{
}
else
{
theResult.ShowResult();
}
}
}
추가 수정
노래가 끝나도 학생들이 계속 생성되는 오류 발생
- NoteManager에서 학생들을 랜덤으로 생성시키는 부분에 if문을 넣어 97개만 생성하도록 하였다
노래가 아직 인트로일 땐 학생을 생성시키고 싶지 않음
- 노래 인트로 부분이 딱 학생 2명이 생성되는 분량이어서 학생의 숫자가 2보다 크면 생성시키도록 하였다.
void Update()
{
currentTime += Time.deltaTime;
//일정 시간마다 학생 생성 함수
if(StudentNum <= 97)
{
if(currentTime >= 140d/bpm)
{
if(StudentNum >= 2)
{
spawn_obj = Random.Range(1,3);
if(spawn_obj == 1) //랜덤수가 1이라면 식판 든 학생 생성
{
GameObject StudentO = Instantiate(Note_O,tfNoteAppear,Quaternion.identity);
StudentO.transform.SetParent(this.transform,false);
}
else //랜덤수가 2라면 식판 들지 않은 학생 생성
{
GameObject StudentX = Instantiate(Note_X,tfNoteAppear,Quaternion.identity);
StudentX.transform.SetParent(this.transform,false);
}
}
currentTime -= 140d / bpm;
StudentNum++;
}
}
실행 영상
타이밍 딱 맞게 잘 실행된다^!^
'프로젝트 > CJ UNIT 7기 게임TF' 카테고리의 다른 글
CJ UNIT 7기 게임TF #9(급식실 게임 - 자잘한 수정) (0) | 2022.11.28 |
---|---|
CJ UNIT 7기 게임TF #8(급식실 게임 - 게임 클리어 / 오버 구분) (0) | 2022.11.27 |
CJ UNIT 7기 게임TF #6(급식실 게임 - BGM) (0) | 2022.11.25 |
CJ UNIT 7기 게임TF #5(급식실 게임 - 점수 시스템) (0) | 2022.11.25 |
CJ UNIT 7기 게임TF #4(급식실 게임 - 판정 효과) (0) | 2022.11.24 |