示例#1
0
        private int executeEnemyAttack(Monster monster)
        {
            int chance = monster.getToHit() - player.getDodge();
            int result = rand.Next(1, 100);

            if (result < chance)
            {
                int variation = rand.Next(1, 3);
                int damage    = monster.getDamage() * variation;
                damage -= player.getArmor().getQuality() + 1;
                if (damage > 0)
                {
                    textBox.Add(monster.getName() + " hits " + player.getName() + " for " + damage + " damage");
                    return(damage);
                }
                else
                {
                    textBox.Add(player.getName() + "'s armor completely absorbs the attack");
                    return(0);
                }
            }
            else
            {
                textBox.Add(player.getName() + " dodges " + monster.getName() + "'s attack");
                return(0);
            }
        }
示例#2
0
        private void process()
        {
            Monster tmp = currentMap.checkMonsterHealth();

            if (tmp != null)
            {
                player.addXP(tmp.getLevel());
                textBox.Add(tmp.getName() + " falls to your might!");
            }

            for (int i = 0; i < currentMap.getMonsters().Length; i++)
            {
                if (currentMap.moveAndCheckAttack(i, player.getPlayerX(), player.getPlayerY()))
                {
                    Object[] temp    = currentMap.getMonsters();
                    Monster  monTemp = (Monster)temp[i];
                    player.setNowHP(player.getNowHP() - executeEnemyAttack(monTemp));
                }
            }

            if (player.endRoundCheck())
            {
                textBox.Add("You have gained a level, " + player.getName() + "'s stats have been increased");
            }

            if (player.getNowHP() <= 0)
            {
                gameEnd = true;
            }
        }
示例#3
0
 private int executePlayerAttack(Monster monster)
 {
     int chance = player.getToHit() - monster.getDodge();
     int result = rand.Next(1, 100);
     if (result < chance)
     {
         int variation = rand.Next(1, 4);
         int damage = (1 + (player.getWeapon().getQuality()) * variation);
         damage -= monster.getAC();
         if (damage > 0)
         {
             textBox.Add(player.getName() + " hits " + monster.getName() + " for " + damage + " damage");
             return damage;
         }
         else
         {
             textBox.Add(monster.getName() + "'s armor completely absorbs the attack");
             return 0;
         }
     }
     else
     {
         textBox.Add(monster.getName() + " dodges " + player.getName() + "'s attack");
         return 0;
     }
 }