Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

공hannah부

CJ UNIT 7기 게임TF #7(급식실 게임 - 결과창) 본문

프로젝트/CJ UNIT 7기 게임TF

CJ UNIT 7기 게임TF #7(급식실 게임 - 결과창)

Hannah0226 2022. 11. 26. 14:27
오늘의 내용

게임이 끝난 후 화면에 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++;
	}
}

 

실행 영상

타이밍 딱 맞게 잘 실행된다^!^