Example #1
0
    // Use this for initialization
    void Start () {
        manager = FindObjectOfType<LaserLevelManager>();
        wasHit = false;
        offSprite = transform.GetChild(0).gameObject;
        onSprite = transform.GetChild(1).gameObject;

        offSprite.SetActive(true);
        onSprite.SetActive(false);
    }
    public void OnEnemyDeath()
    {
        CurrentNumOfEnemies--;

        /*
         * if (CurrentNumOfEnemies < 5)
         * {
         *   // You killed everyone, change scene:
         *   LaserLevelManager.LoadLevel("NextLevelMenu");
         * }
         */
        KilledEnemies++;

        if (Time.timer > 0 && KilledEnemies >= EnemiesToNextLevel)
        {
            LaserLevelManager.LoadLevel("NextLevelMenu");
        }
    }
 void Update()
 {
     if (timer >= 0.0f && CanCount)
     {
         timer         -= Time.deltaTime;      //The timer will count down in delta time based on the seconds we have
         TimerText.text = timer.ToString("F"); //Converting Timer into a string value
     }
     //This means that when the timer reaches zero and OnlyOnce is equal to false
     else if (timer <= 0.0f && !OnlyOnce) //If the timer goes below 0 and OnlyOnce is not equal to flase
     {
         CanCount       = false;          //CanCount is equal to false so we are not counting down anymore since it's not greater than zero and we can't count anymore
         OnlyOnce       = true;           //This is goning to be done once when it reaches it
         TimerText.text = "0.00";         //Setting the UI to 0
         timer          = 0.0f;           //Setting the timer to 0
         if (Time.timer == 0.0f && EnemySpawner.Instance.KilledEnemies != EnemySpawner.Instance.EnemiesToNextLevel)
         {
             LaserLevelManager.LoadLevel("Lose");
         }
     }
 }