Пример #1
0
 internal virtual AttackResult TryAttack(LivingEntity targetEntity)
 {
     Position2D pos = targetEntity.Position;
     if (EntityType == EntityType.Player &&
         targetEntity.EntityType == EntityType.Monster) {
         // Player vs monster
         var a = Attack(targetEntity);
         if (a == AttackResult.Killed) {
             // Player killed monster
             AddXP(targetEntity.ExperienceValue);
             Helper.ConsoleWrite(Id + " kill " + targetEntity.Id);
             PostAttack(pos, targetEntity);
         }
         else if (a == AttackResult.Miss) {
             // Player missed monster
             Helper.ConsoleWrite(Id + " miss " + targetEntity.Id);
         }
         else if (a == AttackResult.Hit) {
             // Player hit monster
             Helper.ConsoleWrite(Id + " hit " + targetEntity.Id);
         }
         PostAttack(pos, targetEntity);
     }
     else if (EntityType == EntityType.Monster &&
              targetEntity.EntityType == EntityType.Player) {
         // Monster vs player
         Helper.ConsoleWrite(Id + " attacks " + targetEntity.Id);
         if (Attack(targetEntity) == AttackResult.Hit) {
             // Monster hit player
             Helper.ConsoleWrite(Id + " hits " + targetEntity.Id);
         }
         PostAttack(pos, targetEntity);
     }
     else if (targetEntity.EntityType == EntityType.Monster &&
              EntityType == EntityType.Monster) {
         // Monster vs Monster
     }
     else if (targetEntity.EntityType == EntityType.Player &&
              EntityType == EntityType.Player) {
         // Player vs Player
         var a = Attack(targetEntity);
         if (a == AttackResult.Killed) {
             // Player killed monster
             AddXP(targetEntity.ExperienceValue);
             Helper.ConsoleWrite(Id + " kill " + targetEntity.Id);
             PostAttack(pos, targetEntity);
         }
         else if (a == AttackResult.Miss) {
             // Player missed monster
             Helper.ConsoleWrite(Id + " miss " + targetEntity.Id);
         }
         else if (a == AttackResult.Hit) {
             // Player hit monster
             Helper.ConsoleWrite(Id + " hit " + targetEntity.Id);
             PostAttack(pos, targetEntity);
         }
     }
     return AttackResult.InvalidAttack;
 }
Пример #2
0
 internal virtual void PostAttack(Position2D pos, LivingEntity mob)
 {
 }