示例#1
0
        public void Attack(WarriorClass enemy)
        {
            //int damage = weapon.Damage / enemy.armor.ArmorPoints;
            int damage = weapon.Damage;

            enemy.health -= damage;

            AttackResult(enemy, damage);
        }
示例#2
0
 private void AttackResult(WarriorClass enemy, int damage)
 {
     if (enemy.health <= 0)
     {
         enemy.isAlive = false;
         //Console.WriteLine($"{enemy.name} has fainted. \n{name} has won the battle.");
         Tools.ColorfulWriteLine($"{enemy.name} has fainted.", ConsoleColor.Red);
         Tools.ColorfulWriteLine($"{name} has won the battle.", ConsoleColor.Green);
     }
     else
     {
         Console.WriteLine($"{name} attacked {enemy.name}. Dealt {damage} damage, {enemy.name} remaining health is {enemy.health}");
     }
 }
示例#3
0
        static void Main(string[] args)
        {
            WarriorClass goodGuy = new WarriorClass("Chris", Faction.Goodguy);
            WarriorClass badGuy  = new WarriorClass("Bob", Faction.Badguy);

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