Beispiel #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());
    }
Beispiel #2
0
 public void RestartGame()
 {
     //restart from level 1
     LifeTracker.setLives(3);
     PlayerPrefs.SetInt("score", 0);
     ScoreTracker.setScore(0);
     SceneManager.LoadScene("Level 1");
 }
Beispiel #3
0
 private void endBossLevel()
 {
     TimeTracker.stopTime();
     TimeTracker.saveFinalTime();
     PlayerPrefs.SetInt("score", ScoreTracker.getScore());
     PlayerPrefs.SetInt("lives", LifeTracker.getLives());
     PlayerPrefs.SetString("NextLevel", "End");
     SceneManager.LoadScene("LevelComplete");
 }
Beispiel #4
0
    public void PlayerDies()
    {
        lifeTracker = GameObject.FindObjectOfType <LifeTracker>();
        lifeTracker.LoseLife();
        var exploder = GameObject.FindObjectOfType <Exploder>();

        exploder.Explode(transform.position);
        Destroy(gameObject);
    }
Beispiel #5
0
 void Awake()
 {
     lifeTracker     = GameObject.FindGameObjectWithTag(Tags.guiController).GetComponent <LifeTracker>();
     respawnPosition = GameObject.FindGameObjectWithTag(Tags.player).transform.position;
     respawnRotation = GameObject.FindGameObjectWithTag(Tags.player).transform.rotation;
     hash            = GameObject.FindGameObjectWithTag(Tags.dataController).GetComponent <HashIDs>();
     gameOver        = GameObject.FindGameObjectWithTag(Tags.guiController).GetComponent <GameOverGUI>();
     spawner         = GameObject.FindGameObjectWithTag(Tags.dataController).GetComponent <AsteroidSpawner>();
 }
Beispiel #6
0
 private void Start()
 {
     if (_lifeTracker == null)
     {
         _lifeTracker = FindObjectOfType <LifeTracker>();
     }
     Operator.lifeTracker = _lifeTracker;
     Operator.Start();
 }
Beispiel #7
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.GetComponent <Player> () == null)
     {
         return;
     }
     TimeTracker.stopTime();
     TimeTracker.saveFinalTime();
     PlayerPrefs.SetInt("score", ScoreTracker.getScore());
     PlayerPrefs.SetInt("lives", LifeTracker.getLives());
     PlayerPrefs.SetInt("Level2Unlocked", 1);
     PlayerPrefs.SetString("NextLevel", "Level 2");
     SceneManager.LoadScene("LevelComplete");
 }
Beispiel #8
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.name == "Player")
        {
            LifeTracker.addLife();
            PlayerPrefs.SetInt("lives", LifeTracker.getLives());

            gameObject.GetComponent <AudioSource> ().Play();
            gameObject.GetComponent <ParticleSystem> ().Pause();
            gameObject.GetComponent <ParticleSystem> ().Clear();
            gameObject.GetComponent <PolygonCollider2D>().enabled = false;
            gameObject.GetComponent <SpriteRenderer> ().enabled   = false;

            Destroy(gameObject, 5);
        }
    }
Beispiel #10
0
 void LateUpdate()
 {
     //Change scene to "end" if final boss is killed
     if (scene.name == "Boss Fight" && !endingBossLevel)
     {
         if (boss.GetComponent <Boss> ().GetIsDead())
         {
             endingBossLevel = true;
             Invoke("endBossLevel", 3);
         }
     }
     //stop time if game is over
     if (player.GetIsDead() && LifeTracker.getLives() - 1 <= 0)
     {
         TimeTracker.stopTime();
     }
 }
Beispiel #11
0
    private IEnumerator DieAndRespawn()
    {
        yield return(new WaitForSeconds(4));

        isPoweredUp = false;
        LifeTracker.takeLife();

        if (LifeTracker.getLives() > 0)
        {
            if (!facingRight)
            {
                ChangeDirection(-1, 1);
            }
            GetComponent <BoxCollider2D>().enabled = true;

            levelManager.RespawnPlayer();
            myAnimator.Rebind();
            health = 100;
        }
    }
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        DontDestroyOnLoad(gameObject);

        lifeStatus = new List <Tuple <GameObject, bool> >();

        for (int i = 0; i < numberOfLives; i++)
        {
            GameObject temp = lives.transform.GetChild(i).gameObject;
            lifeStatus.Add(new Tuple <GameObject, bool>(temp, false));
        }
    }
Beispiel #13
0
 public void FinalBoss()
 {
     LifeTracker.setLives(3);
     PlayerPrefs.SetInt("score", 0);
     SceneManager.LoadScene(bossLevel);
 }
 private void Start()
 {
     lifeTracker = GameObject.Find("GM").GetComponent <LifeTracker>();
 }
        // ******************************************************************
        /// <summary>
        /// Return a new LifeTracker to be used in a 'using' block in order to ensure reliability
        /// </summary>
        /// <returns></returns>
        public LifeTracker GetNewLifeTracker()
        {
            LifeTracker lifeTracker = new LifeTracker(AddRef, RemoveRef);

            return(lifeTracker);
        }
Beispiel #16
0
 public void NewGame()
 {
     LifeTracker.setLives(3);
     PlayerPrefs.SetInt("score", 0);
     SceneManager.LoadScene(startLevel);
 }
Beispiel #17
0
 public void Level2()
 {
     LifeTracker.setLives(3);
     PlayerPrefs.SetInt("score", 0);
     SceneManager.LoadScene(level2);
 }