public static Character ChooseCharacter(Hike nowHike)
        {
            Character subject = null;
            int       i       = 0;

            Console.WriteLine("Choose character:");
            foreach (Character s in nowHike.GetAllCharacters())
            {
                Console.WriteLine("{0} {1}", i, s.GetName());
                i++;
            }
            subject = nowHike.GetAllCharacters()[PlayerInput.Input(0, nowHike.GetAllCharacters().Count())];
            return(subject);
        }
        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));
        }
Exemple #3
0
 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();
 }
Exemple #4
0
        public void play(Hike nowHike)
        {
            Character subject;

            subject = PlayerInteractions.ChooseCharacter(nowHike);
            if (Functions.Test(subject.GetAttributeValue(attribute), subject.GetTalentValue(attribute, skill), difficulty))
            {
                Console.WriteLine(gDescription);
                foreach (Character subj in nowHike.GetAllCharacters())
                {
                    gConsequence.Play(nowHike, subj);
                }
            }
            else
            {
                Console.WriteLine(bDescription);
                foreach (Character subj in nowHike.GetAllCharacters())
                {
                    bConsequence.Play(nowHike, subj);
                }
            }
        }
Exemple #5
0
 public void play(Hike nowHike)
 {
     foreach (Character subject in nowHike.GetAllCharacters())
     {
         if (Functions.Test(subject.GetAttributeValue(attribute), subject.GetTalentValue(attribute, skill), difficulty))
         {
             Console.WriteLine("{0} {1}", subject.GetName(), gDescription);
             gConsequence.Play(nowHike, subject);
         }
         else
         {
             Console.WriteLine("{0} {1}", subject.GetName(), bDescription);
             bConsequence.Play(nowHike, subject);
         }
     }
 }
        public static void StartBattle(Hike hike, List <List <IAction> > listOfActionLists, List <Tactic> enemyCharactersTactics)
        {
            bool          continuue = true;
            int           i;
            int           j;
            int           w;
            int           cho;
            List <Tactic> characterTactics = new List <Tactic> {
            };

            foreach (Character character in hike.GetAllCharacters())
            {
                characterTactics.Add(new Tactic(listOfActionLists[0], character));
            }
            while (continuue)
            {
                Console.WriteLine("Choose Character");
                j = 0;

                foreach (Tactic tactic in characterTactics)
                {
                    Console.WriteLine("{0}. {1}", j, tactic.GetCharacter().GetName());
                    i = 0;
                    j++;
                    foreach (IAction action in tactic.GetActions())
                    {
                        Console.WriteLine(" {0} {1}", i, action.GetName());
                        i++;
                    }
                }
                Console.WriteLine("{0}. Start Fight", j);
                Console.Write("\n");

                cho = PlayerInput.Input(0, hike.GetAllCharacters().Count() + 1);
                if (cho >= 0 && cho < hike.GetAllCharacters().Count())
                {
                    j = 0;

                    Console.WriteLine("Choose actions");
                    foreach (List <IAction> actionList in listOfActionLists)
                    {
                        Console.Write("{0}: ", j);
                        j++;
                        i = 0;
                        foreach (IAction action in actionList)
                        {
                            Console.WriteLine(" {0} {1}", i, action.GetName());
                            i++;
                        }
                    }
                    w = PlayerInput.Input(0, listOfActionLists.Count());
                    characterTactics.RemoveAt(cho);
                    characterTactics.Insert(cho, new Tactic(listOfActionLists[w], hike.GetAllCharacters()[cho]));
                }
                else
                {
                    if (cho == hike.GetAllCharacters().Count())
                    {
                        continuue = false;
                    }
                }
            }
            Fight fight = new Fight(characterTactics, enemyCharactersTactics);

            Console.WriteLine(fight.Ffight());
        }
Exemple #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);
            }
        }