using UnityEngine;
using System.Collections;

public class MainMenu : MonoBehaviour {
    public Transform buttonNew, buttonAbout, buttonSetting;
    public Transform aboutScreen, settingScreen;
    public Transform buttonCloseAbout;

    private Vector3 worldPos;
	
	void Update () {
        if (Input.GetKey(KeyCode.Escape))
        {
            if (aboutScreen.gameObject.activeSelf)
            {
                aboutScreen.gameObject.SetActive(false);
            }
            else if (settingScreen.gameObject.activeSelf)
            {
                settingScreen.gameObject.SetActive(false);
            }
        }
        if (Input.GetMouseButtonDown(0))
        {
            worldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            if (buttonNew.collider2D.OverlapPoint(worldPos))
            {
                Application.LoadLevel(1);
            }
            else if (buttonAbout.collider2D.OverlapPoint(worldPos))
            {
                aboutScreen.gameObject.SetActive(true);
            }
            else if (buttonSetting.collider2D.OverlapPoint(worldPos))
            {
                settingScreen.gameObject.SetActive(true);
            }
        }
	}
}
