Example #1
0
    private void UpdateTimer()
    {
        if (currentState == GameState.INPROGRESS)
        {
            timeRemaining -= Time.deltaTime;

            if (timeRemaining <= 0f)
            {
                spawnSystem.StopSpawning();

                // FindGameObjectWithTag is very spooky when in the Update method so let's avoid it in the future
                // if(GameObject.FindGameObjectWithTag("NPC") == null) EndRound(true);

                if (!spawnSystem.HasNPCs())
                {
                    EndRound(true);
                }
            }

            timeRemaining = Mathf.Clamp(timeRemaining, 0f, Mathf.Infinity);
            dynamicSky.UpdateSky(timeRemaining / roundTimer);
            timerUI.UpdateTimer(timeRemaining);
        }
    }