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

public class StarSystemUI : BaseUI
{
	static StarSystemUI instance = null;
	
	[SerializeField] Button scanButton = null;
	
	protected override void Awake()
	{
		base.Awake ();
		instance = this;
		ShowScanButton (false);
	}

	public static void ShowScanButton(bool show = true)
	{
		if (instance != null && instance.scanButton != null)
		{
			instance.scanButton.interactable = show;
		}
	}

	public void OnShipDetailsClick()
	{
		CameraController.SetNeedDistance (0.5f);
		BaseUI.AsyncShowWithLoaderUI<ShipDetailsUI, LoaderUI> (0, () => {
			Game.SetGameState (2);
		});
	}

	public void OnStarMapClick()
	{
		CameraController.SetNeedDistance (30);
		BaseUI.AsyncShowWithLoaderUI<StarMapUI, LoaderUI> (0, () => {
			Game.SetGameState (0);
		});
	}

	public void OnScanClick()
	{
		if (!Player.IsPlanetVisited (Player.info.currentObjectId))
		{
			if (Random.Range(0, 100) < 50)
			{
				BattleState.StartBattle();
				return;
			}
		}
		CameraController.SetNeedDistance (1);
		BaseUI.AsyncShowWithLoaderUI<PlanetarUI, LoaderUI> (0, () => {
			Game.SetGameState (3);
		});
	}

	void Update () {
	}
}
