using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class GameManager_script : MonoBehaviour
{
    public static GameManager_script current;

    public Text txtScore, txtMonth, txtScoreGameOver;
    public GameObject panelGameOver;


    private int score;
    private string[] months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };
    private int i;

    // Start is called before the first frame update
    void Start()
    {
        current = this;
        InvokeRepeating("ChangeMonth", 10f, 10f);
    }

    public void UpdateScore()
    {
        score += 1;
        txtScore.text = score.ToString("00");
        if(score == 99)
        {
            CancelInvoke("ChangeMonth");
            panelGameOver.SetActive(true);
        }

    }

    public void ChangeMonth()
    {
        i += 1;
        if (i < months.Length)
            txtMonth.text = months[i];
        else
        {
            txtMonth.text = months[0];
            CancelInvoke("ChangeMonth");
            txtScoreGameOver.text = txtScore.text;
            panelGameOver.SetActive(true);
        }

    }

    public void RestartGame()
    {
        SceneManager.LoadScene("GameScene");
    }
}
