using UnityEngine;
using System.Collections.Generic;

public class Store : MonoBehaviour
{
		public List<Powerup> powerups = new List<Powerup> ();
		// Use this for initialization
		public Texture2D doubleway, pupchance;
		void Start ()
		{
				powerups.Add (new Powerup ("Double Way", "It doubles the width of the trustable squares", 0, doubleway));
				powerups.Add (new Powerup ("PowerUpChance", "Makes powerups appear more often", 0, pupchance));
		}
	
		// Update is called once per frame
		void OnGUI ()
		{
				GUI.Label (new Rect (0, 0, Screen.width - 100, 30), "You have " + PlayerPrefs.GetInt ("gold", 0) + " gold(s).");
				if (GUI.Button (new Rect (Screen.width - 100, 0, 100, 30), "MAIN")) {
						powerups.Clear ();
						Application.LoadLevel ("sceneTest");
						return;
				}
				for (int i=0; i<powerups.Count; i++) {
						Powerup p = powerups [i];
						Rect pos = new Rect (0, 30 + 50 * i, Screen.width, 50);
						GUIContent cont = new GUIContent (p.name + "(" + p.cost + " gold)\r\n" + p.desc, p.icon);
						if (p.bought)
								GUI.Label (pos, cont);
						else {
								if (GUI.Button (pos, cont))
										p.buy ();
						}
				}
		}
}
