Example #1
0
        /// <summary>
        /// Checks money and availablity and then buys the weapon
        /// </summary>
        /// <param name="price">Price of the weapon to be bought</param>
        /// <param name="name">Name of the weapon to be bought</param>
        /// <param name="damage">Damage of the weapon to be bought</param>
        /// <param name="choiceNumber">User's input choice</param>
        static void BuyWeapon(int price, string name, int damage)
        {
            Console.WriteLine();

            //checks to see if the weapon had already been purchased
            if (!bought[ninput - 1])
            {
                //checks to see if the player has enough money
                if (Player.money >= price)
                {
                    Player.weapons.Add(new Weapon(name, damage));
                    Player.money      -= price;
                    bought[ninput - 1] = true;
                    Console.WriteLine("Weapon Bought");
                }
                else
                {
                    Console.WriteLine("You don't have enough money for this");
                }
            }
            else
            {
                Console.WriteLine("You already have this weapon");
            }

            Texts.PressAnyButton();
        }
Example #2
0
        /// <summary>
        /// The defence sequence (monster attacks character)
        /// </summary>
        static void Defend()
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("The monster just hit you and dealt " + fields[arrayNumber].monsterDamage + " damage.");
            Console.ForegroundColor = ConsoleColor.White;

            Player.health -= fields[arrayNumber].monsterDamage;

            Console.WriteLine("You have {0} health. The monster has {1} health", Player.health, fields[arrayNumber].monsterHealth);

            Texts.PressAnyButton();
        }
Example #3
0
        /// <summary>
        /// Checks money and availablity and then buys the potion
        /// </summary>
        /// <param name="price">Price of the item</param>
        static void BuyPotion(int price)
        {
            //checks to see if there is enough space in the inventory
            if (Player.healthPotions < 11)
            {
                //checks to see if the player has enough money
                if (Player.money >= price)
                {
                    Player.healthPotions++;
                    Player.money -= price;
                    Console.WriteLine("Potion Bought");
                }
                else
                {
                    Console.WriteLine("You don't have enough money for this");
                }
            }
            else
            {
                Console.WriteLine("You have too many potions already!");
            }

            Texts.PressAnyButton();
        }
Example #4
0
        /// <summary>
        /// The sequence for entering battle field 3
        /// </summary>
        public static void B3()
        {
            //sets up the player "location" and the index variable
            Player.location = "B3";
            arrayNumber     = 2;

            do
            {
                //there are always two different options if
                if (!fields[arrayNumber].MonsterDead())
                {
                    //lets the user choose what to do when confronted by the monster
                    BattleChoice();
                }
                else
                {
                    //Gives the user the money
                    if (!fields[1].itemPickedUp)
                    {
                        Player.money += fields[1].awardMoney;
                    }

                    Console.WriteLine("A large monster lays infront of you");
                    Console.WriteLine("The only option left is to go to a new area");
                    Thread.Sleep(Numbers.shortWait);
                    Console.WriteLine("You can go in three directions");
                    Thread.Sleep(Numbers.shortWait);
                    Console.WriteLine("1. Battle Field 5");
                    Thread.Sleep(Numbers.shortWait);
                    Console.WriteLine("2. Dungeon 1");
                    Thread.Sleep(Numbers.shortWait);
                    Console.WriteLine("3. Battle Field 1");
                    Thread.Sleep(Numbers.shortWait);
                    Console.WriteLine("4. View Map/Inventory");
                    Thread.Sleep(Numbers.shortWait);


                    //makes sure that the input was a number
                    do
                    {
                        Console.BackgroundColor = ConsoleColor.Red;
                        Console.WriteLine("Please enter a number");
                        Console.BackgroundColor = ConsoleColor.Black;

                        //gets the input
                        Console.ForegroundColor = ConsoleColor.Green;
                        input = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.White;
                    } while (!Int32.TryParse(input, out ninput));

                    switch (ninput)
                    {
                    case 1:

                        Texts.TravelTo("B5");
                        B5();
                        break;

                    case 2:
                        if (Player.d1Key)
                        {
                            Texts.TravelTo("D1");
                            D1();
                        }

                        else
                        {
                            Console.WriteLine("You cannot enter here without a key...");
                            Texts.PressAnyButton();
                        }


                        break;

                    case 3:

                        Texts.TravelTo("B1");
                        B1();
                        break;

                    case 4:
                        Texts.Map();
                        break;
                    }
                }
            } while (true);
        }
Example #5
0
        /// <summary>
        /// The attack sequence (character attacks monster)
        /// </summary>
        static void Attack()
        {
            bool validNumberForList = false;

            Console.Clear();

            Console.WriteLine("What weapon do you want to attack with?");
            Thread.Sleep(Numbers.shortWait);
            Texts.ShowInventory(true, false);

            do
            {
                //makes sure that the input was a number
                do
                {
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.WriteLine("Please enter a number");
                    Console.BackgroundColor = ConsoleColor.Black;

                    //gets the input
                    Console.ForegroundColor = ConsoleColor.Green;
                    input = Console.ReadLine();
                    Console.ForegroundColor = ConsoleColor.White;
                } while (!Int32.TryParse(input, out ninput));


                Console.Clear();

                if (ninput > 0 && ninput <= Player.weapons.Count)
                {
                    validNumberForList = true;
                }
                else
                {
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.WriteLine("Please enter a number that is listed above");
                    Console.BackgroundColor = ConsoleColor.Black;
                }
            } while (!validNumberForList);

            Console.Clear();

            //tells the user what they did
            Weapon w = Player.weapons[ninput - 1];

            Console.WriteLine("You've attacked with " + w.name + " and did " + w.damage + " damage. " + randomCoolWord());

            fields[arrayNumber].monsterHealth -= w.damage;

            //checks to see if the monster is alive
            if (!fields[arrayNumber].MonsterDead())
            {
                //lets the player defend against the monsters attacks
                Defend();
            }
            else
            {
                Console.WriteLine("You killed the monster! " + randomCoolWord());

                Texts.PressAnyButton();
            }
        }