public static void ErrorMessage(string text) { ColorWriter.Write("Red", "\n " + text); SystemSounds.Exclamation.Play(); Console.ReadLine(); Console.Clear(); }
public static void SuccessMessage(string text) { ColorWriter.Write("Green", "\n " + text); //add sound Console.ReadLine(); Console.Clear(); }
public static void CountdownMessage(string text, byte i) { ColorWriter.Write("Yellow", "\n " + text + " "); while (i > 0) { ColorWriter.Write("White", i + " "); System.Threading.Thread.Sleep(750); i--; } ColorWriter.WriteLine("White", i.ToString()); Console.Clear(); }
private void CharacterDetails(byte idSelectedCharacter) { Console.Clear(); ColorWriter.SpaceWriteLine("Cyan", characters.Character[idSelectedCharacter - 1].Name); ColorWriter.SpaceWriteLine("DarkGray", "\u2022 " + characters.Character[idSelectedCharacter - 1].Description); ColorWriter.SpaceWrite("Gray", "\u00BB " + "Attack points: "); ColorWriter.Write("Magenta", characters.Character[idSelectedCharacter - 1].Attack.ToString()); ColorWriter.SpaceWriteLine("Yellow", "(Ap)"); ColorWriter.SpaceWrite("Gray", "\u00BB " + "Health points: "); ColorWriter.Write("Green", characters.Character[idSelectedCharacter - 1].Health.ToString()); ColorWriter.SpaceWriteLine("Yellow", "(Hp)"); }
private static byte MainSelectionMenu() { ColorWriter.WriteLine("Yellow", " Main menu options: \n"); ColorWriter.SpaceWrite("Yellow", "Black", "1"); ColorWriter.SpaceWrite("Gray", "Select a"); ColorWriter.SpaceWriteLine("Cyan", "Planet"); if (arena.PlanetChecker() != null) { ColorWriter.SpaceWriteLine("Green", " \u00BB " + arena.PlanetChecker() + " selected!"); } else { Console.WriteLine(); } ColorWriter.SpaceWrite("Yellow", "Black", "2"); ColorWriter.SpaceWrite("Gray", "Select a"); ColorWriter.SpaceWriteLine("Cyan", "Villain"); if (arena.VillainChecker() != null) { ColorWriter.SpaceWriteLine("Green", " \u00BB " + arena.VillainChecker() + " selected!"); } else { Console.WriteLine(); } ColorWriter.SpaceWrite("Yellow", "Black", "3"); ColorWriter.SpaceWrite("Gray", "Select a"); ColorWriter.SpaceWriteLine("Cyan", "Hero"); if (arena.HeroChecker() != null) { ColorWriter.SpaceWriteLine("Green", " \u00BB " + arena.HeroChecker() + " selected!"); } else { Console.WriteLine(); } ColorWriter.SpaceWrite("Yellow", "Black", "4"); ColorWriter.SpaceWrite("Gray", "Build the"); ColorWriter.SpaceWriteLine("Cyan", "Avengers Team"); if (arena.AvengersChecker()) { ColorWriter.SpaceWriteLine("Green", " \u00BB Avengers Team assembled!"); } else { Console.WriteLine(); } ColorWriter.SpaceWrite("Yellow", "Black", "5"); ColorWriter.SpaceWrite("Gray", "Start the"); ColorWriter.SpaceWriteLine("Cyan", "Fight\n"); ColorWriter.SpaceWrite("Yellow", "Black", "6"); ColorWriter.SpaceWriteLine("Gray", "Exit"); ColorWriter.Write("Yellow", "\n Select an option (number) : "); byte option = 0; try { option = byte.Parse(Console.ReadLine()); } catch (Exception) { SpecialMessage.ErrorMessage("Wrong type of value given!\n Expected Byte!"); errorGiven = true; } return(option); }
private void CharacterVsCharacter(Character avatar1, Character avatar2, bool heroAttacksFirst) { Random random = new Random(); short damage; if (!loadingMessageShown) { loadingMessageShown = true; SpecialMessage.LoadingMessage("Selecting who has the first turn (at random)"); if (heroAttacksFirst) { ColorWriter.SpaceWriteLine("Gray", "The Hero attacks first!\n"); } else { ColorWriter.SpaceWriteLine("Gray", "The Villain attacks first!\n"); } System.Threading.Thread.Sleep(1000); } //avatar1 attacks avatar2 if (avatar2.Health > 0 && avatar1.Health > 0) { damage = (short)(avatar1.Attack * (random.Next(60, 101) / 100f)); ColorWriter.SpaceWrite("Cyan", avatar1.Name); ColorWriter.SpaceWrite("Gray", "attacks"); ColorWriter.SpaceWrite("Yellow", avatar2.Name); ColorWriter.SpaceWrite("Gray", "and deals"); ColorWriter.SpaceWrite("Magenta", damage.ToString()); ColorWriter.SpaceWriteLine("Gray", "points of damage"); avatar2.Health = (short)(avatar2.Health - damage); ColorWriter.Write("Yellow", "\n " + avatar2.Name); ColorWriter.SpaceWrite("Gray", "Hp ="); if (avatar2.Health > 0) { ColorWriter.SpaceWriteLine("Green", avatar2.Health + "\n"); } else { ColorWriter.SpaceWriteLine("Red", avatar2.Health + "\n"); } } if (avatar2.Health <= 0) { SpecialMessage.DefeatMessage(avatar2.Name + " was defeated!"); } else { System.Threading.Thread.Sleep(2000); } //avatar2 attacks avatar1 if (avatar2.Health > 0 && avatar1.Health > 0) { damage = (short)(avatar2.Attack * (random.Next(60, 101) / 100f)); ColorWriter.SpaceWrite("Yellow", avatar2.Name); ColorWriter.SpaceWrite("Gray", "attacks"); ColorWriter.SpaceWrite("Cyan", avatar1.Name); ColorWriter.SpaceWrite("Gray", "and deals"); ColorWriter.SpaceWrite("Magenta", damage.ToString()); ColorWriter.SpaceWriteLine("Gray", "points of damage"); avatar1.Health = (short)(avatar1.Health - damage); ColorWriter.Write("Cyan", "\n " + avatar1.Name); ColorWriter.SpaceWrite("Gray", "Hp ="); if (avatar1.Health > 0) { ColorWriter.SpaceWriteLine("Green", avatar1.Health + "\n"); } else { ColorWriter.SpaceWriteLine("Red", avatar1.Health + "\n"); } } if (avatar1.Health <= 0) { SpecialMessage.DefeatMessage(avatar1.Name + " was defeated!"); } else { System.Threading.Thread.Sleep(2000); } }
private void CharacterNewStats(Character character) { ColorWriter.SpaceWriteLine("Cyan", character.Name); ColorWriter.SpaceWrite("Gray", "\u00BB Attack = " + character.Attack); if (character.IsVillain) { character.Attack = (short)(character.Attack + fightingPlanet.Modifiers.VillainAttackModifier); if (fightingPlanet.Modifiers.VillainAttackModifier >= 0) { ColorWriter.Write("Green", "+" + fightingPlanet.Modifiers.VillainAttackModifier); } else { ColorWriter.Write("Red", fightingPlanet.Modifiers.VillainAttackModifier.ToString()); } ColorWriter.Write("Gray", " = "); } else { character.Attack = (short)(character.Attack + fightingPlanet.Modifiers.HeroAttackModifier); if (fightingPlanet.Modifiers.HeroAttackModifier >= 0) { ColorWriter.Write("Green", "+" + fightingPlanet.Modifiers.HeroAttackModifier); } else { ColorWriter.Write("Red", fightingPlanet.Modifiers.HeroAttackModifier.ToString()); } ColorWriter.Write("Gray", " = "); } ColorWriter.Write("Magenta", character.Attack.ToString()); ColorWriter.SpaceWriteLine("Yellow", "(Ap)"); ColorWriter.SpaceWrite("Gray", "\u00BB Health = " + character.Health); if (character.IsVillain) { character.Health = (short)(character.Health + fightingPlanet.Modifiers.VillainHealthModifier); if (fightingPlanet.Modifiers.VillainHealthModifier >= 0) { ColorWriter.Write("Green", "+" + fightingPlanet.Modifiers.VillainHealthModifier); } else { ColorWriter.Write("Red", fightingPlanet.Modifiers.VillainHealthModifier.ToString()); } ColorWriter.Write("Gray", " = "); } else { character.Health = (short)(character.Health + fightingPlanet.Modifiers.HeroHealthModifier); if (fightingPlanet.Modifiers.HeroHealthModifier >= 0) { ColorWriter.Write("Green", "+" + fightingPlanet.Modifiers.HeroHealthModifier); } else { ColorWriter.Write("Red", fightingPlanet.Modifiers.HeroHealthModifier.ToString()); } ColorWriter.Write("Gray", " = "); } ColorWriter.Write("Green", character.Health.ToString()); ColorWriter.SpaceWriteLine("Yellow", "(Hp)"); }
private void OptionSelector(string dataName, bool multiple) { while (true) { ColorWriter.SpaceWriteLine("Yellow", "Black", dataName + " Selector\n"); bool errorGiven = false; if (dataName == "Planet") { foreach (Planet planet in planets.Planet) { ColorWriter.SpaceWrite("Yellow", "Black", planet.Id.ToString()); ColorWriter.SpaceWrite("Cyan", planet.Name + '\n'); ColorWriter.SpaceWriteLine("DarkGray", " \u2022 " + planet.Description); } } else { foreach (Character character in characters.Character) { if (character.IsVillain && dataName == "Villain") { ColorWriter.SpaceWrite("Yellow", "Black", character.Id.ToString()); ColorWriter.SpaceWrite("Cyan", character.Name + '\n'); ColorWriter.SpaceWriteLine("DarkGray", " \u2022 " + character.Description); } if (!character.IsVillain && dataName == "Hero") { ColorWriter.SpaceWrite("Yellow", "Black", character.Id.ToString()); ColorWriter.SpaceWrite("Cyan", character.Name + '\n'); ColorWriter.SpaceWriteLine("DarkGray", " \u2022 " + character.Description); } } } ColorWriter.Write("Yellow", "\n Select a " + dataName.ToLower() + " : "); byte idSelectedEntity = 0; try { idSelectedEntity = byte.Parse(Console.ReadLine()); } catch (Exception) { SpecialMessage.ErrorMessage("Wrong type of value given!\n Expected Byte"); errorGiven = true; } bool entityFound = false; if (dataName == "Planet") { foreach (Planet planet in planets.Planet) { if (planet.Id == idSelectedEntity) { entityFound = true; idSelectedPlanet = idSelectedEntity; } } } else { if (dataName == "Villain") { foreach (Character character in characters.Character) { if (character.Id == idSelectedEntity && character.IsVillain) { entityFound = true; idSelectedVillain = idSelectedEntity; } } } else { if (dataName == "Hero") { foreach (Character character in characters.Character) { if (character.Id == idSelectedEntity && !character.IsVillain) { entityFound = true; } } } } } if (entityFound) { while (true) { bool errorGiven2 = false; byte option = 0; if (dataName == "Planet") { Console.Clear(); PlanetDetails(); } else { if (dataName == "Villain") { CharacterDetails(idSelectedEntity); } else { if (dataName == "Hero") { CharacterDetails(idSelectedEntity); } } } ColorWriter.WriteLine("Yellow", "\n Options: \n"); ColorWriter.SpaceWrite("Yellow", "Black", "1"); if (dataName == "Hero" && multiple) { ColorWriter.SpaceWriteLine("Gray", "Add to the Avengers team\n"); } else { ColorWriter.SpaceWriteLine("Gray", "Confirm selected " + dataName.ToLower() + '\n'); } ColorWriter.SpaceWrite("Yellow", "Black", "2"); ColorWriter.SpaceWriteLine("Gray", "Go back to the selection menu"); if (dataName == "Hero" && multiple) { Console.WriteLine(); ColorWriter.SpaceWrite("Yellow", "Black", "3"); ColorWriter.SpaceWriteLine("Gray", "Show the Avengers team\n"); ColorWriter.SpaceWrite("Yellow", "Black", "4"); ColorWriter.SpaceWriteLine("Gray", "Clear the Avengers team\n"); ColorWriter.SpaceWrite("Yellow", "Black", "5"); ColorWriter.SpaceWriteLine("Gray", "Confirm Avengers Team"); } ColorWriter.Write("Yellow", "\n Select an option: "); try { option = byte.Parse(Console.ReadLine()); } catch (Exception) { SpecialMessage.ErrorMessage("Wrong type of value given!\n Expected Byte!"); errorGiven2 = true; } switch (option) { case 1: if (dataName == "Hero" && multiple) { AddHeroToAvengers(idSelectedEntity); } else { if (dataName == "Hero" && !multiple) { idSelectedHero = idSelectedEntity; } goto mainExit; } break; case 2: Console.Clear(); goto localExit; case 3: if (dataName == "Hero" && multiple) { ShowAvengersTeam(); } else { goto default; } break; case 4: if (dataName == "Hero" && multiple) { if (avengersList.Any()) { avengersList.Clear(); SpecialMessage.SuccessMessage("The Avengers team was cleared!"); } else { SpecialMessage.ErrorMessage("The Avengers team is already empty!"); } } else { goto default; } break; case 5: if (dataName == "Hero" && multiple) { goto mainExit; } else { goto default; } default: if (!errorGiven2) { SpecialMessage.ErrorMessage("No option of value = " + option + " was found"); } break; } } localExit :; } else { if (!errorGiven) { SpecialMessage.ErrorMessage("No " + dataName.ToLower() + " of id = " + idSelectedEntity + " was found"); } } } mainExit: Console.Clear(); }