using UnityEngine;
using System.Collections;
using InControl;

public class StageSelection : MonoBehaviour {

	public GameObject forestLevel;
	public GameObject lavaLevel;

	private InputDevice inputDevice;
	private int playerNum = 0;
	private int level = 0;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		inputDevice = (InputManager.Devices.Count > playerNum) ? InputManager.Devices[playerNum] : null;
		if (inputDevice != null)
		{
			if(inputDevice.Action1.WasPressed){
				AudioController.Play("tap");

				if(level == 0){
					Application.LoadLevel("ForestLevel");
				}else{
					Application.LoadLevel("LavaLevel");
				}
			}

			if(inputDevice.Direction.Left.WasPressed){
				AudioController.Play("tap");
				level = 0;
				forestLevel.SetActive(true);
				lavaLevel.SetActive(false);
			}

			if(inputDevice.Direction.Right.WasPressed){
				AudioController.Play("tap");
				level = 1;
				forestLevel.SetActive(false);
				lavaLevel.SetActive(true);
			}
		}
	}
}
