using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class StatController : MonoBehaviour {

    public string scene = "";

    public string[] buttons;

    public Text T1Text = null;
    public Text T2Text = null;

    int t1P;
    int t2P;

    public float GenerationTime = 2f;

    private float _ElapsedTime = 0f;

	void Update () 
    {
        _ElapsedTime += Time.deltaTime;

        if (T1Text == null || T2Text == null)
        {
            return;
        }

        if (_ElapsedTime < GenerationTime)
        {
            GenerateStat();

            T1Text.text = t1P + "%";
            T2Text.text = t2P + "%";
        }
        else
        {
            foreach(string s in buttons)
            {
                if (Input.GetButtonDown(s))
                {
                    if (scene != "")
                    {
                        Application.LoadLevel(scene);
                        break;
                    }
                }
            }
        }
	}

    private void GenerateStat()
    {
        t1P = Random.Range(0, 100);
        t2P = Random.Range(0, 100);
    }
}
