void Awake() { if (currentActive == null) { currentActive = this; } else if (currentActive != this) { this.enabled = false; } Transform trainersList = transform.FindChild("Trainers"); Transform itemsList = transform.FindChild("Items"); Transform eventsList = transform.FindChild("Events"); trainers = new InteractTrainer[trainersList.childCount]; items = new InteractItem[itemsList.childCount]; events = new GameObject[eventsList.childCount]; for (int i = 0; i < trainers.Length; i++) { trainers[i] = trainersList.GetChild(i).GetComponent <InteractTrainer>(); } for (int i = 0; i < items.Length; i++) { items[i] = itemsList.GetChild(i).GetComponent <InteractItem>(); } for (int i = 0; i < events.Length; i++) { events[i] = eventsList.GetChild(i).gameObject; } }
public IEnumerator bump() { if (!isLocked && !PlayerMovement.player.isInputPaused()) { if (PlayerMovement.player.setCheckBusyWith(this.gameObject)) { if (enterSound != null) { if (!enterSound.isPlaying) { enterSound.volume = PlayerPrefs.GetFloat("sfxVolume"); enterSound.Play(); } } if (entranceStyle == EntranceStyle.SWINGRIGHT) { PlayerMovement.player.running = false; PlayerMovement.player.speed = PlayerMovement.player.walkSpeed; PlayerMovement.player.updateAnimation("walk", PlayerMovement.player.walkFPS); float increment = 0f; float speed = 0.25f; float yRotation = transform.localEulerAngles.y; while (increment < 1) { increment += (1f / speed) * Time.deltaTime; if (increment > 1) { increment = 1; } transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, yRotation + (90f * increment), transform.localEulerAngles.z); PlayerMovement.player.mainCamera.fieldOfView = PlayerMovement.player.mainCameraDefaultFOV - ((PlayerMovement.player.mainCameraDefaultFOV / 10f) * increment); yield return(null); } yield return(new WaitForSeconds(0.2f)); } else if (entranceStyle == EntranceStyle.SLIDE) { PlayerMovement.player.running = false; PlayerMovement.player.speed = PlayerMovement.player.walkSpeed; PlayerMovement.player.updateAnimation("walk", PlayerMovement.player.walkFPS); float increment = 0f; float speed = 0.25f; while (increment < 1) { increment += (1 / speed) * Time.deltaTime; if (increment > 1) { increment = 1; } transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y, 1f - (0.92f * increment)); PlayerMovement.player.mainCamera.fieldOfView = 20f - (2f * increment); yield return(null); } yield return(new WaitForSeconds(0.2f)); } if (entranceStyle != EntranceStyle.STANDSTILL) { if (entranceStyle != EntranceStyle.OPEN) { StartCoroutine(lockCameraPosition()); yield return(new WaitForSeconds(0.1f)); } PlayerMovement.player.forceMoveForward(); } //fade out the scene and load a new scene GlobalVariables.global.fadeTex = fadeTex; //float fadeTime = sceneTransition.FadeOut() + 0.4f; float fadeTime = ScreenFade.slowedSpeed + 0.4f; //fadeCutouts for doorways not yet implemented StartCoroutine(ScreenFade.main.Fade(false, ScreenFade.slowedSpeed)); if (!dontFadeMusic) { BgmHandler.main.PlayMain(null, 0); } yield return(new WaitForSeconds(fadeTime)); //reset camera and doorway transforms PlayerMovement.player.mainCamera.transform.localPosition = PlayerMovement.player.mainCameraDefaultPosition; PlayerMovement.player.mainCamera.fieldOfView = PlayerMovement.player.mainCameraDefaultFOV; transform.localPosition = initPosition; transform.localRotation = initRotation; transform.localScale = initScale; if (!string.IsNullOrEmpty(transferScene)) { NonResettingHandler.saveDataToGlobal(); GlobalVariables.global.playerPosition = transferPosition; GlobalVariables.global.playerDirection = transferDirection; GlobalVariables.global.playerForwardOnLoad = movesForward; GlobalVariables.global.fadeIn = true; Application.LoadLevel(transferScene); } else { //uncheck busy with to ensure events at destination can be run. PlayerMovement.player.unsetCheckBusyWith(this.gameObject); //transfer to current scene, no saving/loading nessecary PlayerMovement.player.updateAnimation("walk", PlayerMovement.player.walkFPS); PlayerMovement.player.speed = PlayerMovement.player.walkSpeed; PlayerMovement.player.transform.position = transferPosition; PlayerMovement.player.updateDirection(transferDirection); if (movesForward) { PlayerMovement.player.forceMoveForward(); } GlobalVariables.global.fadeIn = true; //SceneTransition.gameScene.FadeIn(); StartCoroutine(ScreenFade.main.Fade(true, ScreenFade.slowedSpeed)); yield return(new WaitForSeconds(0.1f)); PlayerMovement.player.pauseInput(0.2f); } } } }
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() { setup.carousel.position = 0; setSelectedText("Bag"); SfxHandler.Play(setup.openClip); yield return(StartCoroutine(openAnim())); state = PauseState.Open; //set elsewhere not just here while (state == PauseState.Open) { if (Input.GetAxisRaw("Horizontal") != 0) { SfxHandler.Play(setup.selectClip); yield return(StartCoroutine(updatePosition(Input.GetAxisRaw("Horizontal")))); } else if (Input.GetButton("Select")) { switch (pauseIcons[setup.carousel.selectedPosition].mode) { case ImageMode.RunScene: SfxHandler.Play(setup.selectClip); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); yield return(StartCoroutine(runSceneUntilDeactivated(SceneScript.main.CastToScene(pauseIcons[setup.carousel.position].scene)))); break; case ImageMode.RunEvent: pauseIcons[setup.carousel.position].activatorEvent.Invoke(); break; case ImageMode.Save: setup.saveDataDisplay.gameObject.SetActive(true); setup.saveDataDisplay.sprite = Resources.Load <Sprite>("Frame/choice" + PlayerPrefs.GetInt("frameStyle")); 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; setup.mapName.text = Player.player.accessedMapSettings.mapName; setup.dataText.text = SaveData.currentSave.playerName + "\n" + badgeTotal + "\n" + "0" + "\n" + //pokedex not yet implemented playerTime; SceneScript.main.Dialog.DrawDialogBox(); yield return(StartCoroutine(SceneScript.main.Dialog.DrawText("Would you like to save the game?"))); yield return(StartCoroutine(SceneScript.main.Dialog.DrawChoiceBox(0))); int chosenIndex = SceneScript.main.Dialog.chosenIndex; if (chosenIndex == 1) { //update save file SceneScript.main.Dialog.UndrawChoiceBox(); SaveData.currentSave.levelName = SceneManager.GetActiveScene().name; SaveData.currentSave.playerPosition = new SeriV3(Player.player.transform.position); SaveData.currentSave.playerDirection = (int)Player.player.direction; SaveData.currentSave.mapName = Player.player.accessedMapSettings.mapName; NonResettingHandler.saveDataToGlobal(); SaveLoad.Save(); SceneScript.main.Dialog.DrawDialogBox(); yield return (StartCoroutine(SceneScript.main.Dialog.DrawText(SaveData.currentSave.playerName + " saved the game!"))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } SceneScript.main.Dialog.UnDrawDialogBox(); SceneScript.main.Dialog.UndrawChoiceBox(); setup.saveDataDisplay.gameObject.SetActive(false); yield return(new WaitForSeconds(0.2f)); break; case ImageMode.NotImplemented: SceneScript.main.Dialog.DrawDialogBox(); yield return(StartCoroutine(SceneScript.main.Dialog.DrawText("This menu has not yet been implemented."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } SceneScript.main.Dialog.UnDrawDialogBox(); yield return(new WaitForSeconds(0.2f)); break; } } if (Input.GetButton("Start") || Input.GetButton("Back")) { state = PauseState.Closing; } yield return(null); } yield return(StartCoroutine(closeAnim())); setup.pauseBottom.gameObject.SetActive(false); gameObject.SetActive(false); }