using UnityEngine;
using System.Collections;

public class ApplicationControl : MonoBehaviour
{
	void OnApplicationQuit ()
	{
		DungeonGenerator dg = GameObject.Find("_MasterObject").GetComponent<DungeonGenerator>();
		if (dg != null	&&
			dg.gameInProgress)	// Quitting a game in progress equals death!
		{
			int deaths = PlayerPrefs.GetInt("deaths", 0) + 1;
			PlayerPrefs.SetInt("deaths", deaths);
		}
		persistSaveData();
    }
	public static void persistSaveData ()
	{
		int deaths = PlayerPrefs.GetInt("deaths", 0);
		int victories = PlayerPrefs.GetInt("victories", 0);
		PlayerPrefs.DeleteAll();
		PlayerPrefs.SetInt("deaths", deaths);
		PlayerPrefs.SetInt("victories", victories);
	}
}
