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));
        }
예제 #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);
        }
예제 #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();
     }
 }
예제 #4
0
        public static Hike LoadHike(int id)
        {
            Hike        hike    = null;
            XmlDocument xACPDoc = new XmlDocument();

            xACPDoc.Load(AllHikesPathsPath);
            if (Functions.CheckHikeExistion(Convert.ToString(id)))
            {
                XmlDocument hikeDocument          = new XmlDocument();
                string      characterDocumentPath = prefix + namePrefix + id + extention;
                hikeDocument.Load(characterDocumentPath);
                XmlNode          hikeRoot   = hikeDocument.DocumentElement;
                string           name       = hikeRoot.ChildNodes[0].InnerText;
                int              progress   = Convert.ToInt32(hikeRoot.ChildNodes[1].InnerText);
                List <Character> characters = new List <Character> {
                };
                foreach (XmlNode characterNode in hikeRoot.ChildNodes[2])
                {
                    characters.Add(ReadLoadCharacter.ReadCharacterBySideAndId(characterNode.InnerText));
                }
                List <Coords> coords = new List <Coords> {
                };
                Coords coord;
                foreach (XmlNode coordNode in hikeRoot.ChildNodes[3])
                {
                    coord = new Coords(Convert.ToInt32(coordNode.ChildNodes[0].InnerText), Convert.ToInt32(coordNode.ChildNodes[1].InnerText));
                    coords.Add(coord);
                }
                Eventt quest = ReadLoadTile.GetEventt(hikeRoot.ChildNodes[4]);//!!!!!!!!!
                ReadLoadTile.tCheck();
                XmlNode StorageNode = hikeRoot.ChildNodes[5];
                int     maxVolume   = Convert.ToInt32(StorageNode.ChildNodes[0].InnerText);
                int     maxMass     = Convert.ToInt32(StorageNode.ChildNodes[1].InnerText);

                List <Item> items = new List <Item> {
                };
                foreach (XmlNode itemNode in StorageNode.ChildNodes[2])
                {
                    items.Add(ReadLoadItem.ReadItemById(Convert.ToInt32(itemNode.InnerText)));
                }
                Storage storage = new Storage(items, maxVolume, maxMass);
                hike = new Hike(name, progress, characters, coords, quest, storage);
            }
            return(hike);
        }
        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));
        }
예제 #6
0
        public static Item ReadItemById(int id)
        {
            const string AllItemPathsPath = @"..\..\..\XMLFiles\Items\AllItemPaths.xml";

            string         name;
            string         description;
            int            mass;
            int            volume;
            List <UseItem> uses           = new List <UseItem> {
            };
            List <PassiveUse> passiveUses = new List <PassiveUse> {
            };

            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(AllItemPathsPath);
            XmlNode     root        = xDoc.DocumentElement;
            string      path        = root.ChildNodes[id].InnerText;
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(path);
            root = xmlDocument.DocumentElement;
            XmlNodeList rootChilds = root.ChildNodes;

            name        = rootChilds[0].InnerText;
            description = rootChilds[1].InnerText;
            id          = Convert.ToInt32(rootChilds[2].InnerText);
            mass        = Convert.ToInt32(rootChilds[3].InnerText);
            volume      = Convert.ToInt32(rootChilds[4].InnerText);
            uses        = new List <UseItem> {
            };
            foreach (XmlNode itemUsesNode in rootChilds[5].ChildNodes)
            {
                uses.Add(new UseItem(itemUsesNode.ChildNodes[0].InnerText, Convert.ToBoolean(Convert.ToInt32(itemUsesNode.ChildNodes[1].InnerText)), ReadLoadTile.GetCharacterConsequence(itemUsesNode.ChildNodes[2])));
            }
            foreach (XmlNode passiveItemUsesNode in rootChilds[6].ChildNodes)
            {
                passiveUses.Add(new PassiveUse(passiveItemUsesNode.ChildNodes[0].InnerText, Convert.ToInt32(passiveItemUsesNode.ChildNodes[1].InnerText)));
            }
            return(new Item(name, description, id, mass, volume, passiveUses, uses));
        }
예제 #7
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);
            }
        }