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));
        }
Example #2
0
        public int Go()
        {
            int unrealProgres;

            while (tilesCoords.Count != 0)
            {
                hikePlacement = tilesCoords[0];
                unrealProgres = ReadLoadTile.ReadTileById(Map.GetTileByCoords(hikePlacement)).Walk(this, progress);
                if (unrealProgres != -1)
                {
                    progress = unrealProgres;
                    ReadLoadHike.SaveHike(this);
                    return(0);
                }
                progress = 0;
                tilesCoords.RemoveAt(0);
                Downtime();
            }
            quest.Play(this);
            if (!endOfTheHike)
            {
                PlayerInteractions.ContinueHike(this).Go();
            }
            return(1);
        }
Example #3
0
 public void Continue()
 {
     for (int nowTile = 0; nowTile < tilesCoords.Count; nowTile++)
     {
         ReadLoadTile.ReadTileById(Map.GetTileByCoords(tilesCoords[nowTile])).Walk(this, progress);
         hikePlacement = tilesCoords[nowTile];
         Downtime();
     }
     quest.Play(this);
     if (!endOfTheHike)
     {
         PlayerInteractions.ContinueHike(this).Go();
     }
 }
        public static Hike StartHike()
        {
            List <Coords>    path;
            List <Character> characters = new List <Character> {
            };
            Eventt        quest         = null;
            List <Eventt> choosenQuests;
            bool          continuee = true;
            string        name;
            int           i;
            int           cho;

            Console.WriteLine("Enter hike name");
            name = Console.ReadLine();
            Console.WriteLine("Choose characters");
            while (continuee)
            {
                i = 0;
                Console.WriteLine("Choosen Characters:");
                foreach (Character character1 in characters)
                {
                    Console.WriteLine(character1.GetName());
                }
                Console.WriteLine("Free Characters");
                foreach (Character character in Town.GetFreeCharacters())
                {
                    Console.WriteLine("{0}. {1}", i, character.GetName());
                    i++;
                }
                Console.WriteLine("{0}. Remove characters from hike", i);
                i++;
                Console.WriteLine("{0}. That's all, continue", i);
                cho = PlayerInput.Input(0, Town.GetFreeCharacters().Count() + 2);
                Console.Write("\n");
                if (cho >= 0 && cho < Town.GetFreeCharacters().Count())
                {
                    characters.Add(Town.GetFreeCharacters()[cho]);
                    Town.RemoveFreeCharacter(Town.GetFreeCharacters()[cho]);
                }
                else
                {
                    if (cho == Town.GetFreeCharacters().Count())
                    {
                        do
                        {
                            i = 0;
                            Console.WriteLine("Free Characters");
                            foreach (Character character in Town.GetFreeCharacters())
                            {
                                Console.WriteLine(character.GetName());
                            }
                            Console.WriteLine("Choosen Characters:");
                            foreach (Character character1 in characters)
                            {
                                Console.WriteLine("{0}. {1}", i, character1.GetName());
                                i++;
                            }
                            Console.WriteLine("{0}. Add characters to the hike", i);
                            i++;
                            cho = PlayerInput.Input(0, characters.Count() + 1);
                            if (cho >= 0 && cho < characters.Count())
                            {
                                Town.AddFreeCharacter(characters[cho]);
                                characters.Remove(characters[cho]);
                            }
                            else
                            {
                                if (cho == characters.Count())
                                {
                                    continuee = false;
                                }
                            }
                        } while (continuee);
                        cho       = 0;
                        continuee = true;
                    }

                    if (cho == Town.GetFreeCharacters().Count() + 1)
                    {
                        if (characters.Count() != 0)
                        {
                            continuee = false;
                        }
                        else
                        {
                            Console.WriteLine("Choose at least one");
                        }
                    }
                }
            }
            Console.WriteLine("Choose quest");
            TileWithCoords choosenTile = Map.ChooseTileOnMap(Map.GetTownCoords());

            choosenQuests = ReadLoadTile.ReadTileById(choosenTile.GetTile()).GetQuests();
            Coords destination = choosenTile.GetCoords();

            i = 0;
            foreach (Eventt qst in choosenQuests)
            {
                Console.WriteLine("{0}. {1}", i, qst.GetName());
                i++;
            }
            cho   = PlayerInput.Input(0, choosenQuests.Count());
            quest = choosenQuests[cho];

            Console.WriteLine("Choose Path");
            path = Map.BuildPath(Map.GetTownCoords(), destination);
            return(new Hike(name, characters, path, quest, new List <Item> {
            }, 100, 100));
        }
Example #5
0
        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);
            }
        }