private void DisplayPotions(List <Item> potionList) { int i = 0; Console.WriteLine("Potions:"); foreach (HealthPotion potion in potionList) { HealthPotion tryPotion = potion as HealthPotion; if (tryPotion != null) { Console.WriteLine(i + ") " + potion + " " + inventory.contents[potion]); i++; } } }
private void DisplayPotions(List <Item> potionList) { int i = 0; Console.WriteLine("Potions:"); foreach (HealthPotion s in potionList) { HealthPotion potion = s as HealthPotion; if (potion != null) { Console.WriteLine(i + ") " + s.name + " " + inventory.contents[s]); i++; } } }
/// <summary> /// Creates all enemy objects with Loop drops already added to their /// respective inventories /// </summary> /// <returns>All enemies in an Array</returns> private static Enemy[] CreateAllEnemies() { List <Enemy> AllEnemies = new List <Enemy>(); //Tutorial Enemy Enemy Spider = new Enemy("Small Spider"); Poison venom = new Poison("Spider Venom", "athough it has a very " + "attractive smell, \n this venom will weaken anyone who touches it.", false); Spider.AddToInventory(venom, 1); //STAGE 1 ENEMIES Enemy Skeleton = new Enemy("Skeleton", 20, 1, 5, 6); Weapon IronSword = new Weapon("Iron Sword", "sword", "A Sword made of Iron", 10, 0); HealthPotion SkeleFluid = new HealthPotion("Skeleton Fluid", "\n Fluid from a skeleton... it looks nutritious", false); Skeleton.AddToInventory(IronSword, 1); Skeleton.AddToInventory(SkeleFluid, 2); Enemy Goblin = new Enemy("Goblin", 30, 2, 7, 9); Weapon SteelSword = new Weapon("Blessed Steel Sword", "sword", "sword made of steel, with slight magic damage", 15, 10); Poison GoblinBlood = new Poison("Goblin Blood", "blood from the heart of the Goblin, \na known harmful neurotoxin.", false); Goblin.AddToInventory(SteelSword, 1); Goblin.AddToInventory(GoblinBlood, 2); Enemy Giant = new Enemy("Giant", 40, 3, 10, 13); Weapon Shield = new Weapon("Basic Shield", "shield", "Shield that slightly reduces enemy damage in battle. " + "Automatically equipped when using a sword.", 0, 0); HealthPotion GiantMagic = new HealthPotion("Giant Magic", "magic potion used by the Giant to cure his injuries", true); Item key1 = new Item("Key I", "key", "this is the key colloected from first stage"); Giant.AddToInventory(key1, 1); Giant.AddToInventory(Shield, 1); Giant.AddToInventory(GiantMagic, 1); //STAGE 2 ENEMIES Enemy GiantSpider = new Enemy("Giant Spider", 40, 10, 5, 30); Weapon BasicBow = new Weapon("BasicBow", "bow", "basic wooden bow", 20, 0); Poison spidervenom = new Poison("Spider Venom", "poison", false); GiantSpider.AddToInventory(BasicBow, 1); GiantSpider.AddToInventory(spidervenom, 1); Enemy Alligator = new Enemy("Alligator", 50, 10, 10, 30, "bow"); Poison FireArrows = new Poison("Fire Arrows", "this quiver contains a poisonous fire arrow", true); HealthPotion aligatoreggs = new HealthPotion("Alligator Eggs", "Delicous and nourishing alligator eggs!.", false); aligatoreggs.Potency = 50; Alligator.AddToInventory(FireArrows, 1); Alligator.AddToInventory(aligatoreggs, 1); Enemy Kraken = new Enemy("Kraken", 70, 10, 10, 40, "bow"); Weapon Crossbow = new Weapon("CrossBow", "bow,", "Higher damage than basic bow, gains magical powers when combined " + "with fire arrows", 20, 15); Item key2 = new Item("Key II", "key", "this is the key collected from second stage"); HealthPotion Krakenblood = new HealthPotion("Kraken Blood", "magical blood that fully restores health", true); Kraken.AddToInventory(Crossbow, 1); Kraken.AddToInventory(Krakenblood, 1); Kraken.AddToInventory(key2, 1); //STAGE 3 ENEMIES Enemy Wolf = new Enemy("Wolf", 60, 10, 10, 30); Weapon Staff = new Weapon("Magic Staff", "staff", "Basic magic staff", 10, 20); HealthPotion WolfMilk = new HealthPotion("Wolf Milk", "Restores partial health", false); Wolf.AddToInventory(Staff, 1); Wolf.AddToInventory(WolfMilk, 1); Enemy Zombie = new Enemy("Zombie", 80, 10, 10, 40); Weapon Lstaff = new Weapon("Lightning Staff", "staff", "Metal staff with stronger magical power", 15, 25); Poison zblood = new Poison("Zombie Blood", "Destructive when poured on skin", true); Zombie.AddToInventory(Lstaff, 1); Zombie.AddToInventory(zblood, 1); Enemy Orc = new Enemy("Orc", 80, 10, 10, 50); Item Key3 = new Item("Key III", "key", "this is the key collected from third stage"); Weapon OrcStaff = new Weapon("Orc Staff", "staff", "Super-Powered staff from Orc boss", 20, 30); HealthPotion orcpotion = new HealthPotion("Orc Portion", "Magic potion that restores all health", true); Orc.AddToInventory(OrcStaff, 1); Orc.AddToInventory(orcpotion, 1); Orc.AddToInventory(Key3, 1); //Final Stage ENEMIES Enemy Dragon = new Enemy("Dragon", 90, 4, 20, 50, "sword"); Weapon DragonSheild = new Weapon("Dragon Scale Sheild", "sheild", "magical sheild that can be used to block magic powers", 0, 0); HealthPotion DragonFruit = new HealthPotion("Dragon Fruit", "restoes heatlh fully", true); Dragon.AddToInventory(DragonSheild, 1); Dragon.AddToInventory(DragonFruit, 1); Enemy Ghost = new Enemy("Odalf", 100, 5, 20, 55); AllEnemies.Add(Spider); // 0 // Index in the AllEnemies.Add(Skeleton); // 1 // returned array AllEnemies.Add(Goblin); // 2 AllEnemies.Add(Giant); // 3 AllEnemies.Add(GiantSpider); // 4 AllEnemies.Add(Alligator); // 5 AllEnemies.Add(Kraken); // 6 AllEnemies.Add(Wolf); // 7 AllEnemies.Add(Zombie); // 8 AllEnemies.Add(Orc); // 9 AllEnemies.Add(Dragon); // 10 AllEnemies.Add(Ghost); // 11 return(AllEnemies.ToArray()); }
private void InspectPotion(HealthPotion potion) { Console.WriteLine("Potency: {0}", potion.Potency); }
private static void Main(string[] args) { TextUtil.SetBufferSize(); TextUtil.PrintTextFile("gamelogo.txt"); TextUtil.PressAnyKeyBufferClear(); TextUtil.PrintTextFile("gamelogo2.txt"); Player p1 = GameIntro.Start(new Player("", 100, 10)); Console.Write(p1.Name + ", "); Enemy Spider = new Enemy(); Spider.Name = "Small Spider"; Combat.StartCombat(p1, Spider); p1.TutorialComplete = true; Console.WriteLine("Congrats on Defeating your first Enemy, {0}!", p1.Name); Poison venom = new Poison("Spider Venom", "athough it has a very attractive smell, " + "\n this venom will weaken anyone who touches it.", false); Console.WriteLine("The {0} has dropped {1}, {2}. \n You can now add it to your inventory if you desire." , Spider.Name, venom.name, venom.description); int answer = getChoice(2, "Would you like to add to inventory? \n 1) Yes \n 2) No)\n"); if (answer == 1) { p1.AddToInventory(venom, 1); Console.WriteLine("{0} has been added to you inventory.", venom.name); } else { Console.WriteLine("you have dropped {0}", venom.name); } Console.WriteLine("{0}, good job on your combat training, \n we are now ready to venture" + " into the tunnel. \nIt will be challening, but after seeing your skills, \nI trust you will bring peace to the woods.", p1.Name); int forward = getChoice(2, "Are you ready to journey into the tunnel? \n 1) Yes \n 2) No)\n"); if (forward == 1) { Console.WriteLine("Good to hear, we are now entering the cave."); } else { Console.WriteLine("You're coming anyways... were walking into the tunnel."); } Console.WriteLine("Its seems we have come to a fork. There are 4 doors ahead of us." + "\n Look! there's a note on the wall."); string noteDescription = TextUtil.ReturnTextFile("note.txt"); Item note = new Item("Note", "Paper", noteDescription); int response = getChoice(2, " Would you like to: \n 1) Take a Look \n 2) Add to Inventory"); if (response == 1) { Console.WriteLine(note.description); Console.WriteLine("\n\n**Hmmmm, kind of odd that the name at the bottom is ripped off**\n\n"); } else { p1.AddToInventory(note, 1); } p1.AddToInventory(note, 1); Console.WriteLine("Well lets not take too long, lets start finding keys!\n"); bool responseIsGood = false; while (!(responseIsGood)) { response = getChoice(4, "Which door would you like to enter? \n 1) Door 1 \n 2) Door 2 \n 3) Door 3 \n 4) Open Inventory \n"); if (p1.currentStage == 0 && //Stage 1 starts here response != 4) { if (OpenedDoors(response, p1) == true) { p1.Stage = true; Console.WriteLine("Okay, we are going into door {0}", response); Enemy skeleton = new Enemy("Skeleton", 10, 1, 5, 6); Weapon IronSword = new Weapon("Iron Sword", "sword", "sword made of iron", 10, 0); HealthPotion skeleFluid = new HealthPotion("Skeleton Fluid", "Fluid from a skeleton... it looks nutritious", false); skeleton.AddToInventory(IronSword, 1); skeleton.AddToInventory(skeleFluid, 2); Enemy goblin = new Enemy("Goblin", 20, 2, 7, 9); Weapon SteelSword = new Weapon("#blessed Steel Sword", "sword", "sword made of steel, with slight magic damage", 15, 10); HealthPotion GoblinBlood = new HealthPotion("Goblin Blood", "blood from the heart of the Goblin", false); goblin.AddToInventory(SteelSword, 1); goblin.AddToInventory(GoblinBlood, 2); Enemy giant = new Enemy("Giant", 35, 3, 10, 13); Weapon BasicBow = new Weapon("BasicBow", "bow", "basic wooden bow", 20, 0); HealthPotion GiantMagic = new HealthPotion("Giant Magic", "magic potion used by the Giant to cure his injuries", true); Item key1 = new Item("Key I", "key", "this is the key colloected from first stage"); giant.AddToInventory(key1, 1); giant.AddToInventory(BasicBow, 1); giant.AddToInventory(GiantMagic, 1); DoorStage(p1, skeleton, goblin, giant); Console.WriteLine("After defeating the giant, you leave the room. You hear \n the door lock behind you as you step into the lobby."); p1.Stage1Complete = true; ////Stage 1 ends here p1.currentStage = 1; p1.Stage = false; continue; } else if (p1.Stage1Complete) { Console.WriteLine("The door is sealed shut"); continue; } } else if (p1.currentStage == 1 && response != 4) { if (OpenedDoors(response, p1) == true) { Console.WriteLine("Okay, we are going into door {0}", response); Enemy GiantSpider = new Enemy("Giant Spider", 20, 10, 5, 7); Enemy alligator = new Enemy("Alligator", 20, 10, 5, 7); Enemy kraken = new Enemy("Kraken", 20, 10, 5, 7); Item key2 = new Item("Key II", "key", "this is the key collected from second stage"); kraken.AddToInventory(key2, 1); DoorStage(p1, GiantSpider, alligator, kraken); p1.Stage2Complete = true; p1.currentStage = 2; continue; } else if (p1.Stage2Complete) { response = UI.PromptInt("You have already completed this Door, choose another."); continue; } } else if (p1.currentStage == 2 && response != 4) { if (OpenedDoors(response, p1) == true) { Console.WriteLine("Okay, we are going into door {0}", response); Enemy wolf = new Enemy("Wolf", 20, 10, 5, 7); Enemy zombie = new Enemy("Zombie", 20, 10, 5, 7); Enemy orc = new Enemy("Orc", 20, 10, 5, 7); Item key3 = new Item("Key III", "key", "this is the key collected from third stage"); orc.AddToInventory(key3, 1); DoorStage(p1, wolf, zombie, orc); p1.Stage3Complete = true; p1.currentStage = 3; } else if (p1.Stage3Complete) { response = UI.PromptInt("You have already completed this Door, choose another."); continue; } } else if (response == 4) { p1.DisplayInventoryContents(); string input = UI.PromptLine("Spell out the name of Item you wish to see description of. (case doesn't matter)"); foreach (KeyValuePair <Item, int> a in p1.inventory.contents) { if (input.Trim().ToLower() == a.Key.name.Trim().ToLower()) { p1.Inspect(a.Key); } else { input = UI.PromptLine("There is no item in your inventory that matches that input. Try again."); } } } else if (p1.currentStage == 3 && response != 4) { responseIsGood = true; continue; } } }
public void UseHealthPotion(HealthPotion pot) { ModifyCurrentHP(pot.Potency); RemoveFromInventory(pot, 1); }
static void Main(string[] args) { Console.WriteLine(FIO.GetLocation("TextFile1.txt")); // Test create player with custom constructor values Player p1 = new Player("George", 10, 10); Console.WriteLine(p1.Name); // Test player "conversation" command p1.Emote("Hello"); // Test create generic non-combat character Character NPC1 = new Character(); if (NPC1.isAlive()) { Console.WriteLine(NPC1.Name + " is alive"); } // Test create generic player Player p2 = new Player(); if (p2.isAlive()) { Console.WriteLine("player 2 " + p2.Name + " is alive"); Console.WriteLine("player 2 {0} has {1} health", p2.Name, p2.TotalHP); Console.WriteLine("player 2 level is {0}", p2.Level); } // Test create Axe with placeholders for constructors Weapon Axe = new Weapon("axe of smashing", "two-handed axe", "this axe smashes things", 10, 0); Console.WriteLine(Axe.name); if (Axe.playerCanEquip) { Console.WriteLine("{0} can be equiped.", Axe.name); } // Test create inventory with placeholder items added Weapon magicbow = new Weapon("MagicBow", "Bow", "A magical bow", 5, 1); //string magicArrow = "magical arrows"; p1.AddToInventory(magicbow, 1); p1.DisplayInventoryContents(); // Test Remove items until no more of said item remain for (int i = 0; i < p1.inventory.contents.Count; i++) { p1.RemoveFromInventory(magicbow, 1); } //Test Remove item not in inventory Item MagicShield = new Item("MagicShield", "Shield", "A Magical Shield"); p1.RemoveFromInventory(MagicShield, 1); //p1.AddToInventory(magicArrow, 5); // Create new bag, add items to it, test that cannot add more items // Than capacity of bag Quiver testbag = new Quiver(); Weapon SteelArrow = new Weapon("Steel Arrow", "Arrow", "A Good Arrow", 5, 0); testbag.Add(SteelArrow, 7); testbag.ArrowsInQuiver(); testbag.Remove(SteelArrow, 12); testbag.ArrowsInQuiver(); // Test Equip and Unequip player functions p1.Equip(SteelArrow); Console.WriteLine("player one is wielding " + p1.EquippedWeapon.name); p1.UnEquip(); Console.WriteLine("player one is wielding " + p1.EquippedWeapon.name); // Test Inspect Functions p1.Inspect(Axe); p1.Inspect(p1.EquippedWeapon); //Test Health Potions! Console.WriteLine("{0}'s current health: {1}", p1.Name, p1.CurrentHP); p1.CurrentHP = p1.CurrentHP / 2; Console.WriteLine("{0}'s current health: {1}", p1.Name, p1.CurrentHP); // Create and Inspect Potion to display properties to player HealthPotion potion = new HealthPotion(); p1.Inspect(potion); // Add a basic health potion to player 1's inventory here // Stronger ones can be made by manually declaring one p1.AddToInventory(new HealthPotion(), 1); // Test use Healthpotion with 1 HealthPotion in Inventory p1.UseHealthPotion(); Console.WriteLine("{0}'s current health: {1}", p1.Name, p1.CurrentHP); // Test UseHealthPotion with NO potions in Inventory p1.UseHealthPotion(); //test Create enemy and engage in combat Enemy enemy = new Enemy(); p1.AddToInventory(Axe, 1); p1.Equip(Axe); Combat.StartCombat(p1, enemy); // So console doesn't auto close string abc = Console.ReadLine(); }