コード例 #1
0
        public void fireball(human enemy)
        {
            Random rand   = new Random();
            int    damage = rand.Next(20, 51);

            enemy.health -= damage;
            System.Console.WriteLine($"{enemy.name} took {damage} points of damage from the fireball");
        }
コード例 #2
0
 public void deathblow(human enemy)
 {
     if (enemy.health < 50)
     {
         enemy.health = 0;
         System.Console.WriteLine($"Insta kill");
     }
     else
     {
         System.Console.WriteLine("Insta fail");
     }
 }
コード例 #3
0
        static void Main(string[] args)
        {
            Wizard  test  = new Wizard("Harry");
            human   test2 = new human("jimmy");
            Ninja   test3 = new Ninja("Genji");
            Samurai test4 = new Samurai("Jack");

            test.heal();
            test.fireball(test2);
            test.fireball(test2);
            test3.steal(test2);
            test3.run();
            test4.deathblow(test2);
            test4.meditate();
        }
コード例 #4
0
 public void steal(human enemy)
 {
     this.health  += 10;
     enemy.health -= 10;
     System.Console.WriteLine($"you've stolen 10 health from {enemy.name}");
 }
コード例 #5
0
 public void Attack(human player)
 {
     player.health -= (this.strength * 5);
     System.Console.WriteLine($"{player.name} took {(this.strength * 5)} of damage");
 }