/// <summary>
 /// Provides Logic for Plot and Combat for the fourth stage
 /// </summary>
 /// <param name="player">Main Character</param>
 /// <param name="enemy1">First Enemy to fight</param>
 /// <param name="enemy2">Second Enemy to fight</param>
 /// <param name="boss">Final Boss of Stage</param>
 private static void DoorStage4(Player player, Enemy boss1,
                                Enemy boss2)
 {
     Combat.StartCombat(player, boss1);
     if (DeadOrRunCheck(player, 40))
     {
         return;
     }
     player.Shield = 2;
     Combat.StartCombat(player, boss2);
     if (DeadOrRunCheck(player, 40))
     {
         return;
     }
     Console.ForegroundColor = ConsoleColor.Yellow;
     Console.WriteLine();
     Console.WriteLine("After defeating the {0} and {1}, {2} has " +
                       "Defeated the Game!!", boss1, boss2,
                       player);
     Console.ResetColor();
     player.Stage        = false;
     player.currentStage = 4;
 }
        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;
                }
            }
        }
Ejemplo n.º 3
0
        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();
        }