BGM Game Wiki - UAVisonline/Portfolio GitHub Wiki
4์ง์ ๋ค BGM ๋ง์ถ๊ธฐ Game์ ๋ค์ํ ๊ฒ์์ ์ ๋ช BGM์ด ์ฌ์๋๋ฉด 4์ง์ ๋ค ์ ํ์ง๋ฅผ ์ด์ฉํด ๊ฒ์ ์ ๋ชฉ์ ๋ง์ถ๋ Game์ด๋ค. ํด๋น Game์ Practice mode ๋ฐ Arcade mode๊ฐ ์กด์ฌํ๋ฉฐ Practice๋ ํ๋ ์ด์ด๊ฐ ๊ทธ๋ง๋๊ณ ์ถ์ ๋๊น์ง ๊ฒ์ ์ ๋ชฉ์ ๋ง์ถ ์ ์๋ mode์ด๋ฉฐ, Arcade๋ 30๊ฐ์ ๋ฌธ์ ๋ฅผ ์์คํ ์ด ๊ฐ์ ธ์ค๊ณ ํ๋ ์ด์ด๋ ์ด๋ฅผ ๋ง์ถ์ด์ ๋ช ๋ฌธ์ ๋ฅผ ๋ง์ถ๋์ง ํ์ธํ๋ mode์ด๋ค.
ํด๋น ํ๋ก์ ํธ๋ 2020๋ 2์ ์์ ์ ์์ํ์ฌ ํ(๊ฒ์ ์์คํ ๋ฐ ์ฝํ ์ธ ํ ํ๋ฆฟ)์ ์ ์, ๊ทธ ํ ์ฝํ ์ธ ์ถ๊ฐ ๋ฐ ๊ฒ์ Scene์์ ์์คํ ์ ๋์ํ๊ธฐ ์ํด UI๋ฅผ ์ถ๊ฐ, ์ฐ๊ฒฐํ๋ ๋ฐฉ์์ผ๋ก ๊ฐ๋ฐ์ ์๋ฃํ๋ค.
ํด๋น ํ๋ก์ ํธ๋ฅผ ์งํํ๋ฉด์ ๊ด๋ จ ์์ ์ฌํท ๋ฐ ์์ ํ์ผ์ ์๋์ ๊ฐ์ด ์ถ์ถ, ํธ์งํ์ผ๋ฉฐ, ํ๋ก์ ํธ ์๋ฃ ํ ๋ฌธ์ ๊ฐ ๋ ๊ฒ์ด ํ์คํ ๋ฐฐํฌ ๊ฐ์ ๊ฒฝ์ฐ๋ ์งํํ์ง ์์๋ค.
- ์์ ์ฌํท : ์คํ ๋ฐ ๊ตฌ๊ธ Image๋ฅผ ํตํด ์ด๋ฏธ์ง ์ํท ์ถ์ถ
- ์์ ํ์ผ : ์ ํ๋ธ ์์ ์์์ ์ถ์ถ, ํด๋น ์์์ ์์์์ ํ์ํ ๋ถ๋ถ๋ง ํธ์งํด 2์ฐจ ์ถ์ถ
ํด๋น ์ํค์์๋ ํ๋ก์ ํธ์ ๋ํด ์๋ ๋ ํญ๋ชฉ๋ค์ ๊ดํด ์์ ํ๊ณ ์ ํ๋ค.
-
๊ฒ์ ์์คํ ์ด ์ฝ๋ ์ ์ด๋ป๊ฒ ๋์, ์ํธ์์ฉ ํ๋๊ฐ?
-
์ง๊ธ ์ด๋ฅผ ๋ณด๋ ์์ ์์ ํ๋ก์ ํธ์ ์๋ชป๋ ๋ถ๋ถ์ ์ด๋๋ผ๊ณ ์๊ฐํ๋๊ฐ? ์ด๋ฅผ ์ด๋ป๊ฒ ์์ ํด์ผ ํ๋๊ฐ?
Game์ ์คํํ๋ฉด ์ฐ์ Resource folder๋ด์ ์๋ ์์ ํ์ผ(ํด๋น ํ๋ก์ ํธ์์๋ Problem_file Script Component๋ฅผ ๊ฐ์ง ๊ฒ์์ค๋ธ์ ํธ)์ ์ฝ์ด๋ค์ด๋ ๊ณผ์ ์ด ํ์ํ๋ค. ํด๋น ํ๋ก์ ํธ์์๋ ์ด๋ฌํ ์์ ์ Problem_Base Script์์ ์๋์ ๊ฐ์ด ์ฒ๋ฆฌํ๊ณ ์๋ค.
34 public int Load(string folder) // Resource Folder๋ก ๋ค์ด๊ฐ์ ์์
๋ฌธ์ ๋ถ๋ฌ์ด
{
object[] obj = Resources.LoadAll(folder);
for(int i = 0;i<obj.Length;i++)
{
GameObject _gameobject = (GameObject)obj[i];
_cache[_gameobject.name] = _gameobject;
Problem_file temp = _gameobject.GetComponent<Problem_file>();
}
return obj.Length; // ํด๋ ๋ด ์ค๋ธ์ ํธ์ ์ซ์๋ฅผ ๋ฐํ
44 }
//_cache๋ <string,GameObject>ํํ Dictionary, string folder๋ Resources folder ๋ด ์ฝ๊ณ ์ถ์ folder์ ์ด๋ฆ
์ด๋ฅผ ํตํด Problem_Base Script๋ ์์ ์ค๋ธ์ ํธ ํ์ผ์ ์ฝ์ ์ ์์ผ๋ฉฐ, ์คํฌ๋ฆฝํธ๋ Start function์์ ๋์ด๋ ๋ณ๋ก ๋๋์ด์ง ์ค๋ธ์ ํธ ํ์ผ์ ์๋์ ๊ฐ์ด ์ฝ๋๋ค.
90 if (loop == 0) list_size = Load("0_Very_Easy");
else if (loop == 1) list_size = Load("1_Easy");
else if (loop == 2) list_size = Load("2_Normal");
else if (loop == 3) list_size = Load("3_Hard");
else if (loop == 4) list_size = Load("4_Very_Hard");
else if (loop == 5) list_size = Load("5_Expert");
96 else if (loop == 6) list_size = Load("6_Nightmare");
๊ทธ ํ Game ์คํ์ ์์ด์ ํ์ํ ๋ณ์๋ฅผ ์ด๊ธฐ๊ฐ์ผ๋ก ์ค์ , ํ๋ ์ด์ด๊ฐ ์ค์ Game์ ๋์ ํ ๋ ๊น์ง ๋๊ธฐํ๋ค.
Main_Menu_Button Script์์๋ function 2๊ฐ(training mode, arcade mode ์ง์ )๋ฅผ ํตํด ๋ณธ ๊ฒ์์ผ๋ก ์ง์ ํ๋ฉฐ ์ด ๋ Problem_Base Singleton์ Start_Game function์ ํธ์ถํ ๋ค Scene์ Loadํ๋ ๋ฐฉ์์ ์ฌ์ฉํ๋ค. ๊ทธ ํ Problem_Base์ Start_Game function์ ์ง์ ํ game mode์ ๋ฐ๋ผ 2๊ฐ์ง Coroutine(Start_Practice, Start_Arcade) ์ค ํ๋๋ฅผ ์คํํ๊ฒ ๋๋ค.
449 IEnumerator Start_Arcade() // Arcade mode Coroutine
{
while (true)
{
if (SceneManager.GetActiveScene().name == "Game") break;
yield return new WaitForSeconds(Time.deltaTime);
}
457 GameObject test_obj = GameObject.Find("Only_Test"); // ํ
์คํธ์ฉ ์ค์ ์ค๋ธ์ ํธ ํ์ (UI)
458 test_obj.SetActive(false); // ๊ทธ ํ ํด๋น ์ค๋ธ์ ํธ ์ข
๋ฃ (arcade mode์์๋ practice mode ์ ์ฉ UI๊ฐ ์ฌ๋ผ์ ธ์ผ ํ๊ธฐ ๋๋ฌธ)
460 ScoreManager.score_manager.arcade_text(); // ScoreManager Singleton์ ๋ํด ํด๋น ๋ฌธ์ ๊ฐ ๋ช๋ฒ์งธ ๋ฌธ์ ์ธ์ง ํ๊ธฐํ๋๋ก ํจ
problem_file = Instantiate(Get(problem_list[list_pos]), Vector2.zero, Quaternion.identity).GetComponent<Problem_file>(); // ์์
์ค๋ธ์ ํธ ํ์ผ ์์ฑ
problem_file.Problem_set(); // ์ค๋ธ์ ํธ์ ๋ํ ์ ๋ณด, ํํธ, ์ ํ์ง ์ธํ
๋ฐ ์์
clip์ Problem_Base Script์์ ํ์ ๊ฐ๋ฅํ๋๋ก ์ค์
jacket_black();
correct = false;
solved = false;
Music_Play();
yield return new WaitForSeconds(1.0f);
Directer_machine.directer.set_panel_slide(false);
470 }
์ ์ฝ๋๋ Arcade mode์ ์ง์ ํ ๋ ์คํ๋๋ Coroutine์ด๋ฉฐ, Practice mode๋ 457~460 Line์ ๋ด์ฉ๋ง ๋ฐ๋ Coroutine(Arcade mode UI๋ฅผ ์ญ์ )์ด ์คํ๋์ด Game Scene์ ์ง์ ํ๊ฒ ๋๋ค.
๊ทธ ํ ํ๋ ์ด์ด๋ Game Scene์์ Button UI๋ฅผ ์ด์ฉํด Game์ ์งํํ ์ ์์ผ๋ฉฐ ์ด๋ ์๋์ ๊ฐ์ Button Script์ Problem_Base Script์ ์ํธ์์ฉ์ผ๋ก ์ด๋ฃจ์ด์ง๋ค.
- Answer_Button Script : answer_button(int i) - Problem_Base Script : answer_function(int i) [์ ๋ต ์ ํ ๋ฒํผ]
- Answer_Button Script : Hint_Button(int num) - Problem_Base Script : give_a_hint(int num) [ํํธ ์ ๊ณต ๋ฒํผ]
- Answer_Button Script : Pass_Button() - Problem_Base Script : pass_function() [Pass ๊ธฐ๋ฅ ๋ฒํผ]
- Play_Button Script : Play_Button_Click() - Problem_Base Script : Music_Play() [์์ ์ฌ์ ๋ฒํผ - ๋ค์ ์ฒ์๋ถํฐ ์ฌ์ํ๊ธฐ]
- Play_Button Script : Back_Button_Click() - Problem_Base Script : Music_back_ten_second() [์์ ๋๊ฐ๊ธฐ ๋ฒํผ]
- Answer_Button Script : back_button_click() - Problem_Base Script : Back_Game() & ScoreManager Script : set_initial() [Mainํ๋ฉด์ผ๋ก ๋์๊ฐ๊ธฐ]
- Answer_Button Script : next_button_click() - Answer_Button Script : next_problem coroutine -> ์๋ง์ ProblemBase Code์ ์ํธ์์ฉ
์ด๋ฌํ ์ํธ์์ฉ์ ์ด์ฉํด ํ๋ ์ด์ด๋ Game์ ์งํํ๋ ๊ฒ์ด ๊ฐ๋ฅํ๋ฉฐ, ์ด๋ฅผ ๊ทธ๋ํ๋ก ํํํ๋ฉด ์๋์ ๊ฐ์ ์ด๋ฏธ์ง๋ก ๋ํ๋ผ ์ ์๋ค.
ํ๋ก์ ํธ์ ์๋ชป๋ ๋ถ๋ถ์ ์ด๋๋ผ๊ณ ์๊ฐํ๋๊ฐ? ์ด๋ฅผ ์ด๋ป๊ฒ ์์ ํด์ผ ์ข์๊น?
ํด๋น ํ๋ก์ ํธ์์๋ Asset/Resources๋ฅผ ํตํด ๋์ ์ผ๋ก ํ์ผ์ ๋ฉ๋ชจ๋ฆฌ์ ๋ถ๋ฌ์ค๋ ๋ฐฉ์์ ์ฌ์ฉํ๊ณ ์๋ค. ๊ทธ๋ฌ๋ ํด๋น ํ๋ก์ ํธ๋ Problem_Base Script๊ฐ Resources๋ฅผ Loadํด ๋ด๋ถ Dictionary์ ์ ์ฅํด๋๋ฏ๋ก ๊ทธ ๋ค์๋ ๋ฐ๋ก ๋ฉ๋ชจ๋ฆฌ์ Resources file์ ์ฌ๋ ค๋ ์ด์ ๊ฐ ์๋ค. ๊ทธ๋ฌ๋ ํด๋น ํ๋ก์ ํธ์์๋ ์ด๋ฅผ Unloadํ๋ ๋ถ๋ถ์ด ์กด์ฌํ์ง ์์ผ๋ฉฐ, ๋ฐ๋ผ์ Problem_Base script๋ฅผ ํตํด ์ด๋ฏธ ๋ถ๋ฌ์ฌ ์ค๋น๊ฐ ๋ง์น ํ์ผ์ ๊ณ์ ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ ค๋๋ ์ฑ๋ฅ ๋ญ๋น๊ฐ ๋ฐ์ํ๊ณ ์๋ค.
๋ํ ๋ฌธ์ ์ ์ ๋ณด๋ฅผ ์ ์ฅํ๊ณ ์๋ Problem_File Script๋ ๊ฒ์ ์ค๋ธ์ ํธ ๋ด ์ปดํฌ๋ํธ์ ํํ๋ก ๋ค์ด๊ฐ ๊ด๋ฆฌ๊ฐ ์งํ๋๋ค. ๊ทธ๋ฌ๋ ํ๋ก์ ํธ์ ์์ด์ ํ์ํ๊ฑด ๊ฒ์ ์ค๋ธ์ ํธ๊ฐ ์๋๋ผ Problem_File ์ปดํฌ๋ํธ์ด๋ฉฐ, ๋ฐ๋ผ์ Problem_File Script๋ฅผ ScriptableObject ํํ๋ก ๋ฐ๊พผ๋ค๋ฉด ๊ฒ์ ์ค๋ธ์ ํธ ํํ๋ก ๋ฐ์ดํฐ๋ฅผ ๊ด๋ฆฌํ๋ ๋ถํธํจ์ด ์ฌ๋ผ์ง๊ฒ ๋๋ฉฐ, ๊ด๋ฆฌ ํจ์จ์ฑ๋ ๋ ์ฆ๊ฐํ๊ฒ ๋ ๊ฒ์ด๋ค.
ํด๋น ํ๋ก์ ํธ์์๋ ๋ค์ํ Coroutine์ ํตํด ๊ฒ์ ๋ฉ์ปค๋์ฆ(Mainํ๋ฉด ์ด๋, ๊ฒ์ mode ์คํ, ๋ฌธ์ ๊ต์ฒด)๋ฅผ ๊ตฌํํ์๋๋ฐ ์ด๋ฌํ ๋ถ๋ถ์ ์์ด์ ์๊ฐ ๊ด๋ฆฌ๋ฅผ new WaitforSecond๋ก ์ฒ๋ฆฌํ๊ณ ์๋ค. ๋ฐ๋ผ์ ์ฝ๋ฃจํด์ด ์คํ๋ ๋๋ง๋ค ์๋ก์ด WaitforSecond ๋ฐ์ดํฐ๋ฅผ ๋ฉ๋ชจ๋ฆฌ์ ์ ์ธํด ์ฌ์ฉํ๊ณ ์์ผ๋ฉฐ ์ด๋ ์ฑ๋ฅ์ ์์ด์ ์ข์ง ์์ ์ํฅ์ ๋ฏธ์น๋ค.
๋คํํ Mainํ๋ฉด ์ด๋, ๊ฒ์ mode ์คํ์ ์์ฃผ ์คํ๋๋ Coroutine์ด ์๋๋ผ ์ด๋ฌํ ๋ถ๋ถ์ด ํฐ ์ํฅ์ ๋ฏธ์น์ง๋ ์์ง๋ง, ๋ฌธ์ ๊ต์ฒด๋ ์ด๋ณด๋ค๋ ๋น๋ฒํ๊ฒ ์คํ๋๋ฏ๋ก ๋งค๋ฒ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ ์ธํ๋ ๊ฒ์ด ๋ถ๋ด์ด ๋ ์ ์๋ค. ๋ฐ๋ผ์ Script ๋ด WaitforSecond ๋ณ์๋ฅผ ์ถ๊ฐํ๊ณ ์ฌ๊ธฐ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ ์ธํ ๋ค Coroutine์ด ์คํ๋ ๋ ๋ง๋ค ํด๋น ๋ณ์๋ฅผ ๋ถ๋ฌ์ ์ฌ์ฉํ๋ ๋ฐฉ์์ผ๋ก ๊ตฌ์กฐ๋ฅผ ๋ฐ๊พผ๋ค๋ฉด ๋ฉ๋ชจ๋ฆฌ ๋ถ๋ด์ ์ค์ผ ์ ์์ ๊ฒ์ด๋ค.