Пример #1
0
        public void People(Player player, List <Quest> activeQuests, List <Tuple <Enemy, int> > enemyTracker)
        {
            if (player.QuestsDone.Find(x => x == StartingQuest) == null && activeQuests.Find(x => x == startingQuest) == null)
            {
                Console.Clear();

                StartingQuest.Start(activeQuests, enemyTracker);

                Console.ReadKey();
            }

            while (true)
            {
                Console.Clear();

                Util.WriteLine("You see: ");

                for (int i = 0; i < Npcs.Count; ++i)
                {
                    if (Npcs[i].QuestToActivate == null || player.QuestsDone.Find(x => x == Npcs[i].QuestToActivate) != null)
                    {
                        Util.Write((i + 1) + " ");
                        Util.WriteLine(Npcs[i].Name, ConsoleColor.Blue);
                    }
                }

                Util.WriteLine("\n0. Exit");

                var decision = Util.NumpadKeyToInt(Console.ReadKey());

                if (decision == 0)
                {
                    break;
                }
                if (decision > 0 && decision - 1 < Npcs.Count)
                {
                    Npcs[decision - 1].Talk(player, activeQuests, enemyTracker);
                }
            }
        }
Пример #2
0
        public void EquipItem(Type type)
        {
            Item item = null;

            if (type == Helmet.GetType())
            {
                item = Helmet;
            }
            else if (type == Armor.GetType())
            {
                item = Armor;
            }
            else if (type == Legs.GetType())
            {
                item = Legs;
            }
            else if (type == Boots.GetType())
            {
                item = Boots;
            }
            else if (type == Weapon.GetType())
            {
                item = Weapon;
            }
            else
            {
                return;
            }

            int site    = 0;
            int maxSite = (ItemStash.Count - 1) / 7;

            while (true)
            {
                List <Item> items = itemStash.Where(x => x.GetType() == type).OrderByDescending(x => x.Level).ToList();

                maxSite = (items.Count - 1) / 7;
                if (site > maxSite)
                {
                    site = maxSite;
                }

                if (items.Count == 0)
                {
                    Util.Write("\nYou don't have any ");
                    Util.Write(type.Name.ToString() + " ", ConsoleColor.DarkGray);
                    Util.Write("in your stash");
                }

                Console.Clear();

                Util.Write("Level", ConsoleColor.DarkRed);
                Util.Write(": ");
                Util.WriteLine(Level + "", ConsoleColor.DarkRed);

                Util.Write(type.Name.ToString() + ": ");
                item.Info(false);

                Util.Write("\n\nItem ", ConsoleColor.DarkGray);
                Util.WriteLine("stash: " + (site + 1) + " / " + (maxSite + 1));

                for (int i = 0; i < 7; ++i)
                {
                    if (items.Count <= i + (site * 7))
                    {
                        break;
                    }

                    Util.Write((i + 1) + " ");
                    items[i + (site * 7)].Info();
                }

                if (site > 0)
                {
                    Util.WriteLine("8. Previous site");
                }

                if (site < maxSite)
                {
                    Util.WriteLine("9. Next site");
                }

                Util.WriteLine("\n0. Exit");

                int decision = Util.NumpadKeyToInt(Console.ReadKey());

                if (decision == 0)
                {
                    break;
                }
                else if (site > 0 && decision == 8)
                {
                    site -= 1;
                }
                else if (site < maxSite && decision == 9)
                {
                    site += 1;
                }
                else if (decision > 0 && decision < 8)
                {
                    if (decision + (site * 7) < items.Count + 1)
                    {
                        if (level >= items[decision - 1 + (site * 7)].Level)
                        {
                            itemStash.Remove(items[decision - 1 + (site * 7)]);
                            if (!item.IsBase)
                            {
                                itemStash.Add(item);
                            }
                            item = items[decision - 1 + (site * 7)];

                            Console.Clear();

                            Util.Write("You've equiped ");
                            Util.WriteLine(item.Name, ConsoleColor.DarkGray);

                            Console.ReadKey();
                        }
                        else
                        {
                            Console.Clear();

                            Util.Write("Your ");
                            Util.Write("level ", ConsoleColor.DarkRed);
                            Util.WriteLine("is too low");

                            Console.ReadKey();
                        }
                    }
                }

                if (item is Helmet helmet)
                {
                    Helmet = helmet;
                }
                else if (item is Armor armor)
                {
                    Armor = armor;
                }
                else if (item is Legs legs)
                {
                    Legs = legs;
                }
                else if (item is Boots boots)
                {
                    Boots = boots;
                }
                else if (item is Weapon weapon)
                {
                    Weapon = weapon;
                }

                CalculateStats();
            }
        }
Пример #3
0
#pragma warning disable CS8632
        public Enemy?Outside(Player player, List <Quest> activeQuests)
#pragma warning restore CS8632
        {
            Enemy enemy = null;

            while (true)
            {
                Console.Clear();

                List <Tuple <Area, Quest> > possibleAreas = areas.Where(x => player.QuestsDone.Find(y => y == x.Item2) != null).ToList();

                foreach (var area in temporaryAreas)
                {
                    if (activeQuests.Contains(area.Item2))
                    {
                        possibleAreas.Add(area);
                    }
                }

                if (possibleAreas.Count > 0)
                {
                    Util.WriteLine("Go to: ");

                    for (int i = 0; i < possibleAreas.Count; ++i)
                    {
                        Util.Write((i + 1) + ". ");
                        Util.WriteLine(possibleAreas[i].Item1.Name, ConsoleColor.DarkGreen);
                    }

                    Util.WriteLine("\n0. Exit");

                    int decision = Util.NumpadKeyToInt(Console.ReadKey());

                    Console.Clear();

                    if (decision == 0)
                    {
                        break;
                    }
                    else if (decision > 0 && decision - 1 < possibleAreas.Count)
                    {
                        enemy = possibleAreas[decision - 1].Item1.LookForEnemy();

                        Util.Write("You met ");
                        Util.WriteLine(enemy.Name, ConsoleColor.Blue);

                        Console.ReadKey();

                        break;
                    }
                }
                else
                {
                    Util.WriteLine("You can't go anywhere");
                    Console.ReadKey();

                    break;
                }
            }

            return(enemy);
        }
Пример #4
0
        private void SellItems(Player player)
        {
            if (player.ItemStash.Count == 0)
            {
                Console.Clear();

                Util.WriteLine("You don't have anything to sell.");

                Console.ReadKey();

                return;
            }

            int site = 0;
            int maxSite;

            while (true)
            {
                maxSite = (player.ItemStash.Count - 1) / 7;
                if (site > maxSite)
                {
                    site = maxSite;
                }

                Console.Clear();

                player.OrderItemStashList();

                Util.Write("Gold", ConsoleColor.DarkYellow);
                Util.Write(": ");
                Util.WriteLine(player.Gold + "\n", ConsoleColor.DarkYellow);

                Util.Write("Item ", ConsoleColor.DarkGray);
                Util.WriteLine("stash: " + (site + 1) + " / " + (maxSite + 1));
                for (int i = 0; i < 7; ++i)
                {
                    if (player.ItemStash.Count <= i + (site * 7))
                    {
                        break;
                    }

                    Util.Write(i + 1 + " ");
                    player.ItemStash[i + (site * 7)].Info(false);
                    Util.Write(" - ");
                    Util.Write(Convert.ToInt32((player.ItemStash[i + (site * 7)].Value() * valueMultiplier))
                               + "G\n", ConsoleColor.DarkYellow);
                }

                if (site > 0)
                {
                    Util.WriteLine("8. Previous site");
                }

                if (site < maxSite)
                {
                    Util.WriteLine("9. Next site");
                }

                Util.WriteLine("\n0. Exit");

                int decision = Util.NumpadKeyToInt(Console.ReadKey());

                if (decision == 0)
                {
                    break;
                }
                else if (site > 0 && decision == 8)
                {
                    site -= 1;
                }
                else if (site < maxSite && decision == 9)
                {
                    site += 1;
                }
                else if (decision > 0 && decision < 8)
                {
                    if (decision + (site * 7) < player.ItemStash.Count + 1)
                    {
                        player.Gold += Convert.ToInt32(player.ItemStash[decision - 1 + (site * 7)].Value() * valueMultiplier);

                        Util.Write("\nYou sold ");
                        Util.Write(player.ItemStash[decision - 1 + (site * 7)].Name, ConsoleColor.DarkGray);
                        Util.Write(" for ");
                        Util.WriteLine(Convert.ToInt32(player.ItemStash[decision - 1 + (site * 7)].Value() * valueMultiplier)
                                       + " G", ConsoleColor.DarkYellow);

                        Console.ReadKey();

                        player.ItemStash.RemoveAt(decision - 1 + (site * 7));
                    }
                }
            }
        }
Пример #5
0
        void BuyItems(Player player)
        {
            while (true)
            {
                Console.Clear();

                Util.Write("Level", ConsoleColor.DarkRed);
                Util.Write(": ");
                Util.WriteLine(player.Level + "", ConsoleColor.DarkRed);

                Util.Write("Gold", ConsoleColor.DarkYellow);
                Util.Write(": ");
                Util.WriteLine(player.Gold + "\n", ConsoleColor.DarkYellow);

                Util.WriteLine("Things to buy: ");

                for (int i = 0; i < items.Count; ++i)
                {
                    Util.Write(i + 1 + " ");
                    items[i].Info(false);
                    Util.Write(" - ");
                    Util.Write((items[i].Value() * ValueMultiplier) + "G\n", ConsoleColor.DarkYellow);
                }

                Util.WriteLine("\n0. Exit");

                int decision = Util.NumpadKeyToInt(Console.ReadKey());

                Console.Clear();

                if (decision == 0)
                {
                    break;
                }
                else if (decision > 0)
                {
                    if (decision < items.Count + 1)
                    {
                        if (player.Gold < items[decision - 1].Value() * ValueMultiplier)
                        {
                            Util.Write("You don't have enough ");
                            Util.Write("gold ", ConsoleColor.DarkYellow);
                            Util.Write("to buy ");

                            if (items[decision - 1] is Consumable)
                            {
                                Util.WriteLine(items[decision - 1].Name, ConsoleColor.Yellow);
                            }
                            else
                            {
                                Util.WriteLine(items[decision - 1].Name, ConsoleColor.DarkGray);
                            }

                            Console.ReadKey();
                        }
                        else if (decision > 0)
                        {
                            player.Gold -= Convert.ToInt32(items[decision - 1].Value() * ValueMultiplier);

                            Util.Write("You bought ");
                            if (items[decision - 1] is Consumable)
                            {
                                Util.Write(items[decision - 1].Name + " ", ConsoleColor.DarkYellow);
                            }
                            else
                            {
                                Util.Write(items[decision - 1].Name + " ", ConsoleColor.DarkGray);
                            }
                            Util.Write("for ");
                            Util.WriteLine(items[decision - 1].Value() * ValueMultiplier + " G", ConsoleColor.DarkYellow);

                            Console.ReadKey();

                            if (items[decision - 1] is not Consumable)
                            {
                                player.ItemStash.Add(items[decision - 1]);
                            }
                            else
                            {
                                if (player.Consumables.Contains(items[decision - 1]))
                                {
                                    player.Consumables.Find(x => x == items[decision - 1]).Count += 1;
                                }
                                else
                                {
                                    player.Consumables.Add((Consumable)items[decision - 1]);
                                }
                            }
                        }
                    }
                }
            }
        }