// Update is called once per frame void Update() { //if on android, tap will go to arcade game screen #if UNITY_ANDROID MobileInput.InputType input = MobileInput.getInput(); if (input == MobileInput.InputType.hold) { SceneManager.LoadScene("TitleScreen"); } else if (input == MobileInput.InputType.left) { SceneManager.LoadScene("RMTutorial"); } else if (input == MobileInput.InputType.up) { source.Stop(); rhythm_game.SetGameMode(Rhythm.GameMode.normal); rhythm_game.enabled = true; play_menu_prompt = false; this.enabled = false; } else if (input == MobileInput.InputType.right) { source.Stop(); rhythm_game.SetGameMode(Rhythm.GameMode.normal); rhythm_game.enabled = true; play_menu_prompt = false; this.enabled = false; } else if (input == MobileInput.InputType.down) { SceneManager.LoadScene("MinigameScreen"); } #endif if (Input.GetKeyDown("left")) //"Tutorial level", just for explaining gameplay { SceneManager.LoadScene("RMTutorial"); } else if (Input.GetKeyDown("up")) //Beginning mode { source.Stop(); rhythm_game.SetGameMode(Rhythm.GameMode.normal); rhythm_game.enabled = true; this.enabled = false; play_menu_prompt = false; } else if (Input.GetKeyDown("right")) //Intermediate { source.Stop(); rhythm_game.SetGameMode(Rhythm.GameMode.hard); rhythm_game.enabled = true; this.enabled = false; play_menu_prompt = false; } else if (Input.GetKeyDown("down")) { SceneManager.LoadScene("MinigameScreen"); } }
// Update is called once per frame void Update() { //If running on Unity Android, run this block to use mobile input controls #if UNITY_ANDROID MobileInput.InputType input = MobileInput.getInput(); if (input == MobileInput.InputType.up) { SceneManager.LoadScene(Load.lastPlayedGame, LoadSceneMode.Single); } if (input == MobileInput.InputType.down) { SceneManager.LoadScene("TitleScreen", LoadSceneMode.Single); } #endif //Run desktop keyboard/mouse controls if (Input.GetKeyDown("up")) { SceneManager.LoadScene(Load.lastPlayedGame, LoadSceneMode.Single); } else if (Input.GetKeyDown("down")) { SceneManager.LoadScene("TitleScreen", LoadSceneMode.Single); } //This function returns the game to main menu after 3 seconds //StartCoroutine(gameOverScreen()); }
// Update is called once per frame void Update() { if (isUsersTurn) { if (!inputDelayActive) { HandlePlayerInput(); } } #if UNITY_ANDROID MobileInput.InputType input2 = MobileInput.getInput(); if (input2 == MobileInput.InputType.hold) { SceneManager.LoadScene("TitleScreen"); } #endif //if user hits escape, go back to main menu if (Input.GetKeyDown("escape")) { print("ESCAPE"); SceneManager.LoadScene("TitleScreen"); } //user should be able to reload scene if (Input.GetKeyDown(KeyCode.R)) { print("attempting scene reload"); Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name); } }
public IEnumerator OnStart() { direction_noise.PlayOneShot(instructions); while (!Input.GetKeyDown("return") && direction_noise.isPlaying && MobileInput.getInput() != MobileInput.InputType.tap) { yield return(null); } direction_noise.Stop(); yield return(new WaitForSeconds(0.2f)); direction_noise.PlayOneShot(welcome); while (!Input.GetKeyDown("return") && direction_noise.isPlaying && MobileInput.getInput() != MobileInput.InputType.tap) { yield return(null); } direction_noise.Stop(); StartCoroutine(show_sequence()); }
void HandlePlayerInputMobile() { MobileInput.InputType input = MobileInput.getInput(); if (!isRotating) { if (input == MobileInput.InputType.right) { playerFacing = (Directions)(((int)playerFacing + 1) % 4); StartCoroutine(rotatePlayer(transform.rotation, transform.rotation * Quaternion.Euler(0, -90, 0), rotationDuration)); } else if (input == MobileInput.InputType.left) { StartCoroutine(rotatePlayer(transform.rotation, transform.rotation * Quaternion.Euler(0, 90, 0), rotationDuration)); playerFacing = (Directions)(((int)playerFacing + 3) % 4); //mod on negative doesn't work, this is equivalent to subtracting 1 } } if (!weaponDelayActive) { if (input == MobileInput.InputType.up) { spawners[(int)playerFacing].playerSwing(currentWeapon); StartCoroutine(inputController()); } } if (input == MobileInput.InputType.down) { currentWeapon = (PlayerWeapons)(((int)currentWeapon + 1) % numberOfWeapons); playerAudioSource.PlayOneShot(weaponEquipSound[(int)currentWeapon], 0.3f); weaponDelayActive = false; } }
//function to wait for user input IEnumerator WaitForKeyDown(KeyCode keyCode, MobileInput.InputType m_input) { while (!Input.GetKeyDown(keyCode) && m_input != MobileInput.getInput()) { yield return(null); } }
// Update is called once per frame void Update() { //if on android, tap will go to arcade game screen #if UNITY_ANDROID MobileInput.InputType input = MobileInput.getInput(); if (input == MobileInput.InputType.hold) { SceneManager.LoadScene("TitleScreen"); } else if (input == MobileInput.InputType.left) { SceneManager.LoadScene("SCTutorial"); } else if (input == MobileInput.InputType.up) { source.Stop(); script.SetGameMode(SwordCombat.GameMode.normal); script.enabled = true; Destroy(this); } else if (input == MobileInput.InputType.right) { source.Stop(); script.SetGameMode(SwordCombat.GameMode.hard); script.enabled = true; Destroy(this); } else if (input == MobileInput.InputType.down) { SceneManager.LoadScene("MinigameScreen"); } #endif if (Input.GetKeyDown("left")) //"Tutorial level" { SceneManager.LoadScene("SCTutorial"); } else if (Input.GetKeyDown("up")) //Beginning mode { source.Stop(); script.SetGameMode(SwordCombat.GameMode.normal); script.enabled = true; Destroy(this); } else if (Input.GetKeyDown("right")) //Intermediate { source.Stop(); script.SetGameMode(SwordCombat.GameMode.hard); script.enabled = true; Destroy(this); } else if (Input.GetKeyDown("down")) { SceneManager.LoadScene("MinigameScreen"); } }
// Update is called once per frame void Update() { //if on android, tap will go to arcade game screen #if UNITY_ANDROID MobileInput.InputType input = MobileInput.getInput(); if (input == MobileInput.InputType.left) { SceneManager.LoadScene("SCTutorial"); } else if (input == MobileInput.InputType.up) { script.SetGameMode(SwordCombat.GameMode.normal); script.enabled = true; Destroy(this); } else if (input == MobileInput.InputType.right) { script.SetGameMode(SwordCombat.GameMode.hard); script.enabled = true; Destroy(this); } else if (Input.GetKeyDown("3")) //Intermediate { script.SetGameMode(SwordCombat.GameMode.hard); script.enabled = true; Destroy(this); } #endif //if on desktop, use keyboard controls if (Input.GetKeyDown("escape")) { print("ESCAPE"); SceneManager.LoadScene("TitleScreen"); } if (Input.GetKeyDown("1")) //"Tutorial level", just for explaining gameplay { SceneManager.LoadScene("SCTutorial"); } else if (Input.GetKeyDown("2")) //Beginning mode { script.SetGameMode(SwordCombat.GameMode.normal); script.enabled = true; Destroy(this); } else if (Input.GetKeyDown("3")) //Intermediate { script.SetGameMode(SwordCombat.GameMode.hard); script.enabled = true; Destroy(this); } }
// Update is called once per frame void Update() { //If running on Unity Android, run this block to use mobile input controls #if UNITY_ANDROID MobileInput.InputType input = MobileInput.getInput(); if (input == MobileInput.InputType.hold) { SceneManager.LoadScene("TitleScreen", LoadSceneMode.Single); } else if (input == MobileInput.InputType.down) { SceneManager.LoadScene("MinigameScreen", LoadSceneMode.Single); } #endif //Run desktop keyboard/mouse controls if (Input.GetKeyDown("down")) { SceneManager.LoadScene("MinigameScreen", LoadSceneMode.Single); } }
// Update is called once per frame void Update() { #if UNITY_ANDROID if (MobileInput.getInput() == MobileInput.InputType.tap && !triggered) { triggered = true; activated = true; StartCoroutine(show_sequence()); } else if (valid_input) { if (MobileInput.getInput() == MobileInput.InputType.tap) { compare_user_input(Action.tap); } else if (MobileInput.getInput() == MobileInput.InputType.up) { compare_user_input(Action.swipe_up); } else if (MobileInput.getInput() == MobileInput.InputType.down) { compare_user_input(Action.swipe_down); } else if (MobileInput.getInput() == MobileInput.InputType.left) { compare_user_input(Action.swipe_left); } else if (MobileInput.getInput() == MobileInput.InputType.right) { compare_user_input(Action.swipe_right); } } #endif //start prompt if (Input.GetKeyDown("return") && !triggered) { music.GetComponent <AudioSource>().enabled = true; triggered = true; activated = true; StartCoroutine(show_sequence()); } //take user input else if (valid_input) { if (Input.GetKeyDown("space")) { compare_user_input(Action.tap); } else if (Input.GetKeyDown("up")) { compare_user_input(Action.swipe_up); } else if (Input.GetKeyDown("down")) { compare_user_input(Action.swipe_down); } else if (Input.GetKeyDown("left")) { compare_user_input(Action.swipe_left); } else if (Input.GetKeyDown("right")) { compare_user_input(Action.swipe_right); } } //keep running prompt if (activated && !looping) { StartCoroutine(show_sequence()); } }
void HandlePlayerInput() { #if UNITY_ANDROID MobileInput.InputType input = MobileInput.getInput(); if (input == MobileInput.InputType.up) { enable_arrow(Direction.Up); user_guess.Add(Direction.Up); direction_noise.PlayOneShot(simple_direction[0]); StartCoroutine(inputController()); } else if (input == MobileInput.InputType.down) { enable_arrow(Direction.Down); user_guess.Add(Direction.Down); direction_noise.PlayOneShot(simple_direction[1]); StartCoroutine(inputController()); } else if (input == MobileInput.InputType.left) { enable_arrow(Direction.Left); user_guess.Add(Direction.Left); direction_noise.PlayOneShot(simple_direction[2]); StartCoroutine(inputController()); } else if (input == MobileInput.InputType.right) { enable_arrow(Direction.Right); user_guess.Add(Direction.Right); direction_noise.PlayOneShot(simple_direction[3]); StartCoroutine(inputController()); } else if (input == MobileInput.InputType.tap) { } #endif if (Input.GetKeyDown("up")) { enable_arrow(Direction.Up); user_guess.Add(Direction.Up); direction_noise.PlayOneShot(simple_direction[0]); StartCoroutine(inputController()); } else if (Input.GetKeyDown("down")) { enable_arrow(Direction.Down); user_guess.Add(Direction.Down); direction_noise.PlayOneShot(simple_direction[1]); StartCoroutine(inputController()); } else if (Input.GetKeyDown("left")) { enable_arrow(Direction.Left); user_guess.Add(Direction.Left); direction_noise.PlayOneShot(simple_direction[2]); StartCoroutine(inputController()); } else if (Input.GetKeyDown("right")) { enable_arrow(Direction.Right); user_guess.Add(Direction.Right); direction_noise.PlayOneShot(simple_direction[3]); StartCoroutine(inputController()); } else if (Input.GetKeyDown("enter")) { } HandlePlayerGuess(); }
// Update is called once per frame void Update() { #if UNITY_ANDROID if (MobileInput.getInput() == MobileInput.InputType.hold) { SceneManager.LoadScene("TitleScreen"); } if (allowturning && MobileInput.getInput() == MobileInput.InputType.left) { allowturning = false; StartCoroutine(rotatePlayer(transform.rotation, transform.rotation * Quaternion.Euler(0, 90, 0), 0.25f)); StartCoroutine(SwitchWeaponTutorial()); } if (allowWeaponSwitch && MobileInput.getInput() == MobileInput.InputType.down) { weapon++; allowWeaponSwitch = false; if (weapon == 1) { playerAudioSource.PlayOneShot(weaponEquipSound[(int)PlayerWeapons.magic_staff]); StartCoroutine(AttackTutorial()); } if (weapon == 2) { playerAudioSource.PlayOneShot(weaponEquipSound[(int)PlayerWeapons.sword]); allowAttack = true; } if (weapon == 3) { playerAudioSource.PlayOneShot(weaponEquipSound[(int)PlayerWeapons.hammer]); allowAttack = true; } } if (allowAttack && MobileInput.getInput() == MobileInput.InputType.up) { allowAttack = false; if (weapon == 1) { currentEnemy.kill(); playerAudioSource.PlayOneShot(enemyDeaths[(int)EnemyType.ghost]); StartCoroutine(EnemyMoveTutorial()); } if (weapon == 2) { currentEnemy.kill(); playerAudioSource.PlayOneShot(enemyDeaths[(int)EnemyType.wolf]); StartCoroutine(BugTutorial()); } if (weapon == 3) { currentEnemy.kill(); playerAudioSource.PlayOneShot(enemyDeaths[(int)EnemyType.insect]); StartCoroutine(FinishedTutorial()); } } #endif if (allowturning && Input.GetKeyDown("left")) { allowturning = false; StartCoroutine(rotatePlayer(transform.rotation, transform.rotation * Quaternion.Euler(0, 90, 0), 0.25f)); StartCoroutine(SwitchWeaponTutorial()); } if (allowWeaponSwitch && Input.GetKeyDown("down")) { weapon++; allowWeaponSwitch = false; if (weapon == 1) { playerAudioSource.PlayOneShot(weaponEquipSound[(int)PlayerWeapons.magic_staff]); StartCoroutine(AttackTutorial()); } if (weapon == 2) { playerAudioSource.PlayOneShot(weaponEquipSound[(int)PlayerWeapons.sword]); allowAttack = true; } if (weapon == 3) { playerAudioSource.PlayOneShot(weaponEquipSound[(int)PlayerWeapons.hammer]); allowAttack = true; } } if (allowAttack && Input.GetKeyDown("up")) { allowAttack = false; if (weapon == 1) { currentEnemy.kill(); playerAudioSource.PlayOneShot(enemyDeaths[(int)EnemyType.ghost]); StartCoroutine(EnemyMoveTutorial()); } if (weapon == 2) { currentEnemy.kill(); playerAudioSource.PlayOneShot(enemyDeaths[(int)EnemyType.wolf]); StartCoroutine(BugTutorial()); } if (weapon == 3) { currentEnemy.kill(); playerAudioSource.PlayOneShot(enemyDeaths[(int)EnemyType.insect]); StartCoroutine(FinishedTutorial()); } } }
void HandlePlayerInput() { #if UNITY_ANDROID if (MobileInput.getInput() == MobileInput.InputType.up) { enable_arrow(Direction.Up); user_guess.Add(Direction.Up); direction_noise.PlayOneShot(simple_direction[0]); StartCoroutine(inputController()); } else if (MobileInput.getInput() == MobileInput.InputType.down) { enable_arrow(Direction.Down); user_guess.Add(Direction.Down); direction_noise.PlayOneShot(simple_direction[1]); StartCoroutine(inputController()); } else if (MobileInput.getInput() == MobileInput.InputType.right) { enable_arrow(Direction.Right); user_guess.Add(Direction.Right); direction_noise.PlayOneShot(simple_direction[2]); StartCoroutine(inputController()); } else if (MobileInput.getInput() == MobileInput.InputType.left) { enable_arrow(Direction.Left); user_guess.Add(Direction.Left); direction_noise.PlayOneShot(simple_direction[3]); StartCoroutine(inputController()); } #endif if (Input.GetKeyDown("up")) { enable_arrow(Direction.Up); user_guess.Add(Direction.Up); direction_noise.PlayOneShot(simple_direction[0]); StartCoroutine(inputController()); } else if (Input.GetKeyDown("down")) { enable_arrow(Direction.Down); user_guess.Add(Direction.Down); direction_noise.PlayOneShot(simple_direction[1]); StartCoroutine(inputController()); } else if (Input.GetKeyDown("left")) { enable_arrow(Direction.Left); user_guess.Add(Direction.Left); direction_noise.PlayOneShot(simple_direction[2]); StartCoroutine(inputController()); } else if (Input.GetKeyDown("right")) { enable_arrow(Direction.Right); user_guess.Add(Direction.Right); direction_noise.PlayOneShot(simple_direction[3]); StartCoroutine(inputController()); } if (user_guess.Count == sequence.Count) { isUsersTurn = false; } if (user_guess.Count == sequence.Count) { HandlePlayerGuess(); } }
// Update is called once per frame void Update() { #if UNITY_ANDROID MobileInput.InputType input = MobileInput.getInput(); //mobile version starts automatically without needing to tap to start if (!triggered) { triggered = true; activated = true; music.GetComponent <AudioSource>().enabled = true; music.GetComponent <AudioSource>().Play(); StartCoroutine(show_sequence()); } else if (valid_input) { if (input == MobileInput.InputType.hold) { SceneManager.LoadScene("TitleScreen"); } else if (input == MobileInput.InputType.tap) { compare_user_input(Action.tap); } else if (input == MobileInput.InputType.up) { compare_user_input(Action.swipe_up); } else if (input == MobileInput.InputType.down) { compare_user_input(Action.swipe_down); } else if (input == MobileInput.InputType.left) { compare_user_input(Action.swipe_left); } else if (input == MobileInput.InputType.right) { compare_user_input(Action.swipe_right); } } #endif //start prompt if (!triggered) { music.GetComponent <AudioSource>().enabled = true; music.GetComponent <AudioSource>().Play(); triggered = true; activated = true; StartCoroutine(show_sequence()); } //take user input else if (valid_input) { if (Input.GetKeyDown("space")) { compare_user_input(Action.tap); } else if (Input.GetKeyDown("up")) { compare_user_input(Action.swipe_up); } else if (Input.GetKeyDown("down")) { compare_user_input(Action.swipe_down); } else if (Input.GetKeyDown("left")) { compare_user_input(Action.swipe_left); } else if (Input.GetKeyDown("right")) { compare_user_input(Action.swipe_right); } } //keep running prompt if (activated && !looping) { StartCoroutine(show_sequence()); } UpdateScore(); }
// Update is called once per frame void Update() { //if on android, tap will go to arcade game screen #if UNITY_ANDROID if (MobileInput.getInput() == MobileInput.InputType.right) { rhythm = false; memory = false; sword = true; } if (MobileInput.getInput() == MobileInput.InputType.left) { rhythm = true; memory = false; sword = false; } if (MobileInput.getInput() == MobileInput.InputType.up) { rhythm = false; memory = false; sword = true; } if (MobileInput.getInput() == MobileInput.InputType.tap) { if (rhythm == true) { SceneManager.LoadScene("RhythmMagic"); } if (sword == true) { SceneManager.LoadScene("SwordCombat"); } if (memory == true) { SceneManager.LoadScene("MemoryGame"); } } #endif //if on desktop, press up left or right then enter if (Input.GetKeyDown("right")) { Debug.Log("Right Swipe"); rhythm = false; memory = false; sword = true; } if (Input.GetKeyDown("left")) { Debug.Log("Left Swipe"); rhythm = false; memory = true; sword = false; } if (Input.GetKeyDown("up")) { Debug.Log("Up Swipe"); rhythm = true; memory = false; sword = false; } if (Input.GetKeyDown("down")) { Debug.Log("Down Swipe"); //Optional Design: swiping down clears selection //rhythm = false; //memory = false; //sword = false; } //Confirm game selection if (Input.GetKeyDown("return")) { Debug.Log("Tap"); if (rhythm == true) { SceneManager.LoadScene("RhythmMagic"); } if (sword == true) { SceneManager.LoadScene("SwordCombat"); } if (memory == true) { SceneManager.LoadScene("MemoryGame"); } } }