public int StartGame() { Console.WriteLine(Player.Story + "\n"); //flags that will determine direction of the game bool defeatedOneVillian = false; //flag to check if one villian is defeated to determine if hero meets ally bool phaseWon = false; //phase will be won when hero beats two villians on the two planets bool quitGame = false; //game will quit if set to true bool playerDead = false; //will return to the main program and give the player an option to play again bool meetAlly = false; //flag to check if hero meet ally, effects the display menu options do { //checking to see if hero as met ally, will not meet ally until one planet is won if (!meetAlly && defeatedOneVillian) { Console.ForegroundColor = ConsoleColor.Cyan; System.Threading.Thread.Sleep(800); Console.WriteLine(Ally.Story + "\n"); Console.ResetColor(); meetAlly = true; } System.Threading.Thread.Sleep(800); DisplayMenuOptions.DisplayMainOptions(PlanetsInGame, Ally, meetAlly); string userInputChoice = Console.ReadLine(); int userChoice; if (Int32.TryParse(userInputChoice, out userChoice)) { if (userChoice < 1 || userChoice > PlanetsInGame.Count) { System.Threading.Thread.Sleep(500); Console.WriteLine("Invalid Choice"); } else { //player go to planet and fight villian occupying planet int result = PlayerActions.VisitPlanet(Player, PlanetsInGame[userChoice - 1].VillianOccupyingPlanet); //switch based on what happend while visiting planet switch (result) { //if player defeats villian case 0: //if first villian defeated in the phase of the game if (!defeatedOneVillian) { defeatedOneVillian = true; PlanetsInGame.RemoveAt(userChoice - 1); } else { phaseWon = true; } break; //if villian defeats hero case 1: playerDead = true; break; //player retreats default: Console.ForegroundColor = ConsoleColor.Blue; System.Threading.Thread.Sleep(500); Console.WriteLine($"\nYou have retreated from planet {PlanetsInGame[userChoice - 1].Name}.\n"); Console.ResetColor(); break; } } } else { if (userInputChoice == "B" || userInputChoice == "b") { if (meetAlly) { PlayerActions.BuyUpgrades(Player, FighterType, Ally); } else { System.Threading.Thread.Sleep(500); Console.WriteLine("Invalid Choice"); } } else if (userInputChoice == "Q" || userInputChoice == "q") { quitGame = true; } else { System.Threading.Thread.Sleep(500); Console.WriteLine("Invalid Choice"); } } } while (!phaseWon && !quitGame && !playerDead); if (phaseWon) { Console.ForegroundColor = ConsoleColor.DarkYellow; System.Threading.Thread.Sleep(800); Console.WriteLine("\nHondo: It's been fun. Congratulations on your battles won. I must depart you and seek my new operation in the " + "outer rim. Good luck to you!\n"); Console.ForegroundColor = ConsoleColor.Blue; System.Threading.Thread.Sleep(800); System.Threading.Thread.Sleep(800); Console.WriteLine("Congratutions! You have conquered this phase of the game. Great work and may the force be with you!"); Console.WriteLine("Your life has increased by 50 points"); Console.WriteLine("Your max life has increased by 20 points"); Console.WriteLine("Your armour has increased by 20 points"); Console.WriteLine("Your max hit damage has increased by 20 points"); Console.WriteLine("You have been awarded 500 credits"); Console.WriteLine("500 points have been added to your score\n"); Console.ResetColor(); PlayerUpgrades.AddMaxHealth(Player, 20); PlayerUpgrades.AddHealth(Player, 50); PlayerUpgrades.AddArmour(Player, 20); PlayerUpgrades.AddMaxHitDamage(Player, 20); PlayerUpgrades.AddCredits(Player, 500); PlayerUpgrades.AddScore(Player, 500); return(0); } else if (playerDead) { return(1); } else //player quit game { return(2); } }
public int StartGame() { bool defeatedTwoVillians = false; //flag to check if first two villians are defeated to determine if hero is allowed to go to last planet in phase bool phaseWon = false; //phase will be won when hero beats two villians on the two planets bool quitGame = false; //game will quit if set to true bool playerDead = false; //will return to the main program and give the player an option to play again //introducing the second phase of the game Console.ForegroundColor = ConsoleColor.DarkYellow; System.Threading.Thread.Sleep(800); Console.WriteLine(Ally.Story + "\n"); Console.ResetColor(); //starting second phase of game do { System.Threading.Thread.Sleep(500); DisplayMenuOptions.DisplayMainOptions(PlanetsInGame, Ally, true); string userInputChoice = Console.ReadLine(); int userChoice; if (Int32.TryParse(userInputChoice, out userChoice)) { if (userChoice < 1 || userChoice > PlanetsInGame.Count) { System.Threading.Thread.Sleep(500); Console.WriteLine("Invalid Choice"); } else { //play go to planet and fight villian occupying planet int result = PlayerActions.VisitPlanet(Player, PlanetsInGame[userChoice - 1].VillianOccupyingPlanet); //switch based on what happend while visiting planet switch (result) { case 0: //check to see if hero defeated last villian in phase if (defeatedTwoVillians) { phaseWon = true; } else { PlanetsInGame.RemoveAt(userChoice - 1); //if two planets are defeated, unlock last planet if (!PlanetsInGame.Any()) { Console.ForegroundColor = ConsoleColor.Blue; System.Threading.Thread.Sleep(500); Console.WriteLine($"\nHelp liberate {(FighterType == HeroType.MANDALORIAN ? "your home planet Mandalore" : "the planet Manadlore")} from the clutches of " + $"Darth Maul.\n"); Console.ResetColor(); PlanetsInGame.Add(Planets.GetMandalore()); defeatedTwoVillians = true; } } break; //if villian defeats hero case 1: playerDead = true; break; //player retreats default: Console.ForegroundColor = ConsoleColor.Blue; System.Threading.Thread.Sleep(500); Console.WriteLine($"\nYou have retreated from planet {PlanetsInGame[userChoice - 1].Name}.\n"); Console.ResetColor(); break; } } } else { //user selects buy items if (userInputChoice == "B" || userInputChoice == "b") { PlayerActions.BuyUpgrades(Player, FighterType, Ally); } //user quits game else if (userInputChoice == "Q" || userInputChoice == "q") { quitGame = true; } else { System.Threading.Thread.Sleep(500); Console.WriteLine("Invalid Choice"); } } } while (!phaseWon && !quitGame && !playerDead); //if phase won a mandalorian will automatically get the darksaber as a weapon if (phaseWon) { if (FighterType == HeroType.MANDALORIAN) { Console.ForegroundColor = ConsoleColor.DarkYellow; System.Threading.Thread.Sleep(500); Console.WriteLine("\nBo-Katan: You have liberated our home planet and won the darksaber from Darth Maul. You are now the Mandalore, ruler of our planet. All of the Clans of " + "Mandalore will now pledge their allegiance to you.\n"); Console.ResetColor(); Weapon darksaber = GameWeaponsList.getDarksaber(); Player.WeaponInventory.Add(darksaber); //adding darksaber to inventory //giving player an option to equip darksaber bool isValidWeaponChoice = false; do { Console.ForegroundColor = ConsoleColor.Green; System.Threading.Thread.Sleep(500); Console.Write("Do you want to equipped the Darksaber? Y/N"); Console.ResetColor(); string choice = Console.ReadLine(); switch (choice) { case "Y": case "y": Player.EquippedWeapon = darksaber; Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("\nYou have now equipped the DarkSaber, the most powerful Mandalorian weapon in the galaxy!\n"); Console.ResetColor(); isValidWeaponChoice = true; break; case "N": case "n": Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("The Darksaber will be in your weapons inventory in case you change your mind."); Console.ResetColor(); isValidWeaponChoice = true; break; default: Console.WriteLine("Invalid choice!"); break; } } while (!isValidWeaponChoice); } else { Console.ForegroundColor = ConsoleColor.DarkYellow; System.Threading.Thread.Sleep(800); Console.WriteLine("Bo-Katan: Thank you Jedi for helping liberating Madalore. All clans of Mandalore" + "are forever in your debt."); Console.ResetColor(); } Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("Congratutions! You have conquered this phase of the game. Great work and may the force be with you!"); Console.WriteLine("Your life has increased by 70 points"); Console.WriteLine("Your max life has increased by 30 points"); Console.WriteLine("Your armour has increased by 50 points"); Console.WriteLine("Your max hit damage has increased by 30 points"); Console.WriteLine("You have been awarded 1000 credits"); Console.WriteLine("1000 points have been added to your score\n"); Console.ResetColor(); PlayerUpgrades.AddMaxHealth(Player, 30); PlayerUpgrades.AddHealth(Player, 70); PlayerUpgrades.AddArmour(Player, 50); PlayerUpgrades.AddMaxHitDamage(Player, 30); PlayerUpgrades.AddCredits(Player, 1000); PlayerUpgrades.AddScore(Player, 1000); return(0); } else if (playerDead) { return(1); } else //player quit game { return(2); } }
//method when player visits ally looking for upgrades public static void BuyUpgrades(Hero player, HeroType fighterType, Character ally) { System.Threading.Thread.Sleep(500); Console.WriteLine($"\n\n{ally.Name}: Hello {player.Name}. Here are some items that will help you on your journey.\n"); System.Threading.Thread.Sleep(500); Console.WriteLine(player + "\n"); bool exit = false; do { System.Threading.Thread.Sleep(500); DisplayMenuOptions.DisplayItemsToBuy(fighterType); string userChoiceInput = Console.ReadLine(); int userChoice; if (Int32.TryParse(userChoiceInput, out userChoice)) { switch (userChoice) { //user buys health case 1: if (player.Credits >= 100) { PlayerUpgrades.AddHealth(player, 20); player.Credits -= 100; Console.ForegroundColor = ConsoleColor.Blue; System.Threading.Thread.Sleep(500); Console.WriteLine($"\n\nYou have purchased 20 points of health\n"); Console.ResetColor(); Console.WriteLine(player + "\n"); } else { System.Threading.Thread.Sleep(500); Console.WriteLine("You do not have enought credits to purchase this item"); } break; //user buy armour case 2: if (player.Credits >= 200) { PlayerUpgrades.AddArmour(player, 20); player.Credits -= 200; Console.ForegroundColor = ConsoleColor.Blue; System.Threading.Thread.Sleep(500); Console.WriteLine($"\n\nYou have purchased 20 points of armour\n"); Console.ResetColor(); Console.WriteLine(player + "\n"); } else { System.Threading.Thread.Sleep(500); Console.WriteLine("You do not have enought credits to purchase this item"); } break; //user buys weapons upgrades case 3: bool exitWeaponsUpgrade = false; do { System.Threading.Thread.Sleep(500); DisplayMenuOptions.DisplayWeaponToUpgrade(player); string userUpgradeOption = Console.ReadLine(); int upgradeOption; if (Int32.TryParse(userUpgradeOption, out upgradeOption)) { switch (upgradeOption) { //user buys weapon case 1: Weapon weaponToBuy = player.WeaponUpgrades.Peek(); if (player.Credits >= weaponToBuy.Cost) { player.EquippedWeapon = weaponToBuy; player.WeaponInventory.Add(player.WeaponUpgrades.Dequeue()); player.Credits -= weaponToBuy.Cost; Console.ForegroundColor = ConsoleColor.Blue; System.Threading.Thread.Sleep(800); Console.WriteLine($"\n\nYou have purchased {player.EquippedWeapon}!\n"); Console.ResetColor(); Console.WriteLine(player + "\n"); } //not enough credits to buy else { System.Threading.Thread.Sleep(500); Console.WriteLine("You do not have enough credits to purchase this item."); } break; //view weapon stats case 2: Weapon weaponToDisplay = player.WeaponUpgrades.Peek(); System.Threading.Thread.Sleep(500); DisplayMenuOptions.DisplayWeaponStats(weaponToDisplay); break; //user quits case 3: exitWeaponsUpgrade = true; break; //invalid int default: System.Threading.Thread.Sleep(500); Console.WriteLine("Invalid option"); break; } } else { System.Threading.Thread.Sleep(500); Console.WriteLine("Invalid option"); } } while (!exitWeaponsUpgrade); break; //user quits case 4: exit = true; break; //invalid int default: System.Threading.Thread.Sleep(500); Console.WriteLine("Invalid option"); break; } } else { System.Threading.Thread.Sleep(500); Console.WriteLine("Invalid option"); } } while (!exit); Console.WriteLine(player + "\n"); }
//will return 0 if player wins, 1 if villian wins and 2 if player retreats public static int VisitPlanet(Hero player, Villian villian) { bool playerWins = false; bool villianWins = false; bool retreat = false; Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("\n" + villian.Story); Console.ResetColor(); do { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n" + player); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\n" + villian + "\n"); Console.ResetColor(); //display options DisplayMenuOptions.DisplayFightOptions(); string userInputOption = Console.ReadLine(); int userOption; if (Int32.TryParse(userInputOption, out userOption)) { if (userOption == 1 || userOption == 2) { if (userOption == 1) //attack { //hero attacts villian int villianDamage = player.Attack(villian); if (villian.Life > 0) //if villian isn't defeated { Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine($"\n{villian.Name} was struck by {player.Name} for {villianDamage} points."); Console.ResetColor(); } else //if villian is defeated { System.Threading.Thread.Sleep(800); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine($"\nYou have defeated {villian.Name}!"); Console.WriteLine("You have been awarded 10 points of health, 10 points of max life and 10 points of armour and 300 credits!\n"); Console.ResetColor(); PlayerUpgrades.AddHealth(player, 10); PlayerUpgrades.AddMaxHealth(player, 10); PlayerUpgrades.AddCredits(player, 300); PlayerUpgrades.AddArmour(player, 10); PlayerUpgrades.AddScore(player, 500); playerWins = true; } //villian attacts hero if villian hasn't been defeated if (!playerWins) { int heroDamage = villian.Attack(player); if (player.Life > 0) { System.Threading.Thread.Sleep(800); Console.ForegroundColor = ConsoleColor.DarkMagenta; Console.WriteLine($"{player.Name} was struck by {villian.Name} for {heroDamage} points."); Console.ResetColor(); } else { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine($"You have been defeated by {villian.Name}\n"); Console.ResetColor(); villianWins = true; } } } else //player retreats { retreat = true; } } else { Console.WriteLine("Invalid choice!"); } } else { Console.WriteLine("Invalid choice!"); } } while (!playerWins && !villianWins && !retreat); //return values based on whats true if (playerWins) { return(0); } else if (villianWins) { return(1); } else { return(2); } }
public int StartGame() { bool defeatedOneVillain = false; //flag to see if one villian has been deafeated bool phaseWon = false; //phase will be won when hero beats two villians on the two planets bool quitGame = false; //game will quit if set to true bool playerDead = false; //will return to the main program and give the player an option to play again //introducing the second phase of the game Console.ForegroundColor = ConsoleColor.DarkYellow; System.Threading.Thread.Sleep(800); Console.WriteLine(Ally.Story + "\n"); Console.ResetColor(); //starting third phase of the game do { System.Threading.Thread.Sleep(500); DisplayMenuOptions.DisplayMainOptions(PlanetsInGame, Ally, true); string userInputChoice = Console.ReadLine(); int userChoice; if (Int32.TryParse(userInputChoice, out userChoice)) { if (userChoice < 1 || userChoice > PlanetsInGame.Count) { System.Threading.Thread.Sleep(500); Console.WriteLine("Invalid Choice"); } else { //go to planet and fight villain occupying planet int result = PlayerActions.VisitPlanet(Player, PlanetsInGame[userChoice - 1].VillianOccupyingPlanet); //switch based on what happend while visiting planet switch (result) { case 0: //check to seee if hero defeated one villian if (defeatedOneVillain) { phaseWon = true; } else { PlanetsInGame.RemoveAt(userChoice - 1); defeatedOneVillain = true; } break; //if villian defeats hero case 1: playerDead = true; break; //player retreats default: Console.ForegroundColor = ConsoleColor.Blue; System.Threading.Thread.Sleep(500); Console.WriteLine($"\nYou have retreated from planet {PlanetsInGame[userChoice - 1].Name}.\n"); Console.ResetColor(); break; } } } else { //user selecs buy items if (userInputChoice == "B" || userInputChoice == "b") { PlayerActions.BuyUpgrades(Player, FighterType, Ally); } else if (userInputChoice == "Q" || userInputChoice == "b") { quitGame = true; } else { System.Threading.Thread.Sleep(500); Console.WriteLine("Ivalid Choice"); } } } while (!phaseWon && !quitGame && !playerDead); if (phaseWon) { Console.ForegroundColor = ConsoleColor.DarkYellow; System.Threading.Thread.Sleep(800); Console.WriteLine($"\nBoba Fett: Congraulations kid...You are the biggest hero in the galaxy. The {(FighterType == HeroType.JEDI? "Jedi" : "Mandalorians")} should be proud!\n"); Console.ForegroundColor = ConsoleColor.Blue; System.Threading.Thread.Sleep(800); System.Threading.Thread.Sleep(800); Console.WriteLine("Congratulations. You have defeated the most evil and vile scum of the galaxy and have returned peace to everyone!"); Console.WriteLine("Your life has increased by 50 points"); Console.WriteLine("Your max life has increased by 20 points"); Console.WriteLine("Your armour has increased by 20 points"); Console.WriteLine("Your max hit damage has increased by 20 points"); Console.WriteLine("You have been awarded 500 credits"); Console.WriteLine("500 points have been added to your score\n"); Console.ResetColor(); PlayerUpgrades.AddMaxHealth(Player, 20); PlayerUpgrades.AddHealth(Player, 50); PlayerUpgrades.AddArmour(Player, 20); PlayerUpgrades.AddMaxHitDamage(Player, 20); PlayerUpgrades.AddCredits(Player, 500); PlayerUpgrades.AddScore(Player, 500); return(0); } else if (playerDead) { return(1); } else //player quit game { return(2); } }