using UnityEngine;
using System.Collections;

public class Globals : MonoBehaviour
{
		public static bool IsGamePaused = true;

		public static int coinPoints = 0;
		public static int Lifes = 5;
		public static int forwPoints = 0;
		public static int Level = 0;
		public GUITexture coinTexture;
		public GUIText coinText;
		public GUITexture pointTexture;
		public GUIText pointText;
		public GUITexture lifesTexture;
		public GUIText lifesText;
		private int kacCoindeBir = 5;
		public static int set = 0;
		public static int pathWidth = 1;
		public static bool dying = false;

		public void Start ()
		{
				if (Globals.set == 0) {
						Messenger<Vector2>.AddListener ("cube movement", new Callback<Vector2> (delegate(Vector2 where) {
								if (Test.world [(int)where.x, (int)where.y] == 1 && (rotate.last == 0 || rotate.last == 2)) {
										forwPoints += Level;
								}
								if (coinPoints % kacCoindeBir == 0 && coinPoints != 0) {
										Lifes++;
										coinPoints++;
								}

								Globals.set = 1;
						}));

				}
		}

		void OnGUI ()
		{
		Rect coinInset = new Rect(-Screen.width / 2 + 20, -Screen.width/20, Screen.width/20, Screen.width/20);
		coinTexture.pixelInset = coinInset;
		
		Vector2 coinTextOffset = new Vector2(-Screen.width / 2 + Screen.width/20 + 40, Screen.height / 2 - Screen.width/20+Screen.width/60+Screen.width/100);
		coinText.pixelOffset = coinTextOffset;
		coinText.text = coinPoints.ToString();
		coinText.fontSize=Screen.width/30;
		
		Rect pointInset = new Rect(-Screen.width / 2 +20, -Screen.width/10-10, Screen.width/20, Screen.width/20);
		pointTexture.pixelInset = pointInset;
		
		Vector2 pointTextOffset = new Vector2(-Screen.width / 2 + Screen.width/20+40, Screen.height / 2 -Screen.width/10+Screen.width/60+Screen.width/100-10);
		pointText.pixelOffset = pointTextOffset;
		pointText.text = (forwPoints + coinPoints * 5).ToString();
		pointText.fontSize=Screen.width/30;
		
		Rect lifesInset = new Rect(-Screen.width / 2 + 20, -3*Screen.width/20-20, Screen.width/20, Screen.width/20);
		lifesTexture.pixelInset = lifesInset;
		
		Vector2 lifesTextOffset = new Vector2(-Screen.width / 2 + Screen.width/20+40, Screen.height / 2 -3*Screen.width/20+ Screen.width/60+Screen.width/100-20);
		lifesText.pixelOffset = lifesTextOffset;
		lifesText.text = Lifes.ToString();
		lifesText.fontSize=Screen.width/30;
		}
}
