public void StartBattle(Hero TheHero, Enemy TheEnemy, bool BossFight, VisualElement[,] matrix, List<NPC> NPCsOfCurrentLevel) { hero = TheHero; enemy = TheEnemy; totalHeroHP = hero.Statistics.HitPoints; currentHeroHP = totalHeroHP; totalEnemyHP = enemy.Statistics.HitPoints; currentEnemyHP = totalEnemyHP; DrawBattle(hero, enemy); while (currentHeroHP > 0 && currentEnemyHP > 0) { ProcessInput(Console.ReadKey()); Thread.Sleep(1000); DrawBattle(hero, enemy); if (escapeSuccessful) { break; } if (currentEnemyHP < 1) { break; } EnemyAttack(); Thread.Sleep(1000); DrawBattle(hero, enemy); enemyIsCrippled = false; } if (currentHeroHP < 1) { // game over TheHero.LevelUp(); hero.Position = new Position(0, 0); Loader load = new Loader(); NPCsOfCurrentLevel.Clear(); matrix = load.LoadLevel(matrix, TheHero, NPCsOfCurrentLevel); } else { if (BossFight) { TheHero.LevelUp(); hero.Position = new Position(0, 0); if (TheHero.level > 3) { // Game compleated } MenuChangeWeapon newWeapon = new MenuChangeWeapon(); newWeapon.GetRandomWeapon(TheHero); Loader load = new Loader(); NPCsOfCurrentLevel.Clear(); matrix = load.LoadLevel(matrix, TheHero, NPCsOfCurrentLevel); } else if (!escapeSuccessful) { DiceRoller dice = new DiceRoller(); if (dice.NewDice(0.5)) { MenuChangeWeapon newWeapon = new MenuChangeWeapon(); newWeapon.GetRandomWeapon(TheHero); } } } }
public DangerousTerritory(double Chance, Enemy enemyToAppear) { this.Chance = Chance; this.enemyToAppear = enemyToAppear; }
void DrawBattle(Hero hero, Enemy enemy) { Drawer draw = new Drawer(); Console.BackgroundColor = ConsoleColor.Black; Console.Clear(); int heroLifeBarBlocks = (int)(20 * (double)currentHeroHP / totalHeroHP); int enemyLifeBarBlocks = (int)(20 * (double)currentEnemyHP / totalEnemyHP); if (heroLifeBarBlocks < 0) { heroLifeBarBlocks = 0; } if (enemyLifeBarBlocks < 0) { enemyLifeBarBlocks = 0; } draw.DrawString(hero.Name + " (" + hero.level + ")", ConsoleColor.DarkGray, 2, 5); draw.DrawString(new string(' ', heroLifeBarBlocks), ConsoleColor.DarkRed, 3, 15); draw.DrawString(currentHeroHP + " / " + totalHeroHP, ConsoleColor.DarkRed, 3, 36); draw.DrawImage(hero.Image, ConsoleColor.Black, 5, 5); for (int i = 0; i < 7; i++) { draw.DrawString(boxRow, ConsoleColor.DarkYellow, 40 + i, 10); if (i == 1) { draw.DrawString("Press [A] to Attack", ConsoleColor.DarkYellow, 40 + i, 13); } else if (i == 3) { draw.DrawString("Press [S] to use a Spell", ConsoleColor.DarkYellow, 40 + i, 13); } else if (i == 5) { draw.DrawString("Press [E] to Escape", ConsoleColor.DarkYellow, 40 + i, 13); } } draw.DrawString(enemy.Name, ConsoleColor.DarkGray, 2, 55); draw.DrawString(new string(' ', enemyLifeBarBlocks), ConsoleColor.DarkRed, 3, 65); draw.DrawString(currentEnemyHP + " / " + totalEnemyHP, ConsoleColor.DarkRed, 3, 86); draw.DrawImage(enemy.Image, ConsoleColor.Black, 5, 55); for (int i = 0; i < 7; i++) { draw.DrawString(boxRow, ConsoleColor.DarkYellow, 40 + i, 60); draw.DrawString(message[i], ConsoleColor.DarkYellow, 40 + i, 63); } Console.BackgroundColor = ConsoleColor.Black; Console.SetCursorPosition(0,0); }