public override void Work(Player player) { while (true) { Console.Clear(); Util.WriteColorString(WorkMessage, true); Util.Write("1. Sell "); Util.WriteLine("items", ConsoleColor.DarkGray); Util.Write("2. Sell "); Util.WriteLine("consumables", ConsoleColor.Yellow); Util.WriteLine("\n0. Exit"); var decision = Console.ReadKey(); if (decision.Key == ConsoleKey.NumPad0) { break; } else if (decision.Key == ConsoleKey.NumPad1) { SellItems(player); } else if (decision.Key == ConsoleKey.NumPad2) { SellConsumables(player); } } }
public void Talk(Player player, List <Quest> activeQuests, List <Tuple <Enemy, int> > enemyTracker) { while (true) { Console.Clear(); Util.WriteColorString("@15|Hello, I'm @9|" + Name + "\n"); Util.WriteLine("\nSay: "); Util.WriteLine("1. Hello"); Util.Write("2. Ask about his "); Util.WriteLine("work", ConsoleColor.DarkYellow); Util.Write("3. Ask about the "); Util.WriteLine("place", ConsoleColor.Green); if (quests.Count > 0) { Util.Write("4. Ask if he has any "); Util.Write("quest ", ConsoleColor.Red); Util.WriteLine("for you"); Util.Write("5. Tell him about "); Util.Write("quest ", ConsoleColor.Red); Util.WriteLine("that you finished"); } Util.WriteLine("\n0. Exit"); var decision = Console.ReadKey(); if (decision.Key == ConsoleKey.NumPad0) { break; } else if (decision.Key == ConsoleKey.NumPad1) { Hello(); } else if (decision.Key == ConsoleKey.NumPad2) { Work(player); } else if (decision.Key == ConsoleKey.NumPad3) { Place(player, activeQuests, enemyTracker); } else if (decision.Key == ConsoleKey.NumPad4 && quests.Count > 0) { GiveQuests(player, activeQuests, enemyTracker); } else if (decision.Key == ConsoleKey.NumPad5 && quests.Count > 0) { FinishQuests(player, activeQuests, enemyTracker); } } }
public void ShowStatistics() { Console.Clear(); Util.Write("Helmet: "); Helmet.Info(); Util.Write("Armor: "); Armor.Info(); Util.Write("Legs: "); Legs.Info(); Util.Write("Boots: "); Boots.Info(); Util.Write("Weapon: "); Weapon.Info(); Util.Write("\nExperience", ConsoleColor.DarkRed); Util.Write(": "); Util.Write(Experience + " ", ConsoleColor.DarkRed); Util.Write("/ "); Util.WriteLine(ExperienceToLevel(level) + "", ConsoleColor.DarkRed); Util.Write("Level", ConsoleColor.DarkRed); Util.Write(": "); Util.WriteLine(Level + "\n", ConsoleColor.DarkRed); Util.Write("Gold", ConsoleColor.DarkYellow); Util.Write(": "); Util.WriteLine(Gold + "\n", ConsoleColor.DarkYellow); Util.Write("Health", ConsoleColor.Red); Util.Write(": "); Util.Write(Health + "", ConsoleColor.Red); Util.Write(" / "); Util.WriteLine(MaxHealth + "", ConsoleColor.Red); Util.Write("Damage", ConsoleColor.Magenta); Util.Write(": "); Util.Write(Damage.Item1 + "", ConsoleColor.Magenta); Util.Write(" - "); Util.WriteLine(Damage.Item2 + "", ConsoleColor.Magenta); Util.Write("Defense", ConsoleColor.DarkMagenta); Util.Write(": "); Util.WriteLine(Defense + "\n", ConsoleColor.DarkMagenta); Util.Write("Ability points", ConsoleColor.Cyan); Util.Write(": "); Util.Write(Ap + "", ConsoleColor.Cyan); Util.Write(" / "); Util.WriteLine((Level * ApPerLevel) + "\n", ConsoleColor.Cyan); Console.ReadKey(); }
public override void Info(bool newLine = true) { if (!newLine) { Util.Write(Name, ConsoleColor.Red); } else { Util.WriteLine(Name, ConsoleColor.Red); } }
private void Reward(Player player) { Util.Write("You completed "); Util.WriteLine(Name, ConsoleColor.Red); if (GoldReward == 0 && ItemsReward.Count == 0 && ExperienceReward == 0) { Console.ReadKey(); return; } Util.WriteLine("Reward: "); if (GoldReward > 0) { Util.WriteLine(GoldReward + " G", ConsoleColor.DarkYellow); player.Gold += GoldReward; } if (ExperienceReward > 0) { Util.WriteLine(ExperienceReward + " Experience", ConsoleColor.DarkRed); player.Experience += ExperienceReward; } if (itemsReward.Count > 0) { foreach (var item in itemsReward) { if (item is Consumable consumable) { if (player.Consumables.Contains(item)) { player.Consumables.Find(x => x == item).Count += 1; } else { player.Consumables.Add(consumable); } } else { player.ItemStash.Add(item); } item.Info(); } } Console.ReadKey(); }
public void Start(List <Quest> activeQuests, List <Tuple <Enemy, int> > enemyTracker) { activeQuests.Add(this); foreach (var enemy in questEnemies) { enemyTracker.Add(new Tuple <Enemy, int>(enemy.Item1, 0)); } Util.Write("You started \""); Util.Write(Name + "", ConsoleColor.Red); Util.WriteLine("\""); }
public void Info(Player player, List <Tuple <Enemy, int> > enemyTracker) { Util.WriteLine(Name, ConsoleColor.Red); Util.WriteColorString(description, true); if (QuestEnemies.Count > 0) { Util.WriteLine("\nWin fights:"); int enemyCount = 0; foreach (var enemy in QuestEnemies) { if (enemyTracker.Find(x => x.Item1 == enemy.Item1) != null) { enemyCount = enemyTracker.Find(x => x.Item1 == enemy.Item1).Item2; } if (enemyCount > enemy.Item2) { enemyCount = enemy.Item2; } Util.Write(enemy.Item1.Name + " ", ConsoleColor.Blue); Util.WriteLine(enemyCount + " / " + enemy.Item2); } } if (QuestItems.Count > 0) { Util.WriteLine("\nGet:"); int itemCount = 0; foreach (var item in QuestItems) { if (player.QuestItems.Contains(item.Item1)) { itemCount = player.QuestItems.Find(x => x == item.Item1).Count; } else { itemCount = 0; } Util.Write(item.Item1.Name + " ", ConsoleColor.Red); Util.WriteLine(itemCount + " / " + item.Item2); } } }
public override void Info(bool newLine = true) { Util.Write(Name + " ", ConsoleColor.Yellow); Util.Write("Level " + Level + " ", ConsoleColor.DarkRed); Util.Write("Health " + Health + " ", ConsoleColor.Red); if (!newLine) { Util.Write("Ability points " + Ap, ConsoleColor.Cyan); } else { Util.WriteLine("Ability points " + Ap, ConsoleColor.Cyan); } }
public virtual void Info(bool newLine = true) { Util.Write(Name + " ", ConsoleColor.DarkGray); Util.Write("Level " + Level + " ", ConsoleColor.DarkRed); Util.Write("Health " + Health + " ", ConsoleColor.Red); if (!newLine) { Util.Write("Defense " + Defense, ConsoleColor.DarkMagenta); } else { Util.WriteLine("Defense " + Defense, ConsoleColor.DarkMagenta); } }
public void ShowItemStash() { Console.Clear(); OrderItemStashList(); Util.Write("Item ", ConsoleColor.DarkGray); Util.WriteLine("stash:"); foreach (var item in itemStash) { item.Info(); } Console.ReadKey(); }
public override void Info(bool newLine = true) { Util.Write(Name + " ", ConsoleColor.DarkGray); Util.Write("Level " + Level + " ", ConsoleColor.DarkRed); Util.Write("Damage " + Damage.Item1, ConsoleColor.Magenta); Util.Write(" - "); if (!newLine) { Util.Write(Damage.Item2 + "", ConsoleColor.Magenta); } else { Util.WriteLine(Damage.Item2 + "", ConsoleColor.Magenta); } }
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); } } }
public override void Work(Player player) { while (true) { Console.Clear(); Util.WriteColorString(WorkMessage, true); Util.WriteLine("1. Buy"); Util.WriteLine("\n0. Exit"); var decision = Console.ReadKey(); if (decision.Key == ConsoleKey.NumPad0) { break; } else if (decision.Key == ConsoleKey.NumPad1) { BuyItems(player); } } }
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(); } }
#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); }
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)); } } } }
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]); } } } } } } }