using UnityEngine;
using System.Collections;

public class GameController : MonoBehaviour {

	public static GameController instance;
    private GameObject[] copPoints;

    private bool startGame;
    

	public int day, points, money, drugCount;

	// Use this for initialization
	void Awake () {
		if (instance != null)
		{
			Destroy (gameObject);
			return;
		}

        startGame = false;
		Cursor.visible = false;
		DontDestroyOnLoad (transform.gameObject);
		instance = this;
	
	}

	public void resetLevel()
	{
        //Application.LoadLevel ("test");
        PlayerMovement.instance.reset();
        CreateCops.instance.spawn();
        Dealer.instance.spawn();

	}
	
	// Update is called once per frame
	void Update ()
    {
        if (Application.loadedLevelName == "test")
        {
            Cursor.visible = UpgradeController.instance.gameObject.activeInHierarchy;
        }
        else if (startGame)
        {
            Application.LoadLevel("test");
            startGame = false;
        }
        else if (Input.GetKeyDown(KeyCode.Space))
        {
            if (Application.loadedLevelName == "Title")
                Application.LoadLevel("Help");
            else if (Application.loadedLevelName == "Help")
            {
                GameObject.Find("Loading").GetComponent<TextMesh>().text = "LOADING";
                startGame = true;
            }
            Cursor.visible = false;
        }
        else
            Cursor.visible = false;

    }

    public GameObject[] getCopPoints()
    {
        if (copPoints == null)
            copPoints = GameObject.FindGameObjectsWithTag("Point");
        return copPoints;
    }

    void OnLevelWasLoaded(int level)
    {
        if (Application.loadedLevelName != "test")
            copPoints = null;

    }
}
