void Awake() { if (SaveSystem.load() == null) { inst = new levelsCompleated(); } else { inst = SaveSystem.load(); } levelProperties = new List <LevelProperties>(); controls = new PlayerControls(); controls.Menu.Select.performed += ctx => SelectWorld(); controls.Menu.Move.performed += ctx => { move = ctx.ReadValue <Vector2>(); MoveSelection(); }; controls.Menu.Move.canceled += ctx => move = Vector2.zero; if (Worlds.Length != 0) { angle = 360 / Worlds.Length; } for (int world = 0; world < Worlds.Length; world++) { print(angle); var q = Quaternion.AngleAxis(angle * world, Vector3.down); print(q); GameObject wrld = Instantiate(Worlds[world], transform.position + q * Vector3.back * radius, Quaternion.identity); wrld.transform.parent = transform; wrld.GetComponent <LevelProperties>().unlocked = inst.unlockedArray[world]; levelProperties.Add(wrld.GetComponent <LevelProperties>()); } world_name_ui.text = levelProperties[choice].world_name; }
private void Awake() { if (SaveSystem.load() == null) { inst = new levelsCompleated(); } else { inst = SaveSystem.load(); } }
public static void saveLevels(levelsCompleated level) { BinaryFormatter format = new BinaryFormatter(); string path = Application.persistentDataPath + "/levels.u"; FileStream stream = new FileStream(path, FileMode.Create); format.Serialize(stream, level); stream.Close(); }
public static levelsCompleated load() { string path = Application.persistentDataPath + "/levels.u"; if (File.Exists(path)) { BinaryFormatter format = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); levelsCompleated data = format.Deserialize(stream) as levelsCompleated; stream.Close(); return(data); } else { Debug.LogError("Save File not found in " + path); return(null); } }