public IEnumerator control() { //sceneTransition.FadeIn(); StartCoroutine(ScreenFade.main.Fade(true, ScreenFade.defaultSpeed)); running = true; loadSettings(); int[] originalIndexes = new int[] { selectedOptionIndex[0], selectedOptionIndex[1], selectedOptionIndex[2], selectedOptionIndex[3], selectedOptionIndex[4], selectedOptionIndex[5], selectedOptionIndex[6], selectedOptionIndex[7] }; // float originalMVol = PlayerPrefs.GetFloat("musicVolume"); // float originalSVol = PlayerPrefs.GetFloat("sfxVolume"); selectedOption = 0; selectRow.pixelInset = new Rect(51, 144, selectRow.pixelInset.width, selectRow.pixelInset.height); drawDialogBox(); drawTextInstant(selectedOptionText[0]); while (running) { if (Input.GetAxisRaw("Vertical") > 0) { if (selectedOption > 0) { selectedOption -= 1; drawDialogBox(); if (selectedOption == 0) { StartCoroutine("drawText", selectedOptionText[selectedOption]); } else { drawTextInstant(selectedOptionText[selectedOption]); } SfxHandler.Play(selectClip); yield return(StartCoroutine("moveSelection", 1)); } } else if (Input.GetAxisRaw("Vertical") < 0) { if (selectedOption < 7) { selectedOption += 1; StopCoroutine("drawText"); drawDialogBox(); drawTextInstant(selectedOptionText[selectedOption]); SfxHandler.Play(selectClip); yield return(StartCoroutine("moveSelection", -1)); } } else if (Input.GetAxisRaw("Horizontal") > 0) { if (selectedOption == 1) { if (selectedOptionIndex[selectedOption] < selectedOptionSize[selectedOption] - 1) { selectedOptionIndex[selectedOption] += 1; updateOption(); yield return(new WaitForSeconds(0.05f)); } } else if (selectedOption == 2) { if (selectedOptionIndex[selectedOption] < selectedOptionSize[selectedOption] - 1) { selectedOptionIndex[selectedOption] += 1; updateOption(); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.05f)); } } else if (selectedOption == 3) { selectedOptionIndex[selectedOption] += 1; SfxHandler.Play(selectClip); if (selectedOptionIndex[selectedOption] > selectedOptionSize[selectedOption] - 1) { selectedOptionIndex[selectedOption] = 0; } updateOption(); yield return(new WaitForSeconds(0.2f)); } else { if (selectedOptionIndex[selectedOption] < selectedOptionSize[selectedOption] - 1) { selectedOptionIndex[selectedOption] += 1; SfxHandler.Play(selectClip); updateOption(); if (selectedOption == 0) { StopCoroutine("drawText"); drawDialogBox(); StartCoroutine("drawText", selectedOptionText[selectedOption]); } yield return(new WaitForSeconds(0.2f)); } } } else if (Input.GetAxisRaw("Horizontal") < 0) { if (selectedOption == 1) { if (selectedOptionIndex[selectedOption] > 0) { selectedOptionIndex[selectedOption] -= 1; updateOption(); yield return(new WaitForSeconds(0.05f)); } } else if (selectedOption == 2) { if (selectedOptionIndex[selectedOption] > 0) { selectedOptionIndex[selectedOption] -= 1; updateOption(); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.05f)); } } else if (selectedOption == 3) { selectedOptionIndex[selectedOption] -= 1; SfxHandler.Play(selectClip); if (selectedOptionIndex[selectedOption] < 0) { selectedOptionIndex[selectedOption] = selectedOptionSize[selectedOption] - 1; } updateOption(); yield return(new WaitForSeconds(0.2f)); } else { if (selectedOptionIndex[selectedOption] > 0) { selectedOptionIndex[selectedOption] -= 1; SfxHandler.Play(selectClip); updateOption(); if (selectedOption == 0) { StopCoroutine("drawText"); drawDialogBox(); StartCoroutine("drawText", selectedOptionText[selectedOption]); } yield return(new WaitForSeconds(0.2f)); } } } else if (Input.GetButton("Back")) { Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", "Would you like to save the currently \\selected settings?")); Dialog.drawChoiceBoxNo(); yield return(new WaitForSeconds(0.2f)); yield return(StartCoroutine(Dialog.choiceNavigateNo())); int chosenIndex = Dialog.chosenIndex; if (chosenIndex == 1) { saveSettings(); } else { //set music and sfx volume back // PlayerPrefs.SetFloat("musicVolume",originalMVol); // PlayerPrefs.SetFloat("sfxVolume",originalSVol); // PlayerPrefs.Save(); selectedOptionIndex = originalIndexes; saveSettings(); GlobalVariables.global.updateResolution(); } Dialog.undrawDialogBox(); Dialog.undrawChoiceBox(); //yield return new WaitForSeconds(sceneTransition.FadeOut()); yield return(StartCoroutine(ScreenFade.main.Fade(false, ScreenFade.defaultSpeed))); running = false; } yield return(null); } this.gameObject.SetActive(false); }
public IEnumerator control() { selectedIcon = 0; unhideIcons(); StartCoroutine("updateIcon", selectedIcon); SfxHandler.Play(openClip); yield return(StartCoroutine("openAnim")); running = true; while (running) { if (selectedIcon == 0) { if (Input.GetAxisRaw("Vertical") > 0) { selectedIcon = 2; StartCoroutine("updateIcon", selectedIcon); SfxHandler.Play(selectClip); } else if (Input.GetAxisRaw("Horizontal") < 0) { selectedIcon = 1; StartCoroutine("updateIcon", selectedIcon); SfxHandler.Play(selectClip); } else if (Input.GetAxisRaw("Vertical") < 0) { selectedIcon = 5; StartCoroutine("updateIcon", selectedIcon); SfxHandler.Play(selectClip); } else if (Input.GetAxisRaw("Horizontal") > 0) { selectedIcon = 3; StartCoroutine("updateIcon", selectedIcon); SfxHandler.Play(selectClip); } } else { if (Input.GetAxisRaw("Vertical") > 0) { if (selectedIcon > 3) { selectedIcon -= 3; StartCoroutine("updateIcon", selectedIcon); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } else if (Input.GetAxisRaw("Horizontal") > 0) { if (selectedIcon != 3 && selectedIcon != 6) { selectedIcon += 1; StartCoroutine("updateIcon", selectedIcon); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } else if (Input.GetAxisRaw("Vertical") < 0) { if (selectedIcon < 4) { selectedIcon += 3; StartCoroutine("updateIcon", selectedIcon); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } else if (Input.GetAxisRaw("Horizontal") < 0) { if (selectedIcon != 1 && selectedIcon != 4) { selectedIcon -= 1; StartCoroutine("updateIcon", selectedIcon); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } else if (Input.GetButton("Select")) { if (selectedIcon == 1) { //Pokedex Debug.Log("Pokédex not yet implemented"); yield return(new WaitForSeconds(0.2f)); } else if (selectedIcon == 2) { //Party SfxHandler.Play(selectClip); //StartCoroutine(fadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); hideIcons(); yield return(StartCoroutine(runSceneUntilDeactivated(Scene.main.Party.gameObject))); unhideIcons(); //StartCoroutine(unfadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); } else if (selectedIcon == 3) { //Bag SfxHandler.Play(selectClip); //StartCoroutine(fadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); hideIcons(); yield return(StartCoroutine(runSceneUntilDeactivated(Scene.main.Bag.gameObject))); unhideIcons(); //StartCoroutine(unfadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); } else if (selectedIcon == 4) { //TrainerCard SfxHandler.Play(selectClip); //StartCoroutine(fadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); hideIcons(); yield return(StartCoroutine(runSceneUntilDeactivated(Scene.main.Trainer.gameObject))); unhideIcons(); //StartCoroutine(unfadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); } else if (selectedIcon == 5) { //Save saveDataDisplay.gameObject.SetActive(true); saveDataDisplay.texture = Resources.Load <Texture>("Frame/choice" + PlayerPrefs.GetInt("frameStyle")); iconPokedex.hide = true; //hide this icon as it is in the way int badgeTotal = 0; for (int i = 0; i < 12; i++) { if (SaveData.currentSave.gymsBeaten[i]) { badgeTotal += 1; } } string playerTime = "" + SaveData.currentSave.playerMinutes; if (playerTime.Length == 1) { playerTime = "0" + playerTime; } playerTime = SaveData.currentSave.playerHours + " : " + playerTime; mapName.text = PlayerMovement.player.accessedMapSettings.mapName; dataText.text = SaveData.currentSave.playerName + "\n" + badgeTotal + "\n" + "0" + "\n" + //pokedex not yet implemented playerTime; mapNameShadow.text = mapName.text; dataTextShadow.text = dataText.text; Dialog.drawDialogBox(); yield return(StartCoroutine(Dialog.drawText("Would you like to save the game?"))); Dialog.drawChoiceBoxNo(); yield return(new WaitForSeconds(0.2f)); yield return(StartCoroutine(Dialog.choiceNavigateNo())); int chosenIndex = Dialog.chosenIndex; if (chosenIndex == 1) { //update save file Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); SaveData.currentSave.levelName = Application.loadedLevelName; SaveData.currentSave.playerPosition = new SeriV3(PlayerMovement.player.transform.position); SaveData.currentSave.playerDirection = PlayerMovement.player.direction; SaveData.currentSave.mapName = PlayerMovement.player.accessedMapSettings.mapName; NonResettingHandler.saveDataToGlobal(); SaveLoad.Save(); yield return (StartCoroutine(Dialog.drawText(SaveData.currentSave.playerName + " saved the game!"))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } Dialog.undrawDialogBox(); Dialog.undrawChoiceBox(); iconPokedex.hide = false; saveDataDisplay.gameObject.SetActive(false); yield return(new WaitForSeconds(0.2f)); } else if (selectedIcon == 6) { //Settings SfxHandler.Play(selectClip); //StartCoroutine(fadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); hideIcons(); yield return(StartCoroutine(runSceneUntilDeactivated(Scene.main.Settings.gameObject))); unhideIcons(); //StartCoroutine(unfadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); } } } if (Input.GetButton("Start") || Input.GetButton("Back")) { running = false; } yield return(null); } yield return(StartCoroutine("closeAnim")); this.gameObject.SetActive(false); }
public IEnumerator control() { yield return(StartCoroutine(ScreenFade.main.Fade(true, 0f))); GlobalVariables.global.SetRPCLargeImageKey("main_menu", "Main Menu"); GlobalVariables.global.SetRPCState("In the Main Menu"); GlobalVariables.global.UpdatePresence(); if (!newGame) { int fileCount = SaveLoad.getSavedGamesCount(); if (fileCount == 0) { updateButton(1); continueButton.SetActive(false); fileDataPanel.SetActive(false); for (int i = 1; i < 3; i++) { button[i].pixelInset = new Rect(button[i].pixelInset.x, button[i].pixelInset.y + 64f, button[i].pixelInset.width, button[i].pixelInset.height); buttonHighlight[i].pixelInset = new Rect(buttonHighlight[i].pixelInset.x, buttonHighlight[i].pixelInset.y + 64f, buttonHighlight[i].pixelInset.width, buttonHighlight[i].pixelInset.height); buttonText[i].pixelOffset = new Vector2(buttonText[i].pixelOffset.x, buttonText[i].pixelOffset.y + 64f); buttonTextShadow[i].pixelOffset = new Vector2(buttonTextShadow[i].pixelOffset.x, buttonTextShadow[i].pixelOffset.y + 64f); } } else { updateButton(0); updateFile(0); StartCoroutine(animateIcons()); if (fileCount == 1) { fileNumbersText.text = "File 1"; } else if (fileCount == 2) { fileNumbersText.text = "File 1 2"; } else if (fileCount == 3) { fileNumbersText.text = "File 1 2 3"; } } bool running = true; while (running) { if (newGame) { running = false; } if (Input.GetButtonDown("Select")) { if (selectedButton == 0) //CONTINUE { SfxHandler.Play(selectClip); SaveData.currentSave = SaveLoad.savedGames[selectedFile]; yield return(StartCoroutine("openAnim")); } else if (selectedButton == 1) //NEW GAME { SfxHandler.Play(selectClip); yield return(StartCoroutine("openAnimNewGame")); } else if (selectedButton == 2) { //SETTINGS SfxHandler.Play(selectClip); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); Scene.main.Settings.gameObject.SetActive(true); StartCoroutine(Scene.main.Settings.control()); while (Scene.main.Settings.gameObject.activeSelf) { yield return(null); } //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); } } else if (Input.GetKeyDown(KeyCode.Delete)) { Dialog.drawDialogBox(); yield return(Dialog.StartCoroutine("drawText", "Are you sure you want to delete Save #" + (selectedFile + 1) + "?")); Dialog.drawChoiceBoxNo(); yield return(new WaitForSeconds(0.2f)); yield return(StartCoroutine(Dialog.choiceNavigateNo())); int chosenIndex = Dialog.chosenIndex; if (chosenIndex == 1) { SaveLoad.resetSaveGame(selectedFile); GlobalVariables.global.debug("Save " + (selectedFile + 1) + " was deleted!"); Dialog.undrawDialogBox(); Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); yield return(Dialog.StartCoroutine("drawText", "Save #" + (selectedFile + 1) + " was deleted!")); yield return(new WaitForSeconds(2f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); UnityEngine.SceneManagement.SceneManager.LoadScene(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name); } else { Dialog.undrawDialogBox(); Dialog.undrawChoiceBox(); } } else { if (Input.GetAxisRaw("Vertical") > 0) { float minimumButton = (continueButton.activeSelf) ? 0 : 1; if (selectedButton > minimumButton) { updateButton(selectedButton - 1); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } else if (Input.GetAxisRaw("Vertical") < 0) { if (selectedButton < 2) { updateButton(selectedButton + 1); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } if (Input.GetAxisRaw("Horizontal") > 0) { if (selectedButton == 0) { if (selectedFile < fileCount - 1) { updateFile(selectedFile + 1); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } } else if (Input.GetAxisRaw("Horizontal") < 0) { if (selectedButton == 0) { if (selectedFile > 0) { updateFile(selectedFile - 1); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } } } yield return(null); } } }
public IEnumerator control() { int fileCount = SaveLoad.getSavedGamesCount(); //NEW GAME #region NEW GAME if (fileCount == 0) { BgmHandler.main.PlayMain(menuBGM, 0); newGame = true; importantThings.SetActive(true); updateButton(1); continueButton.SetActive(false); fileDataPanel.SetActive(false); for (int i = 1; i < 3; i++) { button[i].pixelInset = new Rect(button[i].pixelInset.x, button[i].pixelInset.y + 64f, button[i].pixelInset.width, button[i].pixelInset.height); buttonHighlight[i].pixelInset = new Rect(buttonHighlight[i].pixelInset.x, buttonHighlight[i].pixelInset.y + 64f, buttonHighlight[i].pixelInset.width, buttonHighlight[i].pixelInset.height); buttonText[i].pixelOffset = new Vector2(buttonText[i].pixelOffset.x, buttonText[i].pixelOffset.y + 64f); buttonTextShadow[i].pixelOffset = new Vector2(buttonTextShadow[i].pixelOffset.x, buttonTextShadow[i].pixelOffset.y + 64f); } transform.Find("NewGame").gameObject.SetActive(false); transform.Find("Settings").gameObject.SetActive(false); StartCoroutine("animBG"); yield return(new WaitForSeconds(2f)); SaveData.currentSave.startTime = System.DateTime.UtcNow; yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); importantThings.SetActive(false); transform.Find("OpeningLecture").gameObject.SetActive(true); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0f))); yield return(StartCoroutine("openAnimNewGame")); } #endregion else { BgmHandler.main.PlayMain(menuBGM, 0); updateButton(0); updateFile(0); StartCoroutine(animateIcons()); if (fileCount == 1) { fileNumbersText.text = "File 1"; fileNumbersTextShadow.text = "File 1"; } else if (fileCount == 2) { fileNumbersText.text = "File 1 2"; fileNumbersTextShadow.text = "File 1 2"; } else if (fileCount == 3) { fileNumbersText.text = "File 1 2 3"; fileNumbersTextShadow.text = "File 1 2"; } } running = true; //bool introup = true; StartCoroutine("animBG"); /*if(introup == true) { * yield return new WaitForSeconds(3.2f); * yield return StartCoroutine(ScreenFade.main.Fade(false, 0.2f)); * yield return new WaitForSeconds(0.2f); * yield return StartCoroutine(ScreenFade.main.Fade(true, 0.2f)); * yield return new WaitForSeconds(3.2f); * yield return StartCoroutine(ScreenFade.main.Fade(false, 0.2f)); * yield return new WaitForSeconds(0.2f); * introBackground.color = new UnityEngine.Color(0.5f,0.5f,0.5f); * yield return StartCoroutine(ScreenFade.main.Fade(true, 0.2f)); * yield return new WaitForSeconds(15.5f); * yield return StartCoroutine(ScreenFade.main.Fade(false, 0.2f)); * yield return new WaitForSeconds(0.2f); * introup = false; * intro.SetActive(false); * yield return StartCoroutine(ScreenFade.main.Fade(true, 0.2f)); * //yield return StartCoroutine(ScreenFade.main.Fade(true, 0.4f)); * }*/ while (running) { if (Input.GetButtonDown("Select")) { if (selectedButton == 0) //CONTINUE { SfxHandler.Play(selectClip); yield return(StartCoroutine("openAnim")); } else if (selectedButton == 1) //NEW GAME { SfxHandler.Play(selectClip); yield return(StartCoroutine("openAnimNewGame")); } else if (selectedButton == 2) //SETTINGS { SfxHandler.Play(selectClip); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); Scene.main.Settings.gameObject.SetActive(true); StartCoroutine(Scene.main.Settings.control()); while (Scene.main.Settings.gameObject.activeSelf) { yield return(null); } //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); } } /*else if(Input.GetKeyDown(KeyCode.Delete)){ //delete save file * SfxHandler.Play(selectClip2); * float time = Time.time; * bool released = false; * Debug.Log("Save "+(selectedFile+1)+" will be deleted! Release 'Delete' key to prevent this!"); * while(Time.time < time+4 && !released){ * if(Input.GetKeyUp(KeyCode.Delete)){ * released = true; * SfxHandler.Play(selectClip3); * } * yield return null;} * * if(Input.GetKey(KeyCode.Delete) && !released){ * SfxHandler.Play(selectClip4); * SaveLoad.resetSaveGame(selectedFile); * Debug.Log("Save "+(selectedFile+1)+" was deleted!"); * * yield return new WaitForSeconds(1f); * * Application.LoadLevel(Application.loadedLevel); * } * else{ * Debug.Log("'Delete' key was released!"); * } * yield return null; * }*/ else if (Input.GetKeyDown(KeyCode.Delete)) { Dialog.drawDialogBox(); yield return(Dialog.StartCoroutine("drawText", "Are you sure you want to delete Save #" + (selectedFile + 1) + "?")); Dialog.drawChoiceBoxNo(); yield return(new WaitForSeconds(0.2f)); yield return(StartCoroutine(Dialog.choiceNavigateNo())); int chosenIndex = Dialog.chosenIndex; if (chosenIndex == 1) { SaveLoad.resetSaveGame(selectedFile); Debug.Log("Save " + (selectedFile + 1) + " was deleted!"); Dialog.undrawDialogBox(); Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); yield return(Dialog.StartCoroutine("drawText", "Save #" + (selectedFile + 1) + " was deleted!")); yield return(new WaitForSeconds(2f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); UnityEngine.SceneManagement.SceneManager.LoadScene(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name); } else { Dialog.undrawDialogBox(); Dialog.undrawChoiceBox(); } } else { if (Input.GetAxisRaw("Vertical") > 0) { float minimumButton = (continueButton.activeSelf)? 0 : 1; if (selectedButton > minimumButton) { updateButton(selectedButton - 1); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } else if (Input.GetAxisRaw("Vertical") < 0) { if (selectedButton < 2) { updateButton(selectedButton + 1); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } if (Input.GetAxisRaw("Horizontal") > 0) { if (selectedButton == 0) { if (selectedFile < fileCount - 1) { updateFile(selectedFile + 1); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } } else if (Input.GetAxisRaw("Horizontal") < 0) { if (selectedButton == 0) { if (selectedFile > 0) { updateFile(selectedFile - 1); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } } } yield return(null); } }