public void UnitEditorMapMenuRevert() { Global.game_system.play_se(System_Sounds.Confirm); _unitData = new Map_Unit_Data(LastSavedUnitData); set_map(Global.game_system.New_Chapter_Id, Map_Data_Key, "", ""); // Close menu Global.game_temp.menuing = false; MapMenu = null; Global.game_map.highlight_test(); }
public void UnitEditorMapMenuSave() { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); //string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); path += @"\SavedUnitData\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } using (XmlWriter writer = XmlWriter.Create( path + Save_Name + ".xml", settings)) { IntermediateSerializer.Serialize(writer, _unitData, null); } LastSavedUnitData = new Map_Unit_Data(_unitData); }
public override void set_map(string chapter_id, string map_data_key, string unit_data_key, string event_data_key) { if (string.IsNullOrEmpty(Save_Name)) { if (!string.IsNullOrEmpty(chapter_id)) { Save_Name = chapter_id; } Map_Data_Key = map_data_key; UnitDataKey = unit_data_key; } // Set difficulty Global.game_system.Difficulty_Mode = Difficulty_Modes.Normal; foreach (var pair in Constants.Difficulty.DIFFICULTY_SAVE_APPEND) { if (Save_Name.EndsWith("" + pair.Value)) { Global.game_system.Difficulty_Mode = pair.Key; break; } } chapter_id = ""; /* //Debug * if (Unit_Data != null) * { * HashSet<Vector2> keys = new HashSet<Vector2>(); * keys.UnionWith(Unit_Data.Units.Keys); * Dictionary<Vector2, Data_Unit> fgdsf = new Dictionary<Vector2, Data_Unit>(); * foreach (Vector2 key in keys) * //for (int i = 0; i < keys.Count; i++) * { * Data_Unit unit = Unit_Data.Units[key]; * fgdsf[key + new Vector2(2, 2)] = unit; * } * //Unit_Data.Units = fgdsf; * } */ Global.game_battalions = new Game_Battalions(); Global.game_battalions.add_battalion(0); Global.game_battalions.current_battalion = 0; Global.game_actors = new Game_Actors(); while (Global.game_map.units.Count > 0) { Global.game_map.remove_unit(Global.game_map.units.First().Key); } bool new_map = _unitData == null; reset_map(new_map); // Map Data Data_Map map_data; if (Map_Data_Key == "") { map_data = new Data_Map(); } else { Data_Map loaded_map_data = get_map_data(Map_Data_Key); map_data = new Data_Map(loaded_map_data.values, loaded_map_data.GetTileset()); } // Unit Data if (!string.IsNullOrEmpty(unit_data_key) && _unitData == null) { if (Global.content_exists(string.Format(@"Data/Map Data/Unit Data/{0}", UnitDataKey))) { _unitData = Map_Content[0].Load <Map_Unit_Data>(string.Format(@"Data/Map Data/Unit Data/{0}", UnitDataKey)); } else if (_unitData == null) { _unitData = new Map_Unit_Data(); } LastSavedUnitData = new Map_Unit_Data(_unitData); } // Event Data Global.game_state.setup(chapter_id, map_data, _unitData, event_data_key); if (Global.test_battler_1.Generic) { Global.test_battler_1.Actor_Id = Global.game_actors.next_actor_id(); } set_map_texture(); if (new_map) { Global.player.center(); Global.game_system.Instant_Move = true; Global.game_state.update(); Global.game_system.update(); } else { Global.game_map.highlight_test(); } }