static void Main(string[] args) { ConsoleEx.WriteLine("┌\t\t\t ┐\n\tMathMagic 1.0\n└ \t\t\t ┘", ConsoleColor.Blue); Thread.Sleep(1000); new Game(); }
private void Poll() { // player turn, get body target ConsoleEx.AddSeparator(); Console.WriteLine("Rodada {0}\nSeu HP: {1}\nHP do Matemágico: {2}", m_rounds, m_player.GetHealth(), m_enemy.GetHealth()); ConsoleEx.WriteLine("Escolha onde deseja atacar:\n" + "1. Torso\n2. Pernas\n3. Cabeça", ConsoleColor.Yellow); uint bodyTarget = 0; ConsoleEx.ParseUint(ref bodyTarget, 1, 3, "Local inválido, escolha entre 1 (torso), 2 (perna) ou 3 (cabeça)."); if (m_rounds == 0) { Console.WriteLine("Faça o cálculo necessário para acertar a flecha!"); Thread.Sleep(1000); } // reset timer aTimer.Stop(); aTimer.Enabled = true; // gen math operation (string operation, int result) = GenOperation(bodyTarget); ConsoleEx.WriteLine(operation, ConsoleColor.Yellow); uint answer = 0; while (aTimer.Enabled && (!uint.TryParse(Console.ReadLine(), out answer))) { if (aTimer.Enabled) { Console.WriteLine("Número inválido, tente novamente."); } } // show results if (!aTimer.Enabled) { ConsoleEx.WriteLine("Você perdeu o turno.", ConsoleColor.Red); } else if (answer == result) { ConsoleEx.WriteLine("Você acertou a flecha!", ConsoleColor.Green); Random rand = new Random(); int damage; if (bodyTarget == (uint)BodyTarget.Torso) { damage = rand.Next(3, 6); } else if (bodyTarget == (uint)BodyTarget.Legs) { damage = rand.Next(4, 7); } else { damage = rand.Next(7, 11); } m_enemy.Hit(damage); } else { ConsoleEx.WriteLine(String.Format("Você errou a flecha. A resposta certa era {0}!", result), ConsoleColor.Red); } aTimer.Stop(); Thread.Sleep(1000); // victory? if (m_enemy.IsDead()) { End(true); return; } m_player.Hit(m_enemy.GetDamage()); Thread.Sleep(1000); // defeat? if (m_player.IsDead()) { End(false); return; } // continue m_rounds++; Poll(); }
protected override void ShowDamage(int value) { ConsoleEx.WriteLine(String.Format("Você causou {0} de dano ao Matemágico!", value), ConsoleColor.Green); }
private static void OnTimerEnd(Object source, System.Timers.ElapsedEventArgs e) { aTimer.Enabled = false; ConsoleEx.WriteLine("Tempo esgotado!", ConsoleColor.Red); ConsoleEx.WriteLine("Pressione <Enter> para continuar...", ConsoleColor.Gray); }