private void Start() { currentStats = (TestPlayerStats)ReadFromPlayerStats(); if (currentStats == null) { currentStats = new TestPlayerStats(100, 100); WriteToPlayerStats(currentStats); } UpdateUI(); }
private void Update() { if (Input.GetKeyDown(KeyCode.H)) { currentStats.health += 5; UpdateUI(); } if (Input.GetKeyDown(KeyCode.J)) { currentStats.health -= 5; UpdateUI(); } if (Input.GetKeyDown(KeyCode.S)) { currentStats.stamina += 5; UpdateUI(); } if (Input.GetKeyDown(KeyCode.D)) { currentStats.stamina -= 5; UpdateUI(); } if (Input.GetKeyDown(KeyCode.W)) { WriteToPlayerStats(currentStats); Debug.Log("<color=green> Stats SAVED into file </color>"); } if (Input.GetKeyDown(KeyCode.R)) { currentStats = (TestPlayerStats)ReadFromPlayerStats(); UpdateUI(); Debug.Log("<color=blue> Stats LOADED from file </color>"); } // if(Input.GetKeyDown(KeyCode.Alpha0)) // { // DeletePlayerStatsFile(); // Debug.Log("<color=red> Stats file DELETED </color>"); // } }
public void WriteToPlayerStats(TestPlayerStats stats) { savePath = Application.persistentDataPath + pStatsDiractory; Binary.WriteToFile(stats, savePath, pStatesFileName); }