Exemplo n.º 1
0
 private void Start()
 {
     WinText.SetActive(false);
     SpeedFx.SetActive(false);
     WinCollider.SetActive(false);
     JumpBar.SetActive(false);
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        // Moves the log forward by getting its current position and moving it right at the set speed
        Vector3 pos = S.transform.position;

        pos.x -= Frog.movementSpeed;
        S.transform.position = pos;

        // If log reaches -25, means Austin has cleared the log.  Adds to score, shows the
        // score that was added to, resets the jump bar, and no longer needs an update this round
        if (pos.x <= -25)
        {
            if (needsUpdate)
            {
                JumpyFrog.showScorePlus = true;
                JumpyFrog.UpdateScore();

                JumpBar.ResetBar();

                needsUpdate = false;

                // Adjusts the speed of the game and adds to Austin's hopping height
                if (Frog.movementSpeed < .75F && JumpyFrog.logsJumped % 2 == 0)
                {
                    Frog.movementSpeed += .25F;
                    Frog.hoppingHeight += 1F;
                }
            }

            Frog.maxHeight = Frog.hoppingHeight;
        }

        // After the log is off the screen, resets the log's position to the left, stops showing the
        // score added that round, changes the log's size, and allows the user to press space to adjust
        // the jump bar again.
        if (pos.x <= -50)
        {
            needsUpdate          = true;
            pos.x                = 70;
            S.transform.position = pos;
            ChangeSize();

            JumpyFrog.showScorePlus = false;

            JumpBar.notPressed = true;
        }
    }
 private void BarJump()
 {
     if (!currentBar)
     {
         RaycastHit hit;
         if (Physics.Raycast(Cam.transform.position, Cam.transform.forward, out hit, checkDistance))
         {
             if (hit.collider.GetComponent <JumpBar>() != null)
             {
                 currentBar = hit.collider.GetComponent <JumpBar>();
                 currentBar.StartBarJump(CC);
             }
         }
     }
     else
     {
         currentBar.UpdateBarJump(CC);
     }
 }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        // When user presses space bar, the new height is added to and the jump bar is increased
        // The counter slows down how quickly this happens
        if (Input.GetKey("space") && notPressed && addCounter % 3 == 0)
        {
            JumpBar.ChangeHeight();
            addCounter++;
        }
        else
        {
            addCounter++;
        }

        // When user releases space bar, notPressed = false so they can't press again
        if (Input.GetKeyUp("space"))
        {
            notPressed = false;
        }
    }
Exemplo n.º 5
0
    // UPDATE (Start not used)

    // Update sets a current log position and size for reference, calls to show the current score, tests if the log is close enough
    // that the frog needs to jump, shows the score that is added if need be, sets up for Austin to fall after the log passes,
    // and handles game over and if the user wants to play again
    void Update()
    {
        // Sets log's current size and pos
        Vector3 logPos  = Log.S.transform.position;
        Vector3 logSize = Log.S.transform.localScale;

        // Shows the current score
        ShowGT();

        // Determines when the frog needs to "jump" (Changing height, hovering, falling after log)
        // If the user did not charge the jump bar at all, Austin does not jump
        // Jump and hover
        if (!JumpBar.notPressed)
        {
            if (logPos.x <= 0 && logSize.x >= 3)
            {
                Frog.BigJump(JumpBar.jumpHeight);
                Frog.hover = true;
            }
            else if (logPos.x <= -8)
            {
                Frog.BigJump(JumpBar.jumpHeight);
                Frog.hover = true;
            }
        }

        // Shows the score added
        if (showScorePlus)
        {
            if (!gameOver)
            {
                gtScorePlus.text = "+" + (score - scoreBefore);
            }
        }
        else
        {
            gtScorePlus.text = " ";
        }

        // Fall after log
        if (logPos.x <= -32 && logSize.x != 3)
        {
            Frog.hover = false;
        }
        else if (logPos.x <= -39)
        {
            Frog.hover = false;
        }

        // GAME OVER

        // If the game is over, display this text
        if (gameOver == true)
        {
            gtGO.text    = "Game Over\n\nFinal score: " + score + "\nLogs jumped: " + logsJumped + "\n\nPress the enter\nkey to play again";
            gtScore.text = " ";
        }

        // GAME OVER RESET

        // If user wants to continue, press the enter/return key. Resets several things
        if (gameOver == true && Input.GetKeyDown("return"))
        {
            gameOver  = false;
            gtGO.text = " ";

            logPos.x = 70;
            Log.S.transform.position = logPos;
            Log.ChangeSize();

            Frog.hover         = false;
            Frog.maxHeight     = Frog.origMaxHeight;
            Frog.movementSpeed = Frog.origMovementSpeed;

            score      = 0;
            logsJumped = 0;

            JumpBar.notPressed = true;
            JumpBar.ResetBar();
        }
        else if (Input.GetKeyDown("escape"))
        {
            Application.Quit();
        }
    }