/// <summary> /// Run the battle /// </summary> public void Run() { while (complete == false && hero.Alive()) { Thread.Sleep(1000); layout.Arena(hero, enemies); //We need to run random before we check alive status therefore do-while & not while. do { enemiesnr = random.Next(0, enemies.Count()); }while (!enemies[enemiesnr].Alive()); //We will only attack Enemy there is alive. if (hero.Alive()) { hero.Action(enemies[enemiesnr]); } else { complete = true; break; } Thread.Sleep(1000); layout.Arena(hero, enemies); enemyAlive = enemies.Count(); foreach (Enemy enemy in enemies) { if (enemy.Alive()) { enemy.Action(hero); } else { enemyAlive--; if (enemyAlive <= 0) { foreach (Enemy deadEnemy in enemies) { hero.Xp += deadEnemy.XpReward; if (hero.LevelUpCheck()) { hero.LevelUpStats(); } } complete = true; break; } } } } }
/// <summary> /// Player Menu /// </summary> public void PlayerMenu() { Console.Clear(); layout.PlayerInfo(hero.Health, hero.MaxHealth, hero.Alive(), hero.Level, hero.Xp, hero.LastLevelUp(), hero.NextLevelUp()); Console.WriteLine(); Console.WriteLine("-------------- Options -------------"); Console.WriteLine("What do you want to do? (choose number)"); if (hero.Alive()) { Console.WriteLine("1. Arena"); Console.WriteLine("2. Rest"); PlayerOption(); } Console.WriteLine("1. Restart"); DeadOption(); //playerSelect = Int16.Parse(Console.ReadLine()); }
/// <summary> /// Arena Layout /// </summary> /// <param name="hero">Hero In Arena</param> /// <param name="enemies">enemies In Arena</param> public void Arena(Hero hero, List <Enemy> enemies) { Console.Clear(); Console.WriteLine("-------------- Arena -------------- "); Console.WriteLine("Health Bar: \n"); Console.WriteLine("{0} {1}", hero.Name, HealthBar(hero.Health, hero.MaxHealth, hero.Alive())); foreach (Enemy enemy in enemies) { Console.WriteLine("{0} {1}", enemy.Name, HealthBar(enemy.Health, enemy.MaxHealth, enemy.Alive())); //Console.WriteLine("{0} {1}", enemy.Name, enemy.HealthBar()); } Console.WriteLine(); }