//Displays player and enemy stats before the match. May be useful in the future for handling loadouts, selecting team mates, etc public static void PreCombat(Soldier player, Sectoid enemy) { Console.WriteLine("You are {0}, a {1} with {2}HP, armed with a {3} that does {4}-{5} damage.", player.Name, player.Class, player.HPMax, player.WeaponEquipped.Name, player.WeaponEquipped.DmgMin, player.WeaponEquipped.DmgMax); Console.WriteLine("Your opponent is a {0} with {1}HP, armed with a {2} that does {3}-{4} damage. \n", enemy.Class, enemy.HPMax, enemy.WeaponEquipped.Name, enemy.WeaponEquipped.DmgMin, enemy.WeaponEquipped.DmgMax); Console.WriteLine("Let battle commence! Press enter to continue.\n"); Console.ReadLine(); Console.Clear(); }
//Combat continues until there is only one survivor, detected and returned by CheckForSurvivors function. The survivor will be announced in PostCombat. public static Entity Combat(Soldier player, Sectoid enemy) { Entity survivor = null; while (survivor == null) { Console.WriteLine("{0} the {1} - {2}/{3}HP", player.Name, player.Class, player.HPCurrent, player.HPMax); Console.WriteLine("Enemy {0} - {1}/{2}HP\n", enemy.Name, enemy.HPCurrent, enemy.HPMax); Console.WriteLine("Press 1 to Attack"); string Choice = ""; while (Choice == "") { Choice = Console.ReadLine(); switch (Choice) { case "1": bool criticalHit; criticalHit = Attack(player, enemy); survivor = CheckForSurvivors(enemy, player, criticalHit); if (!(survivor == null)) { break; } criticalHit = Attack(enemy, player); survivor = CheckForSurvivors(player, enemy, criticalHit); Console.Write("Press enter to continue."); Console.ReadLine(); Console.Clear(); break; default: //This screenclear might need adjustment. Console.WriteLine("Invalid input. Press 1 to Attack."); //Console.ReadLine(); //Console.Clear(); Choice = ""; break; } } } return(survivor); }
static void Main(string[] args) { Soldier player = new Soldier(); Inventory playerInventory = new Inventory(); Shop ItemShop = new Shop(); if (File.Exists(State.SaveLocation(player))) { player = (Soldier)State.Load(player); playerInventory = (Inventory)State.Load(playerInventory); } string nextFunction = "Start"; while (nextFunction != "Exit") { switch (nextFunction) { case "Start": { nextFunction = Start(player); break; } case "CreateSoldier": { nextFunction = CreateSoldier(player, playerInventory); break; } case "Mission": { Entity winner; Sectoid enemy = new Sectoid(); Mission.PreCombat(player, enemy); winner = Mission.Combat(player, enemy); Mission.PostCombat(winner, player, playerInventory); nextFunction = "OptionSelect"; break; } case "OptionSelect": { nextFunction = OptionSelect(player); break; } case "Shop": { nextFunction = Shop.GoShop(Shop.ShopInventory, player, playerInventory); break; } case "Exit": { break; } default: { Console.Write("This should never run. Something has gone wrong. Press enter to end the session."); Console.ReadLine(); System.Environment.Exit(0); break; } } } System.Environment.Exit(0); }