static void Main(string[] args) { Console.Title = "SAO DnD Project"; Console.WriteLine("Welcome to the castle floating in the sky... Aincrad"); int levelsBeat = 0; bool usedSwordSkill = false; bool usedHealing = false; Console.WriteLine("Please enter the name you wish to go by in the game"); string playerName = Console.ReadLine(); // 1. Create the player - need to learn custom classes // 2. Create a weapon Weapon LongSword = new Weapon(1, 8, "Long Sword", 10, false); Weapon GreatSword = new Weapon(6, 15, "Greatsword", 5, true); Weapon Dagger = new Weapon(1, 4, "Dagger", 25, false); Weapon MaceandShield = new Weapon(3, 10, "Mace and Shield", 15, true); Console.WriteLine("Choose a weapon type you would like to use on your quest to clear the game\nLongsword 1\nGreatsword 2\nDagger 3\nMace and Shield 4"); string weaponChoice = Console.ReadLine().ToUpper(); bool agile = false; Weapon chosenWeapon = null; bool hasChosenWeapon = false; do { { switch (weaponChoice) { case "1": case "LONGSWORD": case "L": chosenWeapon = LongSword; hasChosenWeapon = true; break; case "2": case "GREATSWORD": case "G": chosenWeapon = GreatSword; hasChosenWeapon = true; break; case "3": case "DAGGER": case "D": chosenWeapon = Dagger; agile = true; hasChosenWeapon = true; break; case "4": case "MACEANDSHIELD": case "M": chosenWeapon = MaceandShield; hasChosenWeapon = true; break; default: Console.WriteLine("Input not recognized. Please enter a correct response"); hasChosenWeapon = false; break; } } } while (hasChosenWeapon == false); Player player = new Player(playerName, 10, 15, 20, 20, chosenWeapon); int playerLevel = 1; if (chosenWeapon == LongSword) { player.HitChance = 50; player.Block = 15; player.Life = 15; player.MaxLife = 15; } if (chosenWeapon == GreatSword) { player.HitChance = 40; player.Block = 10; player.Life = 20; player.MaxLife = 20; } if (chosenWeapon == Dagger) { player.HitChance = 60; player.Block = 20; player.Life = 12; player.MaxLife = 12; } if (chosenWeapon == MaceandShield) { player.HitChance = 35; player.Block = 30; player.Life = 30; player.MaxLife = 30; } //3. Create a loop for the room and monster bool exit = false; do { // 4. Create a room Console.WriteLine(GetRoom()); // 5. Create a monster Skeleton r1 = new Skeleton(); //uses the default ctor which sets some default values Skeleton r2 = new Skeleton("Skeleton Hero", 30, 35, 18, 18, 3, 7, "A hero from a forgotten realm, risen from his grave."); Boar r3 = new Boar(); Boar r4 = new Boar("Dire Boar", 20, 35, 20, 20, 2, 8, "A boar transformed by it's incredible rage, truly a dangerous foe"); KoboldLord r5 = new KoboldLord(); //all of our child monsters are of type mosnster so we can store them in an array Monster[] monsters = { r1, r1, r2, r3, r3, r4, r5 }; //randomly select a monster Random rand = new Random(); int randNbr = rand.Next(monsters.Length); Monster monster = monsters[randNbr]; Console.WriteLine("\nIn this room you find " + monster.Name); #region Menu Loop //TODO 6 Create a loop for menu of options bool reload = false; do { #region Menu Switch //7. Create a menu of options Console.WriteLine("\nPlease choose an action:\nA) Attack\nS) Sword Skill \nR) Run Away\nP) Player Info\nM) Monster Info\nH) Heal\nX) Exit\n"); //8. cathc the the choice ConsoleKey userChoice = Console.ReadKey(true).Key; //9. Clear the console Console.Clear(); //10. Build switch for user choice switch (userChoice) { case ConsoleKey.A: //11 handlle attack sequence if (agile == true) { Combat.DoAttack(player, monster); } Combat.DoBattle(player, monster); //12 handle player win if (monster.Life <= 0) { //monster is dead //could put in item drop, xp, or life gain playerLevel += 1; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\nWith the {0} Slain, you make your way 1 floor closer to the end.\n", monster.Name); Console.ResetColor(); player.Life = player.MaxLife; usedSwordSkill = false; usedHealing = false; reload = true; //breaks us out of the inner loop but no the outer, will allow the player to continue on their journey levelsBeat++; if (levelsBeat >= 1) { player.Life += 1; player.MaxLife += 1; player.Block += 1; player.HitChance += 1; } } break; case ConsoleKey.S: if (usedSwordSkill == true) { Console.WriteLine("You cannot use another sword skill during this combat."); } else { Console.WriteLine("You unleash a sword skill to do more damage"); player.EquippedWeapon.MinDamage += 10; player.EquippedWeapon.MaxDamage += 10; player.EquippedWeapon.BonusHitChance += 15; Combat.DoAttack(player, monster); player.EquippedWeapon.MinDamage -= 10; player.EquippedWeapon.MaxDamage -= 10; player.EquippedWeapon.BonusHitChance -= 15; usedSwordSkill = true; } if (monster.Life <= 0) { //monster is dead //could put in item drop, xp, or life gain playerLevel += 1; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\nWith the {0} Slain, you make your way 1 floor closer to the end.\n", monster.Name); Console.ResetColor(); player.Life = player.MaxLife; usedSwordSkill = false; usedHealing = false; reload = true; //breaks us out of the inner loop but no the outer, will allow the player to continue on their journey levelsBeat++; if (levelsBeat >= 1) { player.Life += 1; player.MaxLife += 1; player.Block += 1; player.HitChance += 1; } } break; case ConsoleKey.R: Console.WriteLine("So it seems your cowardly instincts have prevailed, how unfortunate."); //todo handle the free attack Console.WriteLine($"{monster.Name} attempts to attack as you run"); Combat.DoAttack(monster, player); Console.WriteLine(); usedSwordSkill = false; usedHealing = false; //14 exit inner loop and get a new room reload = true; break; case ConsoleKey.P: // 15. print out player info Console.WriteLine("Player info"); Console.WriteLine(playerName); Console.WriteLine(player); Console.WriteLine("You are level " + playerLevel); Console.WriteLine("Floors Cleared: " + levelsBeat); break; case ConsoleKey.M: //todo print out monster info Console.WriteLine("monster info"); Console.WriteLine(monster); break; case ConsoleKey.H: if (usedHealing == true) { Console.WriteLine("You cannot use another Healing Crystal during this combat."); } else { player.Life = player.MaxLife; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("You take out a Healing Crystal and use it"); Console.ResetColor(); usedHealing = true; } break; case ConsoleKey.X: case ConsoleKey.E: Console.WriteLine("After unequipping your weapon, you slowly end up rotting away in the Town of Beginnings"); exit = true; break; default: Console.WriteLine("learn to type bruh"); break; } #endregion //todo 17 check life before continuing if (player.Life <= 0) { Console.WriteLine("As your Health Bar is Depleted your body disappears and your vision goes black\a"); exit = true; //break out of both loops } if (levelsBeat == 100) { Console.WriteLine("As you defeat the final enemy a giant Game Cleared sign appears before you and you open your eyes to see the real world\a"); exit = true; //break out of both loops } if (levelsBeat == 20 && levelsBeat == 40 && levelsBeat == 60 && levelsBeat == 80) { r1.Life += 5; r1.MaxLife += 5; r1.Block += 5; r1.HitChance += 5; r1.MinDamage += 2; r1.MaxDamage += 4; r2.Life += 5; r2.MaxLife += 5; r2.Block += 5; r2.HitChance += 5; r2.MinDamage += 2; r2.MaxDamage += 4; r3.Life += 3; r3.MaxLife += 3; r3.Block += 7; r3.HitChance += 3; r3.MinDamage += 3; r3.MaxDamage += 5; r4.Life += 4; r4.MaxLife += 4; r4.Block += 8; r4.HitChance += 4; r4.MinDamage += 3; r4.MaxDamage += 5; r5.Life += 5; r5.MaxLife += 5; r5.Block += 10; r5.HitChance += 5; r5.MinDamage += 1; r5.MaxDamage += 3; } if (levelsBeat == 25 && chosenWeapon == LongSword) { Console.WriteLine("On the 25th floor you find a Dark Steel Longsword and Equip it.\n"); player.EquippedWeapon.MinDamage += 3; player.EquippedWeapon.MaxDamage += 4; player.EquippedWeapon.BonusHitChance += 5; } if (levelsBeat == 50 && chosenWeapon == LongSword) { Console.WriteLine("On the 50th floor you find a Holy Steel Longsword and Equip it.\n"); player.EquippedWeapon.MinDamage += 4; player.EquippedWeapon.MaxDamage += 4; player.EquippedWeapon.BonusHitChance += 5; } if (levelsBeat == 75 && chosenWeapon == LongSword) { Console.WriteLine("On the 75th floor you find the Elucidator and Equip it.\n"); player.EquippedWeapon.MinDamage += 4; player.EquippedWeapon.MaxDamage += 4; player.EquippedWeapon.BonusHitChance += 5; } if (levelsBeat == 25 && chosenWeapon == GreatSword) { Console.WriteLine("On the 25th floor you find a Dark Steel Greatsword and Equip it.\n"); player.EquippedWeapon.MinDamage += 3; player.EquippedWeapon.MaxDamage += 4; player.EquippedWeapon.BonusHitChance += 5; } if (levelsBeat == 50 && chosenWeapon == GreatSword) { Console.WriteLine("On the 50th floor you find a Holy Steel Greatsword and Equip it.\n"); player.EquippedWeapon.MinDamage += 4; player.EquippedWeapon.MaxDamage += 4; player.EquippedWeapon.BonusHitChance += 5; } if (levelsBeat == 75 && chosenWeapon == GreatSword) { Console.WriteLine("On the 75th floor you find the Doomblade and Equip it.\n"); player.EquippedWeapon.MinDamage += 4; player.EquippedWeapon.MaxDamage += 4; player.EquippedWeapon.BonusHitChance += 5; } if (levelsBeat == 25 && chosenWeapon == Dagger) { Console.WriteLine("On the 25th floor you find a Dark Steel Dagger and Equip it.\n"); player.EquippedWeapon.MinDamage += 3; player.EquippedWeapon.MaxDamage += 4; player.EquippedWeapon.BonusHitChance += 5; } if (levelsBeat == 50 && chosenWeapon == LongSword) { Console.WriteLine("On the 50th floor you find a Holy Steel Dagger and Equip it.\n"); player.EquippedWeapon.MinDamage += 4; player.EquippedWeapon.MaxDamage += 4; player.EquippedWeapon.BonusHitChance += 5; } if (levelsBeat == 75 && chosenWeapon == LongSword) { Console.WriteLine("On the 75th floor you find the Assassin's Dirk and Equip it.\n"); player.EquippedWeapon.MinDamage += 4; player.EquippedWeapon.MaxDamage += 4; player.EquippedWeapon.BonusHitChance += 5; } if (levelsBeat == 25 && chosenWeapon == MaceandShield) { Console.WriteLine("On the 25th floor you find a Dark Steel Mace and Shield and Equip it.\n"); player.EquippedWeapon.MinDamage += 3; player.EquippedWeapon.MaxDamage += 4; player.EquippedWeapon.BonusHitChance += 5; } if (levelsBeat == 50 && chosenWeapon == MaceandShield) { Console.WriteLine("On the 50th floor you find a Holy Steel Mace and Shield and Equip it.\n"); player.EquippedWeapon.MinDamage += 4; player.EquippedWeapon.MaxDamage += 4; player.EquippedWeapon.BonusHitChance += 5; } if (levelsBeat == 75 && chosenWeapon == MaceandShield) { Console.WriteLine("On the 75th floor you find the Demon's Cudgel and Shield and Equip them.\n"); player.EquippedWeapon.MinDamage += 4; player.EquippedWeapon.MaxDamage += 4; player.EquippedWeapon.BonusHitChance += 5; } } while (!exit && !reload); #endregion } while (!exit); //while exit is false it will loop Console.WriteLine("You cleared " + levelsBeat + " floor" + (levelsBeat == 1 ? "." : "s.")); }
static void Main(string[] args) { //This is the program that will control the flow of the overall program (the experience of the user). All classes will be build in separate files and referred to in this program to allow us to use instances of the objects. Console.Title = "Forest Walker"; SpeechSynthesizer speech = new SpeechSynthesizer(); speech.SetOutputToDefaultAudioDevice(); Console.WriteLine("\n-=-=-= Welcome to ForestWalker =-=-=-\n" + @" __ .d$$b .' TO$;\ / : TP._; / _.; :Tb| / / ;j$j _.-' d$$$$ .' .. d$$$$; / / P' d$$$$P. |\ / ' .d$$$P' |\^'l .' `T$P^''''' : ._.' _.' ; `-.- '.-'-' ._. _.-'.-'' `.-' _____ ._ .-' - (.g$$$$$$$b. .' '' ^^ T$$$P ^) .(: _ / -' /.' /:/; ._.'-'`-' ')/ /;/; `-.- '..--'' ' / / ; .-' ..--'' -' : ..--''--.- ' (\ .-(\ ..--'' `-\(\/;` _. : ;`- :\ ; AWWWWOOOOOO"); var wolfHowl = new System.Media.SoundPlayer(); wolfHowl.SoundLocation = @"C:\Users\Student\Documents\Visual Studio 2017\Projects\03_CSF2\CSF2\DungeonApp\Dungeon\Resources\wolfHowl01.wav"; wolfHowl.PlaySync(); speech.Speak("Welcome to Forest Walker."); Console.WriteLine("\tWhat is your name, Traveler?"); string playerName = Console.ReadLine(); Console.Clear(); //Keep a running total variable for the user's score int score = 0; int monstersKilled = 0; Console.WriteLine("\tWelcome, {0}. You are about to embark on a spiritual journey through the North American forest.\nAn animal can be chosen to aid you on your journey.", playerName); Console.WriteLine(); //TODO 1. Create a Weapon and a Player Weapon dagger = new Weapon(1, 8, "Rusty Dagger", 8, false, "Sword", false, 10, false); Weapon bow = new Weapon(1, 8, "Short Bow", 2, false, "Bow", true, 15, true); Weapon club = new Weapon(5, 8, "Crude Club", 9, false, "Club", false, 0, false); Player player = new Player(playerName, 70, 2, 60, 60, Race.Human, bow); //Console.WriteLine(sword); - Commented out after testing ToString() return //TODO create a loop for finding animal spirit guides (one land one air?) //TODO create companions to choose from Companion wolf = new Companion("Lobo", 12, 7, 65, 20, 40, 40, Animal.Wolf, null, "A ferocious wolf with a powerful attack."); Companion bear = new Companion("Ben", 7, 4, 60, 40, 85, 85, Animal.Bear, null, "A great bear with a large health pool."); Companion deer = new Companion("Elliot", 5, 1, 50, 30, 30, 30, Animal.Deer, null, "A swift deer, he can help you escape if things look rough."); Companion bison = new Companion("Strongheart", 6, 2, 60, 60, 100, 100, Animal.Bison, null, "A mighty bison, low attack but his health pool is massive."); Companion horse = new Companion("Beau", 4, 1, 30, 90, 50, 50, Animal.Horse, null, "A sturdy steed, he is fantastic at blocking enemy attacks."); Companion mouse = new Companion("Ralph", 0, 0, 0, 100, 5, 5, Animal.Mouse, null, "A tiny mouse with an uncanny ability to dodge attacks and distract the enemy."); Companion raccoon = new Companion("Eddie", 3, 2, 90, 10, 20, 20, Animal.Raccoon, null, "A cheeky raccoon with high accuracy and a low block chance."); Companion skunk = new Companion("Pepe", 4, 2, 55, 40, 20, 20, Animal.Skunk, null, "This skunk is not a powerhouse but he can sometimes stink the enemy into submission."); Companion[] companions = { wolf, bear, deer, bison, horse, mouse, raccoon, skunk }; int companionChoice; repeat : Console.Write("\tEight animals now appear before you. In the stillness, you sense a purposeful patience in their demeanor.\n Some of these animals you may have caught glimpses or signs of in your journey earlier. Others you have not\n seen or heard until now. They all can aid you in some way, but not all of them will necessarily follow you.\n That is why you must choose your companions wisely.\n\nDo you understand? Y/N:"); tryAgain : string response = Console.ReadLine().ToUpper(); if (response == "Y" || response == "YES") { } else if (response == "N" || response == "NO") { Console.WriteLine("Then I will repeat the instructions. Please read carefully."); System.Threading.Thread.Sleep(3000); Console.Clear(); goto repeat; } else { Console.Write("Invalid input. Did you understand the instructions? Y/N: "); goto tryAgain; } chooseAnimal : Console.WriteLine("Choose your companion:\n" + "1) Lobo - wolf\n" + "2) Ben - bear\n" + "3) Elliott - deer\n" + "4) Strongheart - bison\n" + "5) Beau - horse\n" + "6) Ralph - mouse\n" + "7) Eddie - raccoon\n" + "8) Pepe - skunk\n"); string userNum = Console.ReadLine(); if (userNum == "1" || userNum == "2" || userNum == "3" || userNum == "4" || userNum == "5" || userNum == "6" || userNum == "7" || userNum == "8") { Console.Clear(); companionChoice = int.Parse(userNum); companionChoice--; Character companion = companions[companionChoice]; Console.WriteLine(companion); confirmChoice : Console.Write($"\nAre you sure you want to choose {companion.Name} as your companion?\nY/N:"); string confirm = Console.ReadLine().ToUpper(); if (confirm == "Y" || confirm == "YES") { Console.Clear(); } else if (confirm == "N" || confirm == "NO") { Console.Clear(); goto chooseAnimal; } else { Console.Clear(); Console.WriteLine("I need a yes or no answer."); goto confirmChoice; } } else { Console.WriteLine("Improper input. Please enter a value 1-8 to choose your companion."); goto chooseAnimal; } //TODONE 2. Create a loop for the room and monster bool exit = false; do { //TODO 3. Call a new room Console.WriteLine(GetRoom()); //TODONE 4. Create a monster Dragon d1 = new Dragon(); Dragon d2 = new Dragon("Toothless", 25, 25, 40, 10, 1, 12, "This is one bad dragon!", true); Orc o1 = new Orc(); Orc o2 = new Orc("gruk", 30, 30, 45, 20, 5, 7, "This brutish Orc is uglier than your average Orc, which is saying something!", true); Specter s1 = new Specter(); Specter s2 = new Specter("Bloody Bob", 20, 20, 50, 30, 2, 9, "A bloodthirsty specter darts toward you in a blind rage.", true); //Since Rabbit and other child classes are children of monster, all can be placed into an array of Monster objects Monster[] monsters = { d1, d1, d2, o1, o1, o1, o1, o1, o2, o2, s1, s1, s2 }; //Randomly select a monster from the array Random rand = new Random(); int randomNumber = rand.Next(monsters.Length); Monster monster = monsters[randomNumber]; Console.WriteLine("A monster appears! " + monster.Name); //TODO 5. Create a loop for the menu bool reload = false; do { //TODONE 6. Create the menu #region MENU Console.WriteLine("\n\nPlease choose an Action:\n" + "A) Attack\n" + "R) Run Away\n" + "P) Player Info\n" + "M) Monster Info\n" + "C) Companion Info\n" + "X) Exit\n\n" + $"Score: {score}\n\n"); #endregion //TODONE 7. Get User Choice #region UserChoice ConsoleKey userChoice = Console.ReadKey(true).Key; #endregion //TODONE 8. Clear the console after we get input from the user Console.Clear(); //TODO need to make program work without statement below Companion companion = companions[companionChoice]; //TODO 9. Build out the switch for userChoice #region Game Experience - Switch switch (userChoice) { case ConsoleKey.A: Console.WriteLine("Attack\n"); //TODO 10. Build attack logic and place here Combat.DoBattle(player, companion, monster); if (monster.Life <= 0) { //it's dead - you could put some logic here to have player get items, get life back , or something similar due to defeating the monster. Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\nYou killed {0}! The spirit you freed from the monster restores some of your health.\n", monster.Name); Console.ResetColor(); player.Life += monster.MaxLife / 4; score += monster.MaxLife - (player.MaxLife - player.Life); monstersKilled++; reload = true; //get a new room and monster if (monstersKilled < 10) { } else { Console.WriteLine($"" + $"\tAs you deal the final blow to {monster.Name}, {companion.Name} seems to leap in\n triumph at your accomplishment. The monsters have been vanquished, and their tortured\n souls are now free. As you meet {companion.Name}'s eyes, a great sense of confidence\n and strength rises up within you. You know you made the right choice, and that the\n {companion.Animal} is truly your animal guide." + $"\n\n\tYou snap awake in your bed, and glance at the alarm clock on the nightstand.\n It's 3:33 a.m. The dream of the forest was so vivid, so incredibly real. You close your eyes, and still can clearly see the approving gaze\n of {companion.Name}. You\n realize that image will be burned into your memory, and any time you need help you'll\n be able to call upon the spirit of the {companion.Animal} to guide you in the waking world. You roll over and drift back to sleep, and as you drift away a calming sense\n of security washes over you. All is well.\n\n" + $"Final score: {score}\n" + $"Monsters killed: {monstersKilled}"); exit = true; reload = false; } } break; case ConsoleKey.R: Console.WriteLine("Run for your life!"); //TODO 11. Build run away logic Console.WriteLine($"{monster.Name} attacks you as you run!\n"); Combat.DoAttack(monster, player); //load a new room and monster reload = true; break; case ConsoleKey.P: Console.WriteLine("Player Info"); //TODONE 12. Add Player Info Console.WriteLine(player); break; case ConsoleKey.M: Console.WriteLine("Monster Info"); //TODONE 13. Add Monster Info Console.WriteLine(monster); break; case ConsoleKey.C: Console.WriteLine("Companion Info"); Console.WriteLine(companion); break; case ConsoleKey.X: case ConsoleKey.E: Console.WriteLine("The forest can break even the most battle-hardened. Strengthen your resolve before entering these woods again."); exit = true; break; default: Console.WriteLine("That input was not recognized. Please choose a valid option.\n"); break; } #endregion if (player.Life <= 0) { Console.WriteLine($"" + $"\tAs the light fades, you turn to lock eyes with {companion.Name}. He looks sad,\n but stoic as your life fades away. You both gave your best. Perhaps the\n {companion.Animal} was not your proper animal guide." + $"\n\n\tYou snap awake in your bed, and glance at the alarm clock on the nightstand.\n It's 3:33 a.m. The dream of the forest was so vivid, so incredibly real. You lift your\n shirt and check your body for the wounds that just claimed you, just to make sure\n you aren't still bleeding out. You're fine, of course. Even still, the image of{monster.Name}\n hovering over you, the look in {companion.Name}'s eyes as you drew\n your last breath... You can feel the image is going to stick with you for quite some\n time." + $"\n\nMaybe you'll be able to settle back down to sleep, and one day again become the Forest Walker.\n\n" + $"Final score: {score}\n" + $"Monsters killed: {monstersKilled}"); exit = true; } //TODO 14. Handle Player Life } while (!reload && !exit); } while (!exit);//while exit is NOT TRUE keep in the loop }//end Main()