using UnityEngine;
using System.Collections;
using System.Diagnostics;
public class GameManager : MonoBehaviour
{
private static GameManager _instance;
public string Quest;
public Stopwatch time;
public int player_money;
public int Player_damage;
public int player_xp;
public int xp_req;
public int player_armor;
public int player_health;
public int player_potions;
public int player_armorpen;
public int player_level;
public float player_xp_modifier;
public int boosterpacks;
public string player_name;
public bool dead;
//Enemy stats
public string monster_name;
public int monster_xp_reward;
public int monster_gold_reward;
public int monster_damage;
public int monster_armor;
public int monster_armorpen;
public int monster_health;
public bool monster_dead;
public static GameManager instance
{
get
{
if(_instance == null)
{
_instance = GameObject.FindObjectOfType<GameManager>();
//Tell unity not to destroy this object when loading a new scene!
DontDestroyOnLoad(_instance.gameObject);
}
return _instance;
}
}
void Awake()
{
if(_instance == null)
{
//If I am the first instance, make me the Singleton
_instance = this;
DontDestroyOnLoad(this);
}
else
{
//If a Singleton already exists and you find
//another reference in scene, destroy it!
if(this != _instance)
Destroy(this.gameObject);
}
time = Stopwatch.StartNew();
}
void FixedUpdate()
{
if(time.ElapsedMilliseconds >= 5000)
{
time.Reset();
Save ();
print("Saved");
}
}
void Save()
{
//Super awesome save function.
}
}