//Functions /*************************************************************************************************/ public static void SaveGame() { if (!inited) { Init(); } BinaryFormatter bf = new BinaryFormatter(); if (!File.Exists(GetPath())) { File.Create(GetPath()); } FileStream fileStream = File.Open(GetPath(), FileMode.Open); Stats data = new Stats(); data.maxAsteroidDistance = savedMaxAsteroidDistance; data.secondsPerJump = savedSecondsPerJump; data.playerSpeed = playerSpeed; data.maxHunger = maxHunger; data.hungerLowModifier = hungerLowModifier; data.scrap = scrap; data.gravityFragmentCount = gravityFragmentCount; data.obtainedFragment1 = obtainedFragment[0]; data.obtainedFragment2 = obtainedFragment[1]; data.obtainedFragment3 = obtainedFragment[2]; data.tutorialCompleted = tutorialCompleted; data.playerPos = SerialVec3.convTo(player.transform.localPosition); bf.Serialize(fileStream, data); fileStream.Close(); }
public static Vector3 convFrom(SerialVec3 that) { return(new Vector3(that.x, that.y, that.z)); }