private void Save(string filename, SerializableData.Level level) { var serializer = new XmlSerializer(typeof(SerializableData.Level)); var encoding = Encoding.GetEncoding("UTF-8"); using (var stream = new StreamWriter(filename, false, encoding)) { serializer.Serialize(stream, level); } }
public void Save() { pauseMenu.SetActive(false); var level = new SerializableData.Level(); level.name = levelNameField.text; foreach (var n in Level.Instance.tiles) { level.nodes.Add(new Position(n.transform.position)); } LevelManager.Instance.loadedLevels.Clear(); LevelManager.Instance.loadedLevels.Add(level); LevelManager.Instance.SaveLevels(); LevelManager.Instance.LoadLevels(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); var handle = target as Level; if (GUILayout.Button("Save")) { var level = new SerializableData.Level(); level.name = handle.name; foreach (var h in handle.nodes) { level.nodes.Add(new SerializableData.Position(h.transform.position)); } LevelManager.Instance.loadedLevels.Add(level); } }
public void Create(SerializableData.Level level) { ClearNodes(); foreach (var n in level.nodes) { var node = new GameObject().transform; node.position = n.Internal; nodes.Add(node); } GenerateTiles(); int pair = FillTiles(); while (pair == 0) { pair = FillTiles(); } UIManager.Instance.inGameMenu.Reset(nodes.Count); ClearNodes(); }