public Item Fight(Gladiator Player, Enemy Opponent) { if (Player.GetHealth() > 0) { int dmg = Player.Attack(Opponent); Draw.ShowEnemyStats(Opponent, true, dmg); } if (Opponent.health > 0) { int enemyDmg = Opponent.Attack(Player); Draw.ShowPlayerStats(Player, true, enemyDmg, Opponent); } else { credit.BattleCredit(Player, Program.Round); DefeatedOpponents.Add(Opponent.name); return(Opponent.DropItem()); } if (Player.GetHealth() <= 0) { String textFile = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".txt"; using (StreamWriter writer = new StreamWriter(textFile, true)) { foreach (Object opponent in DefeatedOpponents) { writer.WriteLine(opponent); } writer.WriteLine(Player.credits + " credits"); } } return(null); }
public static void ShowPlayerStats(Gladiator gladiator, Boolean didDmg, int dmg, Enemy enemy) { prepCursor(2, HEIGHT - 1); Console.Write(" ".PadRight(gladiatorDrawWidth)); Console.ForegroundColor = ConsoleColor.Green; String drawText = gladiator.name + " [HP: " + gladiator.GetHealth() + " Attack: " + gladiator.GetStrength() + "]"; gladiatorDrawWidth = drawText.Length; prepCursor(2, HEIGHT - 1); Console.Write(drawText); Console.ForegroundColor = ConsoleColor.White; finishedCursor(); if (didDmg) { ConsoleColor[] colors = { ConsoleColor.White, ConsoleColor.White, ConsoleColor.White, ConsoleColor.White, ConsoleColor.Gray, ConsoleColor.DarkGray, ConsoleColor.Black }; for (int i = 0; i < colors.Length; i++) { EnemyAttack(-dmg, colors[i], enemy); System.Threading.Thread.Sleep(250); } } }
static void Main(string[] args) { String name; Draw.initWindowSettings(); Draw.InitWindow(); Draw.displayStartup(); Draw.ShowText("Greetings Gladiator!", 1); name = Draw.ShowTextInput("What is your name?: ", 2); Draw.ShowText("Huh... Please step into the arena " + name, 3); Gladiator Player = new Gladiator(name); Draw.ShowPlayerStats(Player, false, 0, null); Draw.ShowTextPressEnter("< Press Enter to step into the arena >", 5); Draw.ShowText("You step into the arena.", 5); Logic logic = new Logic(); Enemy Opponent; Item droppedItem = null; do { Round++; Opponent = new Enemy(logic.GetName(), Round); Draw.ShowEnemyStats(Opponent, false, 0); if (Round != 1) { Draw.centerText(Opponent.name + " approaches you.", 6); Draw.centerText("", 7); Draw.centerText("< Press Enter to begin fight >", 8); Draw.ShowTextPressEnter(" ", 9); } else { Draw.ShowText(Opponent.name + " approaches you.", 6); Draw.ShowText("< Press Enter to begin fight >", 8); Draw.ShowTextPressEnter(" ", 9); } Draw.Clear(); Draw.InitWindow(); Draw.ShowRound(Round); while (Opponent.health > 0 && Player.GetHealth() > 0) { Draw.ShowPlayerStats(Player, false, 0, null); Draw.ShowEnemyStats(Opponent, false, 0); Draw.FightOptions(); handleInput(Player, Opponent); Draw.ClearFightOptions(); droppedItem = logic.Fight(Player, Opponent); } if (Player.GetHealth() <= 0) { break; } Player.RemoveActivePotion(); Draw.Clear(); Draw.InitWindow(); Draw.ShowRound(Round); Draw.ShowPlayerStats(Player, false, 0, null); Draw.ShowEnemyStats(Opponent, false, 0); Draw.centerText("You defeated " + Opponent.name + "!", 5); if (droppedItem != null) { Draw.centerText(Opponent.name + " dropped " + droppedItem.Name + " [" + droppedItem.Rarity + "] " + "and " + logic.GetCredit().latestDrop + " Credits", 6); } Draw.centerText("< Press Enter to continue >", 7); Draw.ShowTextPressEnter(" ", 8); Player.inventory.AddToInventory(droppedItem); } while (Player.GetHealth() > 0); Draw.Clear(); Draw.centerText(" _____ __ __ ______ ______ ________ _____ ", Draw.HEIGHT / 2 - 4); Draw.centerText(" / ____| /\\ | \\/ | ____| / __ \\ \\ / / ____| __ \\ ", Draw.HEIGHT / 2 - 3); Draw.centerText("| | __ / \\ | \\ / | |__ | | | \\ \\ / /| |__ | |__) |", Draw.HEIGHT / 2 - 2); Draw.centerText("| | |_ | / /\\ \\ | |\\/| | __| | | | |\\ \\/ / | __| | _ / ", Draw.HEIGHT / 2 - 1); Draw.centerText("| |__| |/ ____ \\| | | | |____ | |__| | \\ / | |____| | \\ \\ ", Draw.HEIGHT / 2); Draw.centerText(" \\_____/_/ \\_\\_| |_|______| \\____/ \\/ |______|_| \\_\\", Draw.HEIGHT / 2 + 1); Draw.centerText("You survived to Round (" + Round + ") and gathered " + Player.credits + " credits!", Draw.HEIGHT / 2 + 3); while (true) { } }