using UnityEngine;

public class ScreenShotTaker : Singleton<ScreenShotTaker>
{
	public const KeyCode ScreenShotKey = KeyCode.F9;
	
	private int screenshotCount;

	public void Start()
	{
		if(!PlayerPrefs.HasKey("code-spot::screenshotCount"))
		{
			PlayerPrefs.SetInt("code-spot::screenshotCount", 0);
		}
		else
		{
			screenshotCount = PlayerPrefs.GetInt("code-spot::screenshotCount");
		}
	}
	
	public void Update()
	{
		if(Input.GetKeyDown(ScreenShotKey))
		{
			Take__();
		}
	}

	public void Take__()
	{
		string path = "screen_" + screenshotCount + ".png";
		Debug.Log(path);
		Application.CaptureScreenshot(path);

		screenshotCount++;
		PlayerPrefs.SetInt("code-spot::screenshotCount", screenshotCount);
	}

	public static void Take()
	{
		Instance.Take__();
	}
}
