public IEnumerator interact() { OwnedPokemon targetPokemon = SaveData.currentSave.PC.getFirstFieldEffectUserInParty(fieldEffect); if (targetPokemon != null) { if (PlayerMovement.player.setCheckBusyWith(this.gameObject)) { Dialog.drawDialogBox(); //yield return StartCoroutine blocks the next code from running until coroutine is done. yield return(Dialog.StartCoroutine("drawText", interactText)); /* //This inactive code is used to print a third line of text. * while(!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")){ //these 3 lines stop the next bit from running until space is pressed. * yield return null; * } * Dialog.StartCoroutine("scrollText"); * yield return Dialog.StartCoroutine("drawText", "\\That'd be neat."); */ Dialog.drawChoiceBox(); //You CAN NOT get a value from a Coroutine. As a result, the coroutine runs and resets a public int in it's own script. yield return(Dialog.StartCoroutine(Dialog.choiceNavigate())); //it then assigns a value to that int Dialog.undrawChoiceBox(); if (Dialog.chosenIndex == 1) { //check that int's value Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", targetPokemon.GetName() + " used " + targetPokemon.getFirstFEInstance(fieldEffect) + "!")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.undrawDialogBox(); yield return(new WaitForSeconds(0.5f)); //Run the animation and remove the tree objectLight.enabled = true; if (!breakSound.isPlaying && !breaking) { breakSound.volume = PlayerPrefs.GetFloat("sfxVolume"); breakSound.Play(); } myAnimator.SetBool("break", true); myAnimator.SetBool("rewind", false); breaking = true; yield return(new WaitForSeconds(1f)); } Dialog.undrawDialogBox(); yield return(new WaitForSeconds(0.2f)); PlayerMovement.player.unsetCheckBusyWith(this.gameObject); } } else { if (PlayerMovement.player.setCheckBusyWith(this.gameObject)) { Dialog.drawDialogBox(); //yield return StartCoroutine blocks the next code from running until coroutine is done. yield return(Dialog.StartCoroutine("drawText", examineText)); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.undrawDialogBox(); yield return(new WaitForSeconds(0.2f)); PlayerMovement.player.unsetCheckBusyWith(this.gameObject); } } }
public IEnumerator interact() { if (!Player.strength) { OwnedPokemon targetPokemon = SaveData.currentSave.PC.getFirstFieldEffectUserInParty("Strength"); if (targetPokemon != null) { if (Player.setCheckBusyWith(this.gameObject)) { Dialog.drawDialogBox(); //yield return StartCoroutine blocks the next code from running until coroutine is done. yield return(Dialog.StartCoroutine("drawText", interactText)); Dialog.drawChoiceBox(); //You CAN NOT get a value from a Coroutine. As a result, the coroutine runs and resets a public int in it's own script. yield return(Dialog.StartCoroutine(Dialog.choiceNavigate())); //it then assigns a value to that int Dialog.undrawChoiceBox(); if (Dialog.chosenIndex == 1) { Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", targetPokemon.GetName() + " used " + targetPokemon.getFirstFEInstance("Strength") + "!") ); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.undrawDialogBox(); //Activate strength Player.activateStrength(); yield return(new WaitForSeconds(0.5f)); } Dialog.undrawDialogBox(); } } else { if (Player.setCheckBusyWith(this.gameObject)) { Dialog.drawDialogBox(); //yield return StartCoroutine blocks the next code from running until coroutine is done. yield return(Dialog.StartCoroutine("drawText", examineText)); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.undrawDialogBox(); } } } else { if (Player.setCheckBusyWith(this.gameObject)) { Dialog.drawDialogBox(); //yield return StartCoroutine blocks the next code from running until coroutine is done. yield return(Dialog.StartCoroutine("drawText", examineTextStrengthActive)); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.undrawDialogBox(); } } yield return(new WaitForSeconds(0.2f)); Player.unsetCheckBusyWith(this.gameObject); }
private IEnumerator surfCheck() { OwnedPokemon targetPokemon = SaveData.currentSave.PC.getFirstFieldEffectUserInParty("Surf"); if (targetPokemon != null) { if (getForwardVector(direction, false) != Vector3.zero) { if (setCheckBusyWith(this.gameObject)) { Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", "The water is dyed a deep blue. Would you \nlike to surf on it?")); Dialog.drawChoiceBox(); yield return(Dialog.StartCoroutine("choiceNavigate")); Dialog.undrawChoiceBox(); int chosenIndex = Dialog.chosenIndex; if (chosenIndex == 1) { Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", targetPokemon.GetName() + " used " + targetPokemon.getFirstFEInstance("Surf") + "!")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } surfing = true; updateMount(true, "surf"); BgmHandler.main.PlayMain(GlobalVariables.global.surfBGM, GlobalVariables.global.surfBgmLoopStart); //determine the vector for the space in front of the player by checking direction Vector3 spaceInFront = new Vector3(0, 0, 0); if (direction == 0) { spaceInFront = new Vector3(0, 0, 1); } else if (direction == 1) { spaceInFront = new Vector3(1, 0, 0); } else if (direction == 2) { spaceInFront = new Vector3(0, 0, -1); } else if (direction == 3) { spaceInFront = new Vector3(-1, 0, 0); } mount.transform.position = mount.transform.position + spaceInFront; followerScript.StartCoroutine("withdrawToBall"); StartCoroutine("stillMount"); forceMoveForward(); yield return(StartCoroutine("jump")); updateAnimation("surf", walkFPS); speed = surfSpeed; } Dialog.undrawDialogBox(); unsetCheckBusyWith(this.gameObject); } } } else { if (setCheckBusyWith(this.gameObject)) { Dialog.drawDialogBox(); yield return(Dialog.StartCoroutine("drawText", "The water is dyed a deep blue.")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.undrawDialogBox(); unsetCheckBusyWith(this.gameObject); } } yield return(new WaitForSeconds(0.2f)); }