using UnityEngine;
using System.Collections;

public class InputScript : MonoBehaviour {

	bool hasStarted;

	// Use this for initialization
	void Start () {
		hasStarted = false;
	}
	
	// Update is called once per frame
	void Update () {
		if (Input.GetMouseButtonDown (0)) {
			Vector3 mousePixelPos = Input.mousePosition;
			Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint (mousePixelPos);
			mouseWorldPos.Set (mouseWorldPos.x, mouseWorldPos.y, 0);
			if (!hasStarted && StartPlanetScript.instance.myCollider.OverlapPoint (new Vector2 (mouseWorldPos.x, mouseWorldPos.y))) {
				hasStarted = true;
				StartPlanetScript.instance.PrepareToDestroyYourself ();	
			} else {
				PlanetInstantiatorScript.instance.CreatePlanetIn (mouseWorldPos);
			}
		} else if (Input.GetMouseButtonDown (1)) {
			Vector3 mousePixelPos = Input.mousePosition;
			Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint (mousePixelPos);
			mouseWorldPos.Set (mouseWorldPos.x, mouseWorldPos.y, 0);
			PlanetInstantiatorScript.instance.CreatePlanetOut (mouseWorldPos);
		}
	}
}
