Ejemplo n.º 1
0
//Used to kill the player and program the after effects.
    public void Kill()
    {
        //Takes away a life..
        livesObject.LoseLife();
        //Saves the change when the life is taken away.
        livesObject.SaveLives();

        //Checks if it's game over.

        bool gameOver = livesObject.isGameOver();


        //If it is game over the game over screen is loaded.

//Checks if the game is in game over state
        if (gameOver == true)
        {
            //Resets the player's lives
            livesObject.ResetLives();
            //Loads the game over scene.
            SceneManager.LoadScene("GameOver");
        }
        else
        {
//If it is not game over, the current level is reset
            Scene currentLevel = SceneManager.GetActiveScene();
//Checks Unity to find the current level
            SceneManager.LoadScene(currentLevel.buildIndex);
        }
    }
Ejemplo n.º 2
0
    // Our own function for handling player death
    public void Kill()
    {
        // Take away a life and save that change.
        livesObject.LoseLife();
        livesObject.SaveLives();

        // Check if the game is over.
        bool gameOver = livesObject.isGameOver();


        if (gameOver == true)
        {
            //If the game is over...
            // Load the the Game over scene.
            SceneManager.LoadScene("GameOverScreen");
        }
        else
        {
            // If the game is not over...
            // Reset the current leel to restart

            // Reset the current level to reset from the beggining.

            // First, ask unity what the current level is
            Scene currentLevel = SceneManager.GetActiveScene();

            // Second, tell unity to load the current level again by passing the build index of our level
            SceneManager.LoadScene(currentLevel.buildIndex);
        }
    }
Ejemplo n.º 3
0
    // Our own function for handling player death
    public void Kill()
    {
        //take away a life and save that change
        livesObject.LoseLife();
        livesObject.SaveLives();

        // check if it's game over
        bool gameOver = livesObject.IsGameOver();

        if (gameOver == true)
        {
            // if it IS game over...
            //Load the game over scene
            SceneManager.LoadScene("GameOver");
        }

        else
        {
            // if it is NOT game over...
            // reset the current level to restart from screen


            // Reset the current level to restart from the beginning.

            // First, ask unity what the current level is
            Scene currentLevel = SceneManager.GetActiveScene();

            // Second, tell unity to load the current again
            // by passing the build index of our level
            SceneManager.LoadScene(currentLevel.buildIndex);
        }
    }
Ejemplo n.º 4
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        // Detects if the object/assets that was collided with holds the "Enemy" script
        if (collision.collider.GetComponent <Enemy>())
        {
            //Take away a life and save that change
            livesObject.LoseLife();
            livesObject.saveLives();

            //Plays the death sound
            Death.Play();

            //Checks if its game over
            bool gameOver = livesObject.IsGameOver();

            if (gameOver == true)
            {
                //If it IS game over, load the game over scene
                SceneManager.LoadScene("Game_Over");
            }

            else
            {
                //Detects what the current score of the player is
                Score.scoreValue = PlayerPrefs.GetInt("score", 0);

                //Detects what level the player is on and saves it
                Scene currentLevel = SceneManager.GetActiveScene();

                //Relods the saved level, from the start point of that level
                //using the build index
                SceneManager.LoadScene(currentLevel.buildIndex);
            }
        }
    }
Ejemplo n.º 5
0
    public void Kill()
    {
        // Take away a life and save that change
        LivesObject.LoseLife();
        LivesObject.SaveLives();

        //Check if it's game over
        bool gameOver = LivesObject.IsGameOver();

        if (gameOver == true)
        {
            // If it IS game over...
            // Load the game over screen
            SceneManager.LoadScene("GameOver");
        }
        else
        {
            // If it is NOT game over...
            // Reset the current level to restart from the beginning


            //Reset the current level to restart from the beginning

            //First ask unity what the current level is
            Scene currentLevel = SceneManager.GetActiveScene();
            //Second, tell unity to load the current level again
            //by passing the build index of our level
            SceneManager.LoadScene(currentLevel.buildIndex);

            // Death sound play when player is killed
            Death.Play();
        }
    }
Ejemplo n.º 6
0
    //our own function for handling player death
    public void Kill()
    {
        //Take away a life and save that change
        livesObject.LoseLife();
        livesObject.SaveLives();

        //check if game over
        bool gameOver = livesObject.IsGameOver();

        if (gameOver == true)
        {
            //if is game over load game over scene
            SceneManager.LoadScene("GameOver");
        }
        else
        {
            //if not game over reset current level from start

            //reset the current level to restart from beginning

            //forst ask unity what the current level is
            Scene currentLevel = SceneManager.GetActiveScene();

            //second tell Unity to load current level again
            //by passing the build index of our level
            SceneManager.LoadScene(currentLevel.buildIndex);
        }
    }
Ejemplo n.º 7
0
 void OnTriggerEnter2D(Collider2D c2d)
 {
     if (c2d.CompareTag("Player"))
     {
         lifecount.LoseLife();
         Debug.Log("Life lost");
         transform.position = new Vector2(Random.Range(minX, maxX), Random.Range(minY, maxY));
     }
 }
Ejemplo n.º 8
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (vulnerable && other != null && other.CompareTag("Enemy"))
     {
         vulnerable = false;
         Lives.LoseLife(invincibilityTime * 0.33f);
         StartCoroutine(Invincible());
     }
 }
Ejemplo n.º 9
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        // Check the thing we bump into is an enemy
        if (collision.collider.GetComponent <Enemy>())
        {
            //Take away a life and save that change
            livesObject.LoseLife();
            livesObject.saveLives();



            //Check if its game over

            bool gameOver = livesObject.IsGameOver();

            if (gameOver == true)
            {
                //If it IS game over...
                //Load the game over scene

                SceneManager.LoadScene("Game_Over");
            }

            else
            {
                //try and fix this you need to try and get the game to take away a life but not reset
                //but still check to see if the gme is over and the get the game to reset


                //If it is NOT game over...
                //reset the current level to restart from the begining

                // Reset the current level to restart from the begining.

                //First, ask untiy what the current level is

                Score.scoreValue = PlayerPrefs.GetInt("score", 0);


                Scene currentLevel = SceneManager.GetActiveScene();

                //Second, tell unity to load the current again
                // by passing the build index of our level


                SceneManager.LoadScene(currentLevel.buildIndex);
            }
        }
    }
Ejemplo n.º 10
0
    public void Kill()
    {
        livesObject.LoseLife();
        livesObject.SaveLives();

        //check to see if any lives left
        bool gameOver = livesObject.IsGameOver();

        if (gameOver == true)
        {
            //loads Game Over is no lives left
            SceneManager.LoadScene("GameOver");
        }

        else
        {
            //gets and reloads current level
            Scene currentLevel = SceneManager.GetActiveScene();

            SceneManager.LoadScene(currentLevel.buildIndex);
        }
    }
Ejemplo n.º 11
0
    //Our own fuction for handling player death
    public void Kill()
    {
        lives.LoseLife();

        lives.SaveLives();

        if (lives.IsGameOver())
        {
            // Go to game over screen
            SceneManager.LoadScene("GameOver");
        }
        else
        {
            //Reset the current level to restart from the beginning.

            //First, ask unity what the current level is
            Scene currentLevel = SceneManager.GetActiveScene();

            //Second, tell unity to load the current level again.
            //By passing the build index of our level
            SceneManager.LoadScene(currentLevel.buildIndex);
        }
    }
Ejemplo n.º 12
0
 override public void OnMissedThreshold()
 {
     lives.LoseLife();
 }