using UnityEngine;
using System.Collections;

public class GameController : MonoBehaviour {
	public GUISkin skin;
	
	private float currentTime;
	private float roundTime;
	
	private float lookTimer;
	// Use this for initialization
	void Start () {
		Screen.lockCursor = true;
		roundTime=GameOptions.roundTime;
	}
	
	// Update is called once per frame
	void Update () {
		currentTime+=Time.deltaTime;
		if(currentTime>=roundTime)
		{
			Time.timeScale=0.01f;
			if(Input.GetKeyDown(KeyCode.Return))
			{
				Screen.lockCursor = false;
				CombatLog.Clear();
				GameBrain.Clear();
				Application.LoadLevel(0);
			}
				
		}
		
		
	}
	
	void OnGUI()
	{
		GUI.skin = skin;

		float xSizePercent = Screen.width / 1680.0f;
		float ySizePercent = Screen.height / 1050.0f;	
		
		if(currentTime<roundTime)
		{
			string min =Mathf.Floor((roundTime-currentTime)/60).ToString();
			string sec = ((int)((roundTime-currentTime)%60)).ToString();
			if(((int)((roundTime-currentTime)%60))<10)
				sec="0"+sec;
			string time = min+":"+sec;
			Vector2 size = GUI.skin.label.CalcSize(new GUIContent(time));
			GUI.Label(new Rect(Screen.width/2 - size.x,5*ySizePercent,400*xSizePercent,50*ySizePercent),time);
		}
		
		if(currentTime>=roundTime)
		{
			CombatLog.DrawTable();
			
			string text = "Press ENTER button";
			Vector2 size = GUI.skin.label.CalcSize(new GUIContent(text));
			GUI.Label(new Rect(Screen.width/2 - size.x/2,50*ySizePercent,800*xSizePercent,200*ySizePercent),text);
		}
		
	}
}
