public void LoadTimeDilation() { ShipStatsData data = SaveScript.LoadPlayer(); healthPoint = data.healthPoint; planetSensor = data.planetSensor; atmosphereSensor = data.atmosphereSensor; temperatureSensor = data.temperatureSensor; waterSensor = data.waterSensor; resourcesSensor = data.resourcesSensor; lifeSensor = data.lifeSensor; gravitySensor = data.gravitySensor; sensorBay = data.sensorBay; dataBase = data.dataBase; people = data.people; fuel = data.fuel; equipment1 = data.equipment1; equipment2 = data.equipment2; equip1 = data.equip1; equip2 = data.equip2; scoutRadar = data.scoutRadar; harvestEquipment = data.harvestEquipment; recyclingCenter = data.recyclingCenter; probeBay = data.probeBay; healingDroneBay = data.harvestEquipment; lifeSupportBooster = data.lifeSupportBooster; }
public static void SavePlayer(Ship ship) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/player.fun"; FileStream stream = new FileStream(path, FileMode.Create); ShipStatsData data = new ShipStatsData(ship); formatter.Serialize(stream, data); stream.Close(); }
public static ShipStatsData LoadPlayer() { string path = Application.persistentDataPath + "/player.fun"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); ShipStatsData data = formatter.Deserialize(stream) as ShipStatsData; stream.Close(); return(data); } else { Debug.Log("Save file not found in " + path); return(null); } }