using System;
using UnityEngine;
using Holoville.HOTween;
using com.deeperbeige.lib;

// Class to try make 3d buttons, using cylinders with capsule collider
//
namespace com.deeperbeige.whiteout
{
		public class Buttons3d : MonoBehaviour
		{


			//	private bool initialised = false;
				[System.NonSerialized]
				public bool
						disabled = false;

				private void Start ()
				{


				}
	
				// method to handle clicking on 3d button, when the button is clicked,
				// we compress it down
				// 
				// you cannot currently change your mind once you have selected this unless you go back
				// from the difficulty level scene
				//
				//
				private void OnMouseDown ()
				{
						//Change the colour of the button
						renderer.material.color = Color.red;
						// make the button smaller
						//CapsuleCollider capsuleCollider = GetComponent ("CapsuleCollider") as CapsuleCollider;
		

						//capsuleCollider.height = 20f;

						// Are you on players or Level select?
						Debug.Log (" level name " + Application.loadedLevelName); // currently null

						// If in the players scene.
						if (name.Contains ("layer")) {

								playerChoices ();

								//
								// Load the level select
								//
								Delays.Invoke(LoadLevel, (object)"levelselect", 2.0f);
				//Transition.To ("levelselect");

						} 
						// if in the levels scene.
						if (name.Contains ("Lev")) {
								Debug.Log ("cube checkname" + name + ", name");

								difficultyChoices ();


								//
								// Load the main game
								//
								Debug.Log ("Level set" + App.inst.levelID);
								// need to add in a delay here
				//Transition.To ("Game");
				Delays.Invoke(LoadLevel, (object)"Game", 2.0f);
						}

						// if in the reset scene.
						if (name.Contains ("Reset")) {

								resetChoices ();
						}


				}

			private void LoadLevel(object levelName)
		{
			Transition.To ((string)levelName);
				}

				//
				// responses to the 3 choices on number of players screen 1/2/4
				//
				public void playerChoices ()
				{
						Debug.Log ("player choice checkname" + name + ", name");		
						// Work out which player was selected
			
						if (name.Contains ("OnePlayer")) {
								Debug.Log ("Single player mode selected");
								//OnClickOnePlayer ();
								// set to 1 player, and go to level select.
								App.inst.players = 1;			
						}
						if (name.Contains ("TwoPlayer")) {
								Debug.Log ("Two player mode selected");
								App.inst.players = 2;
						}
						if (name.Contains ("FourPlayer")) {
								Debug.Log ("Four player mode selected");
								App.inst.players = 4;
						}
				}
				//
				// responses to the 3 choices on difficulties screen - easy/med/hard
				//
				public void difficultyChoices ()
				{
						if (name.Contains ("Easy")) {
								Debug.Log ("Easy selected");
				
                                App.inst.meshParams = MeshParams.EASY;
								App.inst.levelID = "Easy";			
				
						}
			
						if (name.Contains ("Medium")) {
								Debug.Log ("Medium selected");
				
                                App.inst.meshParams = MeshParams.MEDIUM;
								App.inst.levelID = "Medium";			
				
						}
			
						if ((name.Contains ("Hard"))) {
								Debug.Log ("Hard selected");
				
                                App.inst.meshParams = MeshParams.HARD;
								App.inst.levelID = "Hard";			
				
						}

				}
				//
				// responses to the 3 choices on the reset (or pause screen)
				//
				public void resetChoices ()
				{

						if (name.Contains ("Quit")) {
								Debug.Log ("quit selected");

				
						}
			
						if (name.Contains ("Restart")) {
								Debug.Log ("Restart selected");

				
						}
			
						if ((name.Contains ("Resume"))) {
								Debug.Log ("Resume selected");
			
				
						}
			
			
				}
		
		}
	
}
