public void Load(String Slot) { if (Slot == null) Slot = "AutoSave"; bool WasSaved; if (Slot != "AutoSave") { String fixer; { XmlDocument File = new XmlDocument(); File.Load("Saves\\" + Slot + "\\Profile.xml"); XmlElement root = File.DocumentElement; XmlNode Item = root.SelectSingleNode("//Profile"); fixer = Item["MapName"].InnerText; } WasSaved = System.IO.File.Exists("Saves\\" + Slot + "\\" + fixer + "\\Saved.xml"); Engine.Singleton.CurrentLevel.Name = fixer; } else WasSaved = System.IO.File.Exists("Saves\\" + Slot + "\\" + Engine.Singleton.CurrentLevel.Name + "\\Saved.xml"); TriggerManager.RemoveAll(); while (Engine.Singleton.ObjectManager.Objects.Count > 0) { int q = 0; if (Engine.Singleton.ObjectManager.Objects[0] is Character && (Engine.Singleton.ObjectManager.Objects[0] as Character) == Engine.Singleton.HumanController.Character) { q = 1; if (Engine.Singleton.ObjectManager.Objects.Count == 1) break; } Engine.Singleton.ObjectManager.Destroy(Engine.Singleton.ObjectManager.Objects[q]); } //*************************************************************// // // // ITEMY // // // //*************************************************************// if (System.IO.File.Exists("Saves\\" + Slot + "\\" + CurrentLevel.Name + "\\Items.xml")) { XmlDocument File = new XmlDocument(); File.Load("Saves\\" + Slot + "\\" + CurrentLevel.Name + "\\Items.xml"); XmlElement root = File.DocumentElement; XmlNodeList Items = root.SelectNodes("//items/item"); foreach (XmlNode item in Items) { if (item["DescribedProfile"].InnerText != "") { Described newDescribed = new Described(Gra.Items.I[item["DescribedProfile"].InnerText]); Vector3 Position = new Vector3(); Quaternion Orientation = new Quaternion(float.Parse(item["Orientation_w"].InnerText), float.Parse(item["Orientation_x"].InnerText), float.Parse(item["Orientation_y"].InnerText), float.Parse(item["Orientation_z"].InnerText)); newDescribed.Orientation = Orientation; Position.x = float.Parse(item["Position_x"].InnerText); Position.y = float.Parse(item["Position_y"].InnerText); Position.z = float.Parse(item["Position_z"].InnerText); newDescribed.Position = Position; newDescribed.Activatorr = item["Activator"].InnerText; newDescribed.PrzypiszMetode(); if (newDescribed.IsContainer && WasSaved) { newDescribed.Container.Gold = int.Parse(item["ContainerGold"].InnerText); XmlNodeList No_oN = item["ContainerItems"].ChildNodes; newDescribed.Container.Contains = new List<DescribedProfile>(); foreach (XmlNode o_o in No_oN) newDescribed.Container.Contains.Add(Gra.Items.I[o_o["ContainerItem"].InnerText]); } Engine.Singleton.ObjectManager.Add(newDescribed); } if (item["ItemSword"].InnerText != "") { Described newDescribed = new Described(Gra.Items.I[item["ItemSword"].InnerText]); Vector3 Position = new Vector3(); Quaternion Orientation = new Quaternion(float.Parse(item["Orientation_w"].InnerText), float.Parse(item["Orientation_x"].InnerText), float.Parse(item["Orientation_y"].InnerText), float.Parse(item["Orientation_z"].InnerText)); newDescribed.Orientation = Orientation; Position.x = float.Parse(item["Position_x"].InnerText); Position.y = float.Parse(item["Position_y"].InnerText); Position.z = float.Parse(item["Position_z"].InnerText); newDescribed.Position = Position; newDescribed.Activatorr = item["Activator"].InnerText; newDescribed.PrzypiszMetode(); Engine.Singleton.ObjectManager.Add(newDescribed); } } } //*************************************************************// // // // NPCs // // // //*************************************************************// if (System.IO.File.Exists("Saves\\" + Slot + "\\" + CurrentLevel.Name + "\\NPCs.xml")) { XmlDocument File = new XmlDocument(); File.Load("Saves\\" + Slot + "\\" + CurrentLevel.Name + "\\NPCs.xml"); XmlElement root = File.DocumentElement; XmlNodeList Items = root.SelectNodes("//npcs//npc"); foreach (XmlNode item in Items) { Character newCharacter = new Character(CharacterProfileManager.C[item["ProfileName"].InnerText]); Vector3 Position = new Vector3(); Quaternion Orientation = new Quaternion(float.Parse(item["Orientation_w"].InnerText), float.Parse(item["Orientation_x"].InnerText), float.Parse(item["Orientation_y"].InnerText), float.Parse(item["Orientation_z"].InnerText)); newCharacter.Orientation = Orientation; Position.x = float.Parse(item["Position_x"].InnerText); Position.y = float.Parse(item["Position_y"].InnerText); Position.z = float.Parse(item["Position_z"].InnerText); newCharacter.Position = Position; if (WasSaved) { newCharacter.Statistics = new Statistics( int.Parse(item["WalkaWrecz"].InnerText), int.Parse(item["Krzepa"].InnerText), int.Parse(item["Opanowanie"].InnerText), int.Parse(item["Odpornosc"].InnerText), int.Parse(item["Zrecznosc"].InnerText), int.Parse(item["Charyzma"].InnerText), int.Parse(item["Zywotnosc"].InnerText), int.Parse(item["Ataki"].InnerText)); newCharacter.Statistics.aktualnaZywotnosc = int.Parse(item["aktualnaZywotnosc"].InnerText); newCharacter.State = (Enemy.StateTypes)int.Parse((item["State"].InnerText)); newCharacter.Profile.Gold = ulong.Parse(item["Gold"].InnerText); List<DescribedProfile> Inventory = new List<DescribedProfile>(); XmlNodeList inv = item["Inventory"].ChildNodes; foreach (XmlNode invItem in inv) { Inventory.Add(Gra.Items.I[invItem["InventoryItem"].InnerText].Clone()); } newCharacter.Inventory = Inventory; } Engine.Singleton.ObjectManager.Add(newCharacter); } } //*************************************************************// // // // ENEMIES // // // //*************************************************************// if (System.IO.File.Exists("Saves\\" + Slot + "\\" + CurrentLevel.Name + "\\Enemies.xml")) { XmlDocument File = new XmlDocument(); File.Load("Saves\\" + Slot + "\\" + CurrentLevel.Name + "\\Enemies.xml"); XmlElement root = File.DocumentElement; XmlNodeList Items = root.SelectNodes("//enemies//enemy"); foreach (XmlNode item in Items) { Enemy newCharacter = new Enemy(Gra.CharacterProfileManager.E[item["ProfileName"].InnerText], false, Gra.CharacterProfileManager.E[item["ProfileName"].InnerText].ZasiegWzroku, Gra.CharacterProfileManager.E[item["ProfileName"].InnerText].ZasiegOgolny); Vector3 Position = new Vector3(); Quaternion Orientation = new Quaternion(float.Parse(item["Orientation_w"].InnerText), float.Parse(item["Orientation_x"].InnerText), float.Parse(item["Orientation_y"].InnerText), float.Parse(item["Orientation_z"].InnerText)); newCharacter.Orientation = Orientation; Position.x = float.Parse(item["Position_x"].InnerText); Position.y = float.Parse(item["Position_y"].InnerText); Position.z = float.Parse(item["Position_z"].InnerText); newCharacter.Position = Position; if (WasSaved) { newCharacter.Statistics = new Statistics( int.Parse(item["WalkaWrecz"].InnerText), int.Parse(item["Krzepa"].InnerText), int.Parse(item["Opanowanie"].InnerText), int.Parse(item["Odpornosc"].InnerText), int.Parse(item["Zrecznosc"].InnerText), int.Parse(item["Charyzma"].InnerText), int.Parse(item["Zywotnosc"].InnerText), int.Parse(item["Ataki"].InnerText)); newCharacter.Statistics.aktualnaZywotnosc = int.Parse(item["aktualnaZywotnosc"].InnerText); newCharacter.State = (Enemy.StateTypes)int.Parse((item["State"].InnerText)); } Engine.Singleton.ObjectManager.Add(newCharacter); } } //*************************************************************// // // // TWOJ PROFIL // // // //*************************************************************// if (WasSaved) { XmlDocument File = new XmlDocument(); File.Load("Saves\\" + Slot + "\\Profile.xml"); XmlElement root = File.DocumentElement; XmlNode Item = root.SelectSingleNode("//Profile"); Character ch = HumanController.Character; ch.Profile.Gold = ulong.Parse(Item["Gold"].InnerText); ch.Profile.Exp = int.Parse(Item["Exp"].InnerText); ch.Position = new Vector3(float.Parse(Item["Position_x"].InnerText), float.Parse(Item["Position_y"].InnerText), float.Parse(Item["Position_z"].InnerText)); ch.Orientation = new Quaternion(float.Parse(Item["Orientation_w"].InnerText), float.Parse(Item["Orientation_x"].InnerText), float.Parse(Item["Orientation_y"].InnerText), float.Parse(Item["Orientation_z"].InnerText)); ch.Statistics = new Statistics( int.Parse(Item["WalkaWrecz"].InnerText), int.Parse(Item["Krzepa"].InnerText), int.Parse(Item["Opanowanie"].InnerText), int.Parse(Item["Odpornosc"].InnerText), int.Parse(Item["Zrecznosc"].InnerText), int.Parse(Item["Charyzma"].InnerText), int.Parse(Item["Zywotnosc"].InnerText), int.Parse(Item["Ataki"].InnerText)); ch.Statistics.aktualnaZywotnosc = int.Parse(Item["aktualnaZywotnosc"].InnerText); ch.State = (Enemy.StateTypes)int.Parse((Item["State"].InnerText)); ch.Inventory = new List<DescribedProfile>(); XmlNodeList invItems = Item["Inventory"].ChildNodes; foreach (XmlNode invItem in invItems) { ch.Inventory.Add(Gra.Items.I[invItem["ProfileName"].InnerText].Clone()); if (bool.Parse(invItem["IsEquipment"].InnerText)) { ch.Inventory[ch.Inventory.Count - 1].IsEquipment = true; ch.Sword = ch.Inventory[ch.Inventory.Count - 1] as ItemSword; } } if (Slot != "AutoSave") { CurrentLevel.DeleteWithAutoSave = false; CurrentLevel.LoadNewMap = true; CurrentLevel.NewMapName = Item["MapName"].InnerText; CurrentLevel.NewMapNav = "Karczmanav"; Gra.Quests.Reload(); XmlNodeList quests = Item["Quests"].ChildNodes; foreach (XmlNode quest in quests) { Quest q = Gra.Quests.Q[quest["QuestName"].InnerText]; q.IsFinished = bool.Parse(quest["IsFinished"].InnerText); q.KilledEnemies.Clear(); XmlNodeList killedEnemies = quest["KilledEnemies"].ChildNodes; foreach (XmlNode killedEnemy in killedEnemies) { q.KilledEnemies.Add(killedEnemy["EnemyName"].InnerText, int.Parse(killedEnemy["Amount"].InnerText)); } ch.ActiveQuests.Add(Gra.Quests.Q[quest["QuestName"].InnerText]); } } } //*************************************************************// // // // DIALOGI // // // //*************************************************************// if (Slot != "AutoSave") { XmlDocument File = new XmlDocument(); File.Load("Saves\\" + Slot + "\\Dialogi.xml"); XmlElement root = File.DocumentElement; XmlNodeList Items = root.SelectNodes("//Dialogi//Dialog"); foreach (XmlNode Item in Items) { String id = Item["DialogID"].InnerText; Dialog d = Conversations.D[id]; XmlNodeList talkEdges = Item["TalkEdges"].ChildNodes; foreach (XmlNode talkEdge in talkEdges) { String edgeid = talkEdge["EdgeID"].InnerText; TalkEdge e = d.Edges[edgeid]; e.FirstTalk = bool.Parse(talkEdge["FirstTalk"].InnerText); e.Other = bool.Parse(talkEdge["Other"].InnerText); } } } //*************************************************************// // // // WAYPOINTS // // // //*************************************************************// Engine.Singleton.CurrentLevel.WayPoints.Clear(); if (System.IO.File.Exists("Media\\Maps\\" + CurrentLevel.Name + "\\Waypoints.xml")) { XmlDocument File = new XmlDocument(); File.Load("Media\\Maps\\" + CurrentLevel.Name + "\\Waypoints.xml"); XmlElement root = File.DocumentElement; XmlNodeList Items = root.SelectNodes("//waypoints//waypoint"); foreach (XmlNode item in Items) { WayPoint newWP = new WayPoint(); newWP.DisplayName = item["DisplayName"].InnerText; Vector3 pos = new Vector3(float.Parse(item["Position_x"].InnerText), float.Parse(item["Position_y"].InnerText), float.Parse(item["Position_z"].InnerText)); newWP.Position = pos; Engine.Singleton.CurrentLevel.WayPoints.Add(newWP); Engine.Singleton.ObjectManager.Add(newWP); } } TriggerManager.Load(); }
public void Add(Enemy NewEnemy) { Enemies.Add(NewEnemy); }