public static Hike ContinueHike(Hike nowHike) { string name; Console.WriteLine("Enter hike name"); name = Console.ReadLine(); List <Character> characters = nowHike.GetAllCharacters(); Storage storage = nowHike.GetStorage(); Console.WriteLine("Choose quest"); TileWithCoords choosenTile = Map.ChooseTileOnMap(nowHike.GetHikePlacement()); List <Eventt> choosenQuests = ReadLoadTile.ReadTileById(choosenTile.GetTile()).GetQuests(); Coords destination = choosenTile.GetCoords(); int i = 0; foreach (Eventt qst in choosenQuests) { Console.WriteLine("{0}. {1}", i, qst.GetName()); i++; } int cho = PlayerInput.Input(0, choosenQuests.Count()); Eventt quest = choosenQuests[cho]; Console.WriteLine("Choose Path"); List <Coords> path = Map.BuildPath(nowHike.GetHikePlacement(), destination); return(new Hike(name, characters, path, quest, storage)); }
public static void ChooseItem(Hike nowHike, Character subject) { int i = 0; int cho; if (nowHike.GetStorage().GetAllItems().Count() != 0) { do { Console.WriteLine("Choose an item:"); foreach (Item itm in nowHike.GetStorage().GetAllItems()) { Console.WriteLine("{0}. {1}", i, itm.GetName()); i++; } Console.WriteLine("{0}. Return", i); i = 0; cho = PlayerInput.Input(0, nowHike.GetStorage().GetAllItems().Count() + 1); Console.Write("\n"); if (cho >= 0 && cho < nowHike.GetStorage().GetAllItems().Count()) { if (ChooseUseOfItem(nowHike.GetStorage().GetAllItems()[cho], nowHike, subject)) { nowHike.GetStorage().GetAllItems().RemoveAt(cho); } } } while (cho != nowHike.GetStorage().GetAllItems().Count()); } }
public void play(Hike nowHike) { foreach (Character character in nowHike.GetAllCharacters()) { Town.AddFreeCharacter(character); } foreach (Item item in nowHike.GetStorage().GetAllItems()) { Town.AddStorageItem(item); } nowHike.EndOfTheHike(); }
public static int ChoosePassiveUse(string passiveUseName, Hike nowHike) { List <Item> items = nowHike.GetStorage().FindPassiveUses(passiveUseName); if (items.Count() == 0) { return(0); } else { int i = 0; int cho; Console.WriteLine("Choose Item:"); foreach (Item itm in items) { Console.WriteLine("{0}. {1}", i, itm.GetName()); Console.WriteLine("Level: {0}", itm.FindPassiveUses(passiveUseName)); i++; } Console.WriteLine("{0}. Don't use any", i); do { cho = Convert.ToInt32(Console.ReadKey().KeyChar) - 48; if (cho >= 0 && cho < items.Count()) { return(items[cho].FindPassiveUses(passiveUseName)); } else { if (cho == items.Count()) { return(0); } } } while (true); } }
public static void SaveHike(Hike hike) { string id = Convert.ToString(hike.GetId()); string name = hike.GetName(); string characterFileName = prefix + namePrefix + id + extention; XDocument characterFile = new XDocument(); XElement rootElement = new XElement(namePrefix + id); XElement hikeName = Functions.CreateElement("name", name); rootElement.Add(hikeName); rootElement.Add(Functions.CreateElement("progress", Convert.ToString(hike.GetProgress()))); XElement characterElement = new XElement("characters"); foreach (Character character in hike.GetAllCharacters()) { characterElement.Add(Functions.CreateElement("characterTrueId", Convert.ToString(character.GetSide()) + Convert.ToString(character.GetId()))); } rootElement.Add(characterElement); XElement pathElement = new XElement("path"); XElement coordElement; foreach (Coords coords in hike.GetCoords()) { coordElement = new XElement("coords"); coordElement.Add(Functions.CreateElement("x", Convert.ToString(coords.Get()[1]))); coordElement.Add(Functions.CreateElement("y", Convert.ToString(coords.Get()[0]))); pathElement.Add(coordElement); } rootElement.Add(pathElement); XElement questElement; string questName = hike.GetQuest().GetName(); Coords questTileCoords = hike.GetCoords()[hike.GetCoords().Count - 1]; Tile questTile = ReadLoadTile.ReadTileById(Map.GetTileByCoords(questTileCoords)); int i = 0; foreach (Eventt tileQuest in questTile.GetQuests()) { if (tileQuest.GetName() == questName) { break; } i++; } XmlDocument tileDocument = ReadLoadTile.GetTileDocumentById(Map.GetTileByCoords(questTileCoords)); XmlNode root = tileDocument.DocumentElement; XmlNode allQuestsElement = root.ChildNodes[7]; questElement = XElement.Load(allQuestsElement.ChildNodes[i].CreateNavigator().ReadSubtree()); rootElement.Add(questElement); XElement storageElement = new XElement("storage"); storageElement.Add(Functions.CreateElement("maxVolume", Convert.ToString(hike.GetStorage().GetMaxVolume()))); storageElement.Add(Functions.CreateElement("maxMass", Convert.ToString(hike.GetStorage().GetMaxMass()))); XElement itemsElement = new XElement("Items"); foreach (Item item in hike.GetStorage().GetAllItems()) { itemsElement.Add(Functions.CreateElement("item", Convert.ToString(item.GetId()))); } storageElement.Add(itemsElement); rootElement.Add(storageElement); characterFile.Add(rootElement); characterFile.Save(characterFileName); if (!Functions.CheckHikeExistion(Convert.ToString(id))) { XDocument xDocument = XDocument.Load(AllHikesPathsPath); xDocument.Root.Add(Functions.CreateElement(namePrefix + id, prefix + namePrefix + id + extention)); xDocument.Save(AllHikesPathsPath); } }