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

public class GameController : MonoBehaviour
{
    public GameObject UI;
    public GameObject FirstPersonCamera;
    public GameObject ThirdPersonCamera;
    public int Score;
    public bool FirstPerson;
    public Text TopScoreFirstPerson;
    public Text TopScoreThirdPerson;

    private void Start()
    {
        Application.targetFrameRate = 60;
        TopScoreFirstPerson.text = "Top Score VR: " + PlayerPrefs.GetString("FirstPersonTopScore");
        TopScoreThirdPerson.text = "Top Socre Top Down: " + PlayerPrefs.GetString("ThirdPersonTopScore");
    }

    public void SoundChanged(bool state)
    {
        Camera.main.GetComponent<AudioListener>().enabled = state;
    }

    public void StartGame()
    {
        Camera.main.GetComponent<CarGenerator>().enabled = true;
        UI.transform.Find("Background").gameObject.SetActive(false);
        UI.transform.Find("Score").gameObject.SetActive(true);
    }

    public void SetCamera(bool firstPerson)
    {
        if (!firstPerson)
        {
            ThirdPersonCamera.SetActive(true);
            FirstPersonCamera.SetActive(false);
            FirstPerson = false;
        }
        else
        {
            ThirdPersonCamera.SetActive(false);
            FirstPersonCamera.SetActive(true);
            FirstPerson = true;
        }
    }
}
