Ejemplo n.º 1
0
    public void RespawnPlayer()
    {
        //reset time
        TimeTracker.resetTimeAtLastCheckpoint();
        TimeTracker.saveTime();
        //respawn all item pickups and enemies
        Destroy(ExpendableObjects_RunningGameState);
        ExpendableObjects_RunningGameState = Instantiate(ExpendableObjects_StartGameState);
        ExpendableObjects_RunningGameState.transform.parent = LevelObjects.transform;
        ExpendableObjects_RunningGameState.SetActive(true);

        //reset new boss, if boss level
        if (scene.name == "Boss Fight")
        {
            boss = GameObject.FindObjectOfType <Boss>().gameObject;
        }


        //reset player score to last checkpoint
        ScoreTracker.setScore(PlayerPrefs.GetInt("lastCheckpointScore"));


        //respawn player at last checkpoint location, update life count
        player.transform.position = currentCheckpoint.transform.position;
        PlayerPrefs.SetInt("lives", LifeTracker.getLives());
    }
Ejemplo n.º 2
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.name == "Player")
     {
         if (gameObject.name != "InvisibleCheckpoint" && !checkpointReached)
         {
             myAnimator.SetBool("SetFlagUp", true);
             clip.Play();
         }
         if (!checkpointReached)
         {
             levelManager.currentCheckpoint = gameObject;
             PlayerPrefs.SetInt("lastCheckpointScore", ScoreTracker.getScore());
             TimeTracker.saveTime();
             checkpointReached = true;
         }
     }
 }