static void LoadPlayerSaveFile() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(@"./Content/Save/PlayerSave.xml"); XmlNode root = xmlDoc.SelectSingleNode("CV"); XmlNodeList rootList = root.ChildNodes; foreach (XmlNode rootNode in rootList) { switch (rootNode.Name) { case "Global": XmlNodeList rootGlobalList = rootNode.ChildNodes; foreach (XmlNode rootGlobalNode in rootGlobalList) { switch (rootGlobalNode.Name) { case "Time": GlobalController.Time = float.Parse(rootGlobalNode.InnerText); break; case "Year": GlobalController.Year = int.Parse(rootGlobalNode.InnerText); break; case "Season": GlobalController.Season = int.Parse(rootGlobalNode.InnerText); break; case "Date": GlobalController.Date = int.Parse(rootGlobalNode.InnerText); break; case "WeekDay": GlobalController.WeekDay = int.Parse(rootGlobalNode.InnerText); break; case "Weather": GlobalController.Weather = rootGlobalNode.InnerText; break; case "IsShipment": GlobalController.isShipment = bool.Parse(rootGlobalNode.InnerText); break; default: break; } } break; case "Player": XmlNodeList rootPlayerList = rootNode.ChildNodes; foreach (XmlNode rootPlayerNode in rootPlayerList) { switch (rootPlayerNode.Name) { case "Map": GlobalController.CStatus = new GlobalController.Cs { cName = rootPlayerNode.InnerText, func = 0 }; break; case "Position": GlobalController.PlayerWithoutInit.Position = new Vector2(float.Parse(rootPlayerNode.InnerText.Split('|')[0]), float.Parse(rootPlayerNode.InnerText.Split('|')[1])); break; case "Name": GlobalController.PlayerWithoutInit.Name = rootPlayerNode.InnerText; break; case "Character": XmlNodeList elementList = rootPlayerNode.ChildNodes; CharacterTile[] cTile = new CharacterTile[8]; for (int i = 0; i < 8; i++) { string context = elementList[i].InnerText; string[] inner = context.Split('|'); cTile[i] = new CharacterTile(int.Parse(inner[0]), int.Parse(inner[1]), inner[2], inner[4], inner[6], inner[8], inner[10], inner[12], inner[14], inner[16], inner[18], inner[20], inner[22], inner[24], int.Parse(inner[3].Split(',')[0]), int.Parse(inner[3].Split(',')[1]), int.Parse(inner[5].Split(',')[0]), int.Parse(inner[5].Split(',')[1]), int.Parse(inner[7].Split(',')[0]), int.Parse(inner[7].Split(',')[1]), int.Parse(inner[9].Split(',')[0]), int.Parse(inner[9].Split(',')[1]), int.Parse(inner[11].Split(',')[0]), int.Parse(inner[11].Split(',')[1]), int.Parse(inner[13].Split(',')[0]), int.Parse(inner[13].Split(',')[1]), int.Parse(inner[15].Split(',')[0]), int.Parse(inner[15].Split(',')[1]), int.Parse(inner[17].Split(',')[0]), int.Parse(inner[17].Split(',')[1]), int.Parse(inner[19].Split(',')[0]), int.Parse(inner[19].Split(',')[1]), int.Parse(inner[21].Split(',')[0]), int.Parse(inner[21].Split(',')[1]), int.Parse(inner[23].Split(',')[0]), int.Parse(inner[23].Split(',')[1]), int.Parse(inner[25].Split(',')[0]), int.Parse(inner[25].Split(',')[1])); } GlobalController.PlayerWithoutInit.CTile = cTile; break; case "Speed": GlobalController.PlayerWithoutInit.Speed = float.Parse(rootPlayerNode.InnerText); break; case "Gender": GlobalController.PlayerWithoutInit.Gender = bool.Parse(rootPlayerNode.InnerText); break; case "HasLight": GlobalController.PlayerWithoutInit.HasLight = bool.Parse(rootPlayerNode.InnerText); break; case "HpUpper": GlobalController.PlayerWithoutInit.HpUpper = float.Parse(rootPlayerNode.InnerText); break; case "Hp": GlobalController.PlayerWithoutInit.Hp = float.Parse(rootPlayerNode.InnerText); break; case "EnergyUpper": GlobalController.PlayerWithoutInit.EnergyUpper = float.Parse(rootPlayerNode.InnerText); break; case "Energy": GlobalController.PlayerWithoutInit.Energy = float.Parse(rootPlayerNode.InnerText); break; case "Habitus": GlobalController.PlayerWithoutInit.Habitus = float.Parse(rootPlayerNode.InnerText); break; case "Hunger": GlobalController.PlayerWithoutInit.Hunger = float.Parse(rootPlayerNode.InnerText); break; case "Gold": GlobalController.PlayerWithoutInit.Gold = int.Parse(rootPlayerNode.InnerText); break; case "IsDisease": GlobalController.PlayerWithoutInit.IsDisease = bool.Parse(rootPlayerNode.InnerText); break; case "Inventory": XmlNodeList inventoryList = rootPlayerNode.ChildNodes; for (int i = 0; i < inventoryList.Count; i++) { if (i == 0) { GlobalController.InventoryCount = int.Parse(inventoryList[i].InnerText); for (int j = 0; j < GlobalController.InventoryCount; j++) { GlobalController.InventoryList.Add(new Inventory(null, true, j + 1, 0)); } } else { GlobalController.InventoryList[i - 1].AddItem(Item.ItemCreateFactory(inventoryList[i].InnerText.Substring(0, 6)), int.Parse(inventoryList[i].InnerText.Substring(7, inventoryList[i].InnerText.Length - 7))); } } break; case "RapidRoom": XmlNodeList RapidRoomList = rootPlayerNode.ChildNodes; for (int i = 0; i < RapidRoomList.Count; i++) { if (i == 0) { GlobalController.RapidRoomCount = int.Parse(RapidRoomList[i].InnerText); for (int j = 0; j < GlobalController.RapidRoomCount; j++) { GlobalController.RapidRoomList.Add(new Inventory(null, true, j + 1, 0)); } } else { GlobalController.RapidRoomList[i - 1].AddItem(Item.ItemCreateFactory(RapidRoomList[i].InnerText.Substring(0, 6)), int.Parse(RapidRoomList[i].InnerText.Substring(7, RapidRoomList[i].InnerText.Length - 7))); } } break; case "SelectingRapidRoom": XmlNodeList SelectingRapidRoom = rootPlayerNode.ChildNodes; GlobalController.SelectingRapidRoomItem = new Inventory(null, true, 0, 0); if (SelectingRapidRoom.Count > 0) { GlobalController.SelectingRapidRoomItem.AddItem(Item.ItemCreateFactory(SelectingRapidRoom[0].InnerText.Substring(0, 6)), int.Parse(SelectingRapidRoom[0].InnerText.Substring(7, SelectingRapidRoom[0].InnerText.Length - 7))); } break; default: break; } } break; case "Shop": XmlNodeList rootShopList = rootNode.ChildNodes; foreach (XmlNode node in rootShopList) { Shops shop = new Shops(ResourceController.UI_ordinary, ResourceController.UI_logos, Map.Null, node.Name); foreach (XmlNode item in node) { string[] inner = item.InnerText.Split('|'); shop.AddGoods(new Goods(Item.ItemCreateFactory(inner[0]), int.Parse(inner[1]), float.Parse(inner[2]))); } GlobalController.Global_Shops.Add(shop); } break; case "PlayerScene": XmlNodeList rootPlayerSceneList = rootNode.ChildNodes; foreach (XmlNode rootPlayerSceneNode in rootPlayerSceneList) { switch (rootPlayerSceneNode.Name) { case "Chest": string[] contextChest = rootPlayerSceneNode.InnerText.Split('|'); Chest chest = new Chest(new Map(contextChest[0]), new Vector2(int.Parse(contextChest[1]), int.Parse(contextChest[2])), ResourceController.Scenes_chest, int.Parse(contextChest[3])); for (int i = 4; i < contextChest.Length; i++) { string[] contextChestItem = contextChest[i].Split('^'); chest.Inventries[int.Parse(contextChestItem[2])].AddItem(Item.ItemCreateFactory(contextChestItem[0]), int.Parse(contextChestItem[1])); } GlobalController.PlayerSceneList.Add(chest); break; case "Soil": string[] contextSoil = rootPlayerSceneNode.InnerText.Split('|'); if (contextSoil[4] == "True") { Soil soil = new Soil(ResourceController.Scenes_soil, new Map(contextSoil[0]), new Vector2(int.Parse(contextSoil[1]), int.Parse(contextSoil[2])), float.Parse(contextSoil[3]), Item.ItemCreateFactory(contextSoil[5]) as Seeds, true); soil.Seed.LoadingSeeds(float.Parse(contextSoil[6]), bool.Parse(contextSoil[7]), bool.Parse(contextSoil[8]), bool.Parse(contextSoil[9]), float.Parse(contextSoil[10]), float.Parse(contextSoil[11]), float.Parse(contextSoil[12]), float.Parse(contextSoil[13]), float.Parse(contextSoil[14]), float.Parse(contextSoil[15]), float.Parse(contextSoil[16]), float.Parse(contextSoil[17])); GlobalController.SoilList.Add(soil); } else { Soil soil = new Soil(ResourceController.Scenes_soil, new Map(contextSoil[0]), new Vector2(int.Parse(contextSoil[1]), int.Parse(contextSoil[2])), float.Parse(contextSoil[3]), Seeds.Null, false); GlobalController.SoilList.Add(soil); } break; case "PterocarpinTree": string[] contextPTree = rootPlayerSceneNode.InnerText.Split('|'); PterocarpinTree ptree = new PterocarpinTree(new Map(contextPTree[0]), new Vector2(int.Parse(contextPTree [1]), int.Parse(contextPTree[2])), ResourceController.Decorats_spring_tree, ResourceController.Decorats_tree_shadow, true); ptree.GrowTime = float.Parse(contextPTree[3]); GlobalController.PlayerSceneList.Add(ptree); break; case "Furniture": string[] contextFurniture = rootPlayerSceneNode.InnerText.Split('|'); GlobalController.PlayerSceneList.Add(Furniture.CreateFurnitureFactory(new Map(contextFurniture[0]), new Vector2(int.Parse(contextFurniture [1]), int.Parse(contextFurniture[2])), contextFurniture[3])); break; case "Construction": string[] contextConstruction = rootPlayerSceneNode.InnerText.Split('|'); if (contextConstruction[3] == "cowhouse") { CowHouse cowHouse = Construction.CreateConstructionFactory(new Map(contextConstruction[0]), new Vector2(int.Parse(contextConstruction [1]), int.Parse(contextConstruction[2])), contextConstruction[3]) as CowHouse; cowHouse.Init(bool.Parse(contextConstruction[4]), int.Parse(contextConstruction[5]), bool.Parse(contextConstruction[6])); GlobalController.PlayerSceneList.Add(cowHouse); } break; case "Animals": string[] contextAnimal = rootPlayerSceneNode.InnerText.Split('|'); if (contextAnimal[3] == "cow") { Cows cow = Animals.CreateAnimalsFactory(new Map(contextAnimal[0]), new Vector2(int.Parse(contextAnimal [1]), int.Parse(contextAnimal[2])), contextAnimal[3], int.Parse(contextAnimal[5]), float.Parse(contextAnimal[6])) as Cows; cow.Init(float.Parse(contextAnimal[4])); GlobalController.AnimalsList.Add(cow); } break; default: break; } } break; default: break; } } foreach (IPlayerScene ipS in GlobalController.PlayerSceneList) { if (ipS.GetIntanceType() == "Construction") { if ((ipS.GetInstance() as Construction).Name == "cowhouse") { CowHouse ch = ipS.GetInstance() as CowHouse; GlobalController.AnimalsList.ForEach(u => { if (u.GetIntanceType() == "Cows") { if ((u.GetInstance() as Cows).Id == ch.Id) { ch.InitAnimal((u.GetInstance() as Cows)); } } }); } } } //GlobalController.OutdoorItemsList.Add(new OutDoorItem(new Map("village_suburb_west"),new Vector2(2400,1700), new Item("1", new Map("village_suburb_west"), new Vector2(1800, 1300), "water1", Content.Load<Texture2D>("Items/items"), 100))); }