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

public class GameManager : MonoBehaviour
{
    public static GameManager instance;

    public Text scoreText;

    public float worldScrollingSpeed = 0.2f;

    public bool inGame;

    public GameObject resetButton;

    private float score;


    void Start()
    {
        if (instance == null) { instance = this; }

        InitializeGame();
    }

    void InitializeGame()
    {
        inGame = true;
    }

    public void GameOver()
    {
        inGame = false;
        resetButton.SetActive(true);
    }

    void FixedUpdate()
    {
        if (!GameManager.instance.inGame) return;

        score += worldScrollingSpeed;
        UpdateOnScreenScore();
    }
    void UpdateOnScreenScore()
    {
        scoreText.text = score.ToString("0");
    }

    public void RestartGame()
    {
        SceneManager.LoadScene(0);
    }
}