GameOver() private method

private GameOver ( ) : void
return void
Esempio n. 1
0
    public static void DecreaseLife()
    {
        Lives--;
        Lives = Mathf.Clamp(Lives, 0f, Mathf.Infinity);

        if (Lives <= 0)
        {
            GameManager.GameOver();
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        //Detecting button can not write in FixedUpdated() method,
        //because detection is once per frame and FixedUpdate may be triggered multiple times per frame.
        //Dash Function, Triggered once when the button is pressed
        if (Input.GetKeyDown(KeyCode.DownArrow) && canJump && dashSwitch == true && GameManager2.GameStart)
        {
            //triger Dash of three frames animation
            animator.SetBool("dash", true);
            //Make the hero move a distance down the Y axis
            GetComponent <BoxCollider2D>().size   = new Vector2(bodySize.x, bodySize.y * 0.5f);
            GetComponent <BoxCollider2D>().offset = new Vector2(bodyCenter.x, bodyCenter.y - 0.19f);

            dashSwitch = false;
            //Keep dash time at 1 seconds
            Invoke("Dash", 0.5f);
        }

        //jump script could also put in FixedUpdate but the unit time should be modified,
        //or there will be delay on jump
        canJump = onGround();
        if (Input.GetKeyDown(KeyCode.UpArrow) && canJump && GameManager2.GameStart)
        {
            GetComponent <Rigidbody2D>().AddForce(new Vector2(0, jumpForce * 10));
            //jump animation active
            animator.SetBool("jump", true);
        }
        else
        {
            //jump animation deactive
            animator.SetBool("jump", !canJump);
        }

        //death trigger
        if (playerDeath == true || playerWin == true)
        {
            gameManager.GameOver();
        }
    }