예제 #1
0
        public void Attack(warrior enemy)
        {
            int damage = weapon.Damage / enemy.armor.ArmorPoint;

            enemy.health -= damage;

            AttackResult(enemy, damage);

            Thread.Sleep(200);
        }
예제 #2
0
 private void AttackResult(warrior enemy, int damage)
 {
     if (enemy.health <= 0)
     {
         enemy.isAlive = false;
         Tools.ColorfulWriteLine($"{enemy.name} is dead!", ConsoleColor.Red);
         Tools.ColorfulWriteLine($"{name} is victorious!", ConsoleColor.Yellow);
     }
     else
     {
         Console.WriteLine($"{name} attacked {enemy.name}. \n{damage} was infilicted to {enemy.name}, remaining health of {enemy.health} is {enemy.health} ");
         Console.WriteLine("--------------------------------------------------------------------------");
     }
 }
예제 #3
0
        static void Main(string[] args)
        {
            warrior goodGuy = new warrior("Justice", Faction.goodGuy);
            warrior badGuy  = new warrior("Evil", Faction.badGuy);

            while (goodGuy.IsAlive && badGuy.IsAlive)
            {
                if (rng.Next(0, 10) < 5)
                {
                    goodGuy.Attack(badGuy);
                }
                else
                {
                    badGuy.Attack(goodGuy);
                }
            }


            Console.ReadKey();
        }