void DropdownValueChanged(Dropdown d) { switch (d.value) { case 0: sr.SetRes(1920, 1080); break; case 1: sr.SetRes(1280, 720); break; case 2: sr.SetRes(1152, 648); break; case 3: sr.SetRes(1024, 576); break; case 4: sr.SetRes(960, 540); break; case 5: sr.SetRes(896, 504); break; case 6: sr.SetRes(800, 450); break; case 7: sr.SetRes(768, 432); break; case 8: sr.SetRes(640, 360); break; case 9: sr.SetRes(256, 144); break; } }
void LateUpdate() { // Check if player presses pause key if (Input.GetKeyDown(pauseKey) && (!block_pause) && (!title)) { toggleMenu(); } if (Input.GetKeyDown(KeyCode.LeftArrow) && gamePause) { switch (pos_menu_v) { case 0: if (slider_music.slider.value != 0) { AudioPlayer.main.playSFX("sfx_type_key"); } else { AudioPlayer.main.playSFX("sfx_backspace"); } slider_music.slider.value -= 0.1f; slider_music.slider.value = Mathf.Max(slider_music.slider.value, 0.0f); break; case 1: if (slider_sfx.slider.value != 0) { AudioPlayer.main.playSFX("sfx_type_key"); } else { AudioPlayer.main.playSFX("sfx_backspace"); } slider_sfx.slider.value -= 0.1f; slider_sfx.slider.value = Mathf.Max(slider_sfx.slider.value, 0.0f); break; case 2: if (slider_scroll.slider.value != 0) { AudioPlayer.main.playSFX("sfx_type_key"); } else { AudioPlayer.main.playSFX("sfx_backspace"); } slider_scroll.slider.value -= 0.1f; slider_scroll.slider.value = Mathf.Max(slider_scroll.slider.value, 0.0f); break; case 3: if (pos_resolution != 0) { AudioPlayer.main.playSFX("sfx_type_key"); } else { AudioPlayer.main.playSFX("sfx_backspace"); } --pos_resolution; pos_resolution = Mathf.Max(pos_resolution, 0); break; case 4: if (pos_screenmode != 0) { AudioPlayer.main.playSFX("sfx_type_key"); } else { AudioPlayer.main.playSFX("sfx_backspace"); } pos_screenmode = 0; break; case 5: if (pos_menu_h != 0) { AudioPlayer.main.playSFX("sfx_enemy_select"); } pos_menu_h = 0; break; } } if (Input.GetKeyDown(KeyCode.RightArrow) && gamePause) { switch (pos_menu_v) { case 0: if (slider_music.slider.value != 1) { AudioPlayer.main.playSFX("sfx_type_key"); } else { AudioPlayer.main.playSFX("sfx_backspace"); } slider_music.slider.value += 0.1f; slider_music.slider.value = Mathf.Min(slider_music.slider.value, 1.0f); break; case 1: if (slider_sfx.slider.value != 1) { AudioPlayer.main.playSFX("sfx_type_key"); } else { AudioPlayer.main.playSFX("sfx_backspace"); } slider_sfx.slider.value += 0.1f; slider_sfx.slider.value = Mathf.Min(slider_sfx.slider.value, 1.0f); break; case 2: if (slider_scroll.slider.value != 1) { AudioPlayer.main.playSFX("sfx_type_key"); } else { AudioPlayer.main.playSFX("sfx_backspace"); } slider_scroll.slider.value += 0.1f; slider_scroll.slider.value = Mathf.Min(slider_scroll.slider.value, 1.0f); break; case 3: if (pos_resolution != 9) { AudioPlayer.main.playSFX("sfx_type_key"); } else { AudioPlayer.main.playSFX("sfx_backspace"); } ++pos_resolution; pos_resolution = Mathf.Min(pos_resolution, 9); break; case 4: if (pos_screenmode != 1) { AudioPlayer.main.playSFX("sfx_type_key"); } else { AudioPlayer.main.playSFX("sfx_backspace"); } pos_screenmode = 1; break; case 5: if (pos_menu_h != 1) { AudioPlayer.main.playSFX("sfx_enemy_select"); } pos_menu_h = 1; break; } } if (Input.GetKeyDown(KeyCode.UpArrow) && gamePause) { if (pos_menu_v != 0) { AudioPlayer.main.playSFX("sfx_enemy_select"); } --pos_menu_v; pos_menu_v = Mathf.Max(pos_menu_v, 0); pos_menu_h = 0; } if (Input.GetKeyDown(KeyCode.DownArrow) && gamePause) { if (pos_menu_v != 5) { AudioPlayer.main.playSFX("sfx_enemy_select"); } ++pos_menu_v; pos_menu_v = Mathf.Min(pos_menu_v, 5); } if ((Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return)) && gamePause) { if (pos_menu_v == 5) { if (pos_menu_h == 0) { AudioPlayer.main.playSFX("sfx_enter"); resolution_script.SetFull(Convert.ToBoolean(pos_screenmode)); selected_res = resolution_map [pos_resolution]; resolution_script.SetRes(selected_res [0], selected_res [1]); resolution_script.ApplySettings(); if (title) { toggleMenu(); } } else { AudioPlayer.main.playSFX("sfx_enter"); ExitGame(); } } } // UPDATE GRAPHICS BASED ON NEW VALUES if (pos_menu_v == 5) { select_instructions.SetActive(true); } else { select_instructions.SetActive(false); } string newvalue; newvalue = Mathf.RoundToInt(slider_music.slider.value * 100) + "%"; texts_toggles [0].text = newvalue; newvalue = Mathf.RoundToInt(slider_sfx.slider.value * 100) + "%"; texts_toggles [1].text = newvalue; newvalue = Mathf.RoundToInt(slider_scroll.slider.value * 100) + "%"; texts_toggles [2].text = newvalue; selected_res = resolution_map[pos_resolution]; texts_toggles [3].text = selected_res [0] + " x " + selected_res [1]; if (pos_screenmode == 1) { texts_toggles [4].text = "FULLSCREEN"; } else { texts_toggles [4].text = "WINDOWED"; } int y = 0; foreach (Image toggleimg in settings_toggles) { if (y == pos_menu_v) { toggleimg.sprite = images_toggles [1]; } else { toggleimg.sprite = images_toggles [0]; } ++y; } int x = 0; foreach (Image buttonimg in settings_buttons) { if (y == pos_menu_v) { if (x == pos_menu_h) { buttonimg.sprite = images_buttons [1]; } else { buttonimg.sprite = images_buttons [0]; } } else { buttonimg.sprite = images_buttons [0]; } ++x; } int isRightArrow = 0; foreach (Image arrowimg in toggle_arrows) { Vector3 new_arrow_pos; Vector3 go_away = new Vector3(arrowimg.rectTransform.localPosition.x, 42069, arrowimg.rectTransform.localPosition.z); switch (pos_menu_v) { case 0: new_arrow_pos = new Vector3(arrowimg.rectTransform.localPosition.x, 268, arrowimg.rectTransform.localPosition.z); arrowimg.rectTransform.localPosition = new_arrow_pos; if (isRightArrow == 1) { if (slider_music.slider.value == 1) { arrowimg.rectTransform.localPosition = go_away; } } else { if (slider_music.slider.value == 0) { arrowimg.rectTransform.localPosition = go_away; } } break; case 1: new_arrow_pos = new Vector3(arrowimg.rectTransform.localPosition.x, 188, arrowimg.rectTransform.localPosition.z); arrowimg.rectTransform.localPosition = new_arrow_pos; if (isRightArrow == 1) { if (slider_sfx.slider.value == 1) { arrowimg.rectTransform.localPosition = go_away; } } else { if (slider_sfx.slider.value == 0) { arrowimg.rectTransform.localPosition = go_away; } } break; case 2: new_arrow_pos = new Vector3(arrowimg.rectTransform.localPosition.x, 108, arrowimg.rectTransform.localPosition.z); arrowimg.rectTransform.localPosition = new_arrow_pos; if (isRightArrow == 1) { if (slider_scroll.slider.value == 1) { arrowimg.rectTransform.localPosition = go_away; } } else { if (slider_scroll.slider.value == 0) { arrowimg.rectTransform.localPosition = go_away; } } break; case 3: new_arrow_pos = new Vector3(arrowimg.rectTransform.localPosition.x, 28, arrowimg.rectTransform.localPosition.z); arrowimg.rectTransform.localPosition = new_arrow_pos; if (isRightArrow == 1) { if (pos_resolution == 9) { arrowimg.rectTransform.localPosition = go_away; } } else { if (pos_resolution == 0) { arrowimg.rectTransform.localPosition = go_away; } } break; case 4: new_arrow_pos = new Vector3(arrowimg.rectTransform.localPosition.x, -52, arrowimg.rectTransform.localPosition.z); arrowimg.rectTransform.localPosition = new_arrow_pos; if (isRightArrow == 1) { if (pos_screenmode == 1) { arrowimg.rectTransform.localPosition = go_away; } } else { if (pos_screenmode == 0) { arrowimg.rectTransform.localPosition = go_away; } } break; case 5: arrowimg.rectTransform.localPosition = go_away; break; } ++isRightArrow; } }