Exemple #1
0
    void Update()
    {
        //Player directional input
        horzMovement = Input.GetAxis("Horizontal");
        vertMovement = Input.GetAxis("Vertical");

        //Press spacebar to jump if the player can jump
        if (stopJumping == false)
        {
            if (Time.timeScale == 1)
            {
                if (IsGrounded() && (Input.GetKeyDown(KeyCode.Space)))
                {
                    //Player has normal jumping when the player is not on a sticky horizontal floor
                    if (alterMovement == false)
                    {
                        playerRB.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
                        inky.SetBool("jump", true); //Play jump anim
                    }

                    //playerRB.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);

                    else if (alterMovement == true)
                    {
                        playerRB.AddForce(Vector3.down * jumpForce, ForceMode.Impulse);
                        //inky.SetBool("jump", true); //Play jump anim
                    }

                    //Debug.Log(Vector3.up * jumpForce);
                }

                // else if (Input.GetKeyUp(KeyCode.Space))
                // {
                //     inky.SetBool("jump", false); //Play land anim
                // }
            }
        }

        //Press shift to change colors, the projectile type, and update color UIs
        if (stopJumping == false)
        {
            if (Time.timeScale == 1)
            {
                if (Input.GetKeyDown(KeyCode.LeftShift))
                {
                    currentColorMode = playerShoot.CheckNextAvailableColor(currentColorMode);
                    ChangeMaterial(currentColorMode);
                    playerShoot.ChangeProjType(currentColorMode);

                    //colorNextUI = playerShoot.CheckNextAvailableColor(colorNextUI);
                    UpdateCurColorUI(currentColorMode);
                    ChangeNewColorUI(currentColorMode);
                    ChangePreviousColorUI(currentColorMode);
                }
            }
        }

        //Play shooting animation
        if (stopJumping == false)
        {
            if (Time.timeScale == 1)
            {
                if (Input.GetKeyDown(KeyCode.Mouse0))
                {
                    inky.SetBool("shoot", true);
                }

                else if (Input.GetKeyUp(KeyCode.Mouse0))
                {
                    inky.SetBool("shoot", false);
                }
            }
        }

        //Make sure there is the amount of collected bristles
        curBristles.text = "Bristles: " + bristles.ToString() + "/" + totalBristles.ToString();

        //Update the color UI icon when the player's color changes AND eventually when the player chooses which color to shoot with
        //curColor.color = currentColor.color;
        //UpdateCurColorUI(currentColorMode);

        //Get superbrush after collecting all bristles in the level
        // if (bristles == totalBristles)
        // {
        //     if (sbLimit == 1)
        //     {
        //         //For programmers
        //         if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("Prototype"))
        //         {
        //             Instantiate(superbrush, transform.position + (transform.up * 0.5f + -transform.right * 2.5f), transform.rotation);
        //         }

        //         //For final version/level designers
        //         else if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("ChromaticVertSlice"))
        //         {
        //             Instantiate(superbrush, transform.position + (transform.up * 0.5f + -transform.right * 4f), transform.rotation);
        //         }

        //         sbLimit = 0;
        //     }
        // }

        if (stopJumping == false)
        {
            if (Time.timeScale == 1)
            {
                if (alterMovement == false)
                {
                    //Play walk sound effect and anim
                    if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
                    {
                        inkySound.clip = inkySFX[0];
                        inkySound.Play();

                        inky.SetBool("isMoving", true);

                        //Change to left orientation
                        if (onRamp == false)
                        {
                            transform.eulerAngles = new Vector3(0f, 220f, 0f);
                        }

                        //Change z-axis when player is on ramp
                        else if (onRamp == true)
                        {
                            transform.eulerAngles = new Vector3(0f, 180f, 0f);
                        }

                        //inky.SetFloat("Move", -horzMovement);
                    }

                    else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
                    {
                        inkySound.clip = inkySFX[0];
                        inkySound.Play();

                        inky.SetBool("isMoving", true);

                        //Change to right orientation
                        if (onRamp == false)
                        {
                            transform.eulerAngles = new Vector3(0f, 160f, 0f);
                        }

                        //Change z-axis when player is on ramp
                        else if (onRamp == true)
                        {
                            transform.eulerAngles = new Vector3(0f, 180f, 0f);
                        }

                        //inky.SetFloat("Move", horzMovement);
                    }

                    //Stop walk sound effect and anim
                    else if (Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.D) || Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow))
                    {
                        inkySound.Stop();

                        //Play idle anim
                        inky.SetBool("isMoving", false);
                    }
                }

                else if (alterMovement == true)
                {
                    //Play walk sound effect and climb wall anim
                    if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
                    {
                        inkySound.clip = inkySFX[0];
                        inkySound.Play();

                        //inky.SetBool("climb", true);

                        //Change to left orientation
                        // if (onRamp == false)
                        // {
                        //     transform.eulerAngles = new Vector3(0f, 220f, 0f);
                        // }
                    }

                    else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
                    {
                        inkySound.clip = inkySFX[0];
                        inkySound.Play();

                        //inky.SetBool("climb", true);

                        //Change to right orientation
                        // if (onRamp == false)
                        // {
                        //     transform.eulerAngles = new Vector3(0f, 160f, 0f);
                        // }
                    }

                    //Stop walk sound effect and anim
                    else if (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.DownArrow))
                    {
                        inkySound.Stop();

                        //Play idle anim
                        //inky.SetBool("climb", false);
                    }
                }
            }
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }
    }