示例#1
0
 public Dungeon(Hero hero, Enemy enemy)
 {
     counter = Count;
     lineCounter = LineCounter;
     this.hero = hero;
     this.enemy = enemy;
     spell = new Spell();
 }
示例#2
0
 static void Main(string[] args)
 {
     Hero hero = new Hero(name: "Ivan", nickName: "Ruski", health: 100, mana: 100, manaRegenerationRate: 2);
     Enemy enemy = new Enemy(health: 100, mana: 100, damage: 20);
     Weapon wep = new Weapon("Damn", 20);
     hero.Equip(wep);
     Dungeon test = new Dungeon(hero, enemy);
     test.Spawn(hero);
     Commands(test,hero,enemy);
 }
示例#3
0
 public static void Commands(Dungeon test,Hero hero,Enemy enemy)
 {
     test.PrintMap();
     string inputDirection = string.Empty;
     while (true)
     {
         inputDirection= Console.ReadLine();
         if (inputDirection == "Right")
         {
             Console.WriteLine(test.MoveHero(Direction.Right));
             if (!hero.IsAlive())
             {
                 return;
             }
             if (test.Victory)
             {
                 Console.WriteLine("You won");
                 return;
             }
             test.PrintMap();
         }
         else if (inputDirection == "Left")
         {
             Console.WriteLine(test.MoveHero(Direction.Left));
             if (!hero.IsAlive())
             {
                 return;
             }
             if (test.Victory)
             {
                 Console.WriteLine("You won");
                 return;
             }
             test.PrintMap();
         }
         else if (inputDirection == "Up")
         {
             Console.WriteLine(test.MoveHero(Direction.Up));
             if (!hero.IsAlive())
             {
                 return;
             }
             if (test.Victory)
             {
                 Console.WriteLine("You won");
                 return;
             }                    
             test.PrintMap();
         }
         else if (inputDirection == "Down")
         {
             Console.WriteLine(test.MoveHero(Direction.Down));
             if (!hero.IsAlive())
             {
                 return;
             }
             if (test.Victory)
             {
                 Console.WriteLine("You won");
                 return;
             }
             test.PrintMap();
         }
         else
         {
             Console.WriteLine("Wrong direction");
         }
     }
 }
示例#4
0
 public Fight(Hero hero, Enemy enemy)
 {
     this.hero = hero;
     this.enemy = enemy;
 }
示例#5
0
 public bool Fight()
 {
     while (true)
     {
         if (hero.SDamage >= hero.WDamage)
         {
             enemy.Health -= hero.SDamage;
             Console.WriteLine($"Hero attacks enemmy with spell ... enemy mana now is {enemy.Health}");
             if (enemy.Health <= 0)
             {
                 break;
             }
         }
         else
         {
             enemy.Health -= hero.WDamage;
             Console.WriteLine($"Hero attacks enemmy with weapon .. enemy mana now is {enemy.Health}");
             if (enemy.Health <= 0)
             {
                 enemy = new Enemy(health: 100, mana: 100, damage: 20);
                 break;
             }
         }
         hero.Health -= enemy.Damage;
         Console.WriteLine($"Enemy attacks Hero ... hero mana is {hero.Health}");
         if (hero.Health <= 0)
         {
             break;
         }
     }
     if (hero.Health <= 0)
     {
         Console.WriteLine("Game Over you lost");
         return false;
     }
     Console.WriteLine("Enemy is dead");
     return true;
 }