public void LoadData() { sPlayerData data = sSaveSystem.LoadPlayerData(); if (data != null) { _InGround = false; // m_FacingRight = data._FacingRight; _YHeight = data._YHeight; //Spawn Above Ground for now this.transform.position = new Vector3(data.position[0], _YHeight, 0); _MoveLocation.transform.position = new Vector3(data.position[0], _YHeightDummy, 0); StopMoving(); // Cant save Diggable Tiles, could be an issue // _CurrentSoilTile = data._CurrentTopTile; // _CurrentTunnelTile = data._CurrentTunnelTile; } else { Debug.LogError("no SaveData to Load"); } }
public static void SavePlayer(PlayerStats ps, PlayerMovement pm) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/playerdata.txt"; FileStream stream = new FileStream(path, FileMode.Create); // appears to overwrite old sPlayerData data = new sPlayerData(ps, pm); formatter.Serialize(stream, data); stream.Close(); }
/**End Interface stuff*/ public void LoadData() { sPlayerData data = sSaveSystem.LoadPlayerData(); if (data != null) { _Hp = data._Health; _Stamina = data._Stamina; UpdateHealthBar(); UpdateStaminaBar(); } else { Debug.LogError("noSaveData to Load"); } }
public static sPlayerData LoadPlayerData() { string path = Application.persistentDataPath + "/playerdata.txt"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); sPlayerData data = formatter.Deserialize(stream) as sPlayerData; stream.Close(); return(data); } else { Debug.LogError("Cant find player file in" + path); return(null); } }