using UnityEngine;
using System.Collections;

public class GameSelectScript : MonoBehaviour {
	
	
	
	
	
	
	public GloriousGame[] games;
	
	
	private Vector2 scrollMenu = Vector2.zero;
	
	private int currentGame = -1;
	
	// Use this for initialization
	void Start () {
		/*games = new GloriousGame[transform.childCount];
		int indexy = 0;
		foreach (Transform child in transform){
			
			games[indexy] = child.GetComponent<GloriousGame>();
			
			indexy ++;
		}*/
	}
	
	public Texture defaultSplash;
	
	void OnGUI(){
		
		
		if (currentGame != -1){
			GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height), games[currentGame].gameSpash);
			
			if (GUI.Button(new Rect(400,500,200,50), "PLAY!")){
				Application.LoadLevel(games[currentGame].loadLevel);
			}
			
			
			GUI.Box(new Rect(300,300,400,150), "~ " + games[currentGame].gameName + " ~\n\n" + games[currentGame].gameDescription);
		}else{
			GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height), defaultSplash);
		}
			
		scrollMenu = GUI.BeginScrollView(new Rect(0,0,200,600), scrollMenu, new Rect(0,0,180,2000));
		
		GUILayout.Label ("\nSELECT A GAME TO PLAY!\n");
		
		for (int i=0; i<games.Length; i++){
			if (GUILayout.Button("\n#" + games[i].gameNumber + ":\n\n" + games[i].gameName + "\n")){
				currentGame = i;
			}
		}
		
		GUI.EndScrollView();
		
		
		
	}
	
	
	// Update is called once per frame
	void Update () {
	
	}
}
