Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (IsGameOver)
        {
            WaitForButtonAndGoBackToMenu();
            return; // nothing to do
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            FinishGame(true);
        }

        DestroyDecayedPortals();

        int newDays = Mathf.FloorToInt((Time.time - startTime) / GameConstants.SecondsPerDay);

        if (newDays > days)
        {
            days = newDays;

            Scoreboard.DisplayDays(days);

            if (days >= GameConstants.DaysPerGame)
            {
                FinishGame(false);
            }
            else
            {
                SoundManager.GetInstance().DayUpSound.Play();
            }
        }

        if (PlayerAchievement.IsAPChanged)
        {
            Scoreboard.DisplayLevelAndAP(PlayerAchievement.Level, PlayerAchievement.AP);

            if (PlayerAchievement.IsLevelChanged)
            {
                SoundManager.GetInstance().LevelUpSound.Play();
            }

            PlayerAchievement.ResetAPChanged();
        }
    }