コード例 #1
0
    // 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");
        }
    }
コード例 #2
0
    // 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());
    }
コード例 #3
0
    // 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);
        }
    }
コード例 #4
0
    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;
        }
    }
コード例 #5
0
 //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);
     }
 }
コード例 #6
0
    // 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");
        }
    }
コード例 #7
0
    // 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);
        }
    }
コード例 #8
0
    // 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);
        }
    }
コード例 #9
0
    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();
    }
コード例 #10
0
    // 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();
    }