Beispiel #1
0
 void TryMoveTo(Coord coord)
 {
     if (Map.IsWalkable(coord))
     {
         Collider2D collision = CustomRaycast.GetMapEntityColliderAt(coord);
         if (collision != null) // something is in the way
         {
             IAttackable target = collision.GetComponent <IAttackable>();
             if (target != null) // that something can be attacked
             {
                 attack.Attack(target);
                 time.Increase(AttackSpeed);
             }
         }
         else
         {
             transform.position = (Vector2)coord;
             time.Increase(MoveSpeed);
         }
     }
 }
 void TryMoveTo(Coord coord)
 {
     if (Map.IsWalkable(coord))
     {
         Collider2D collision = CustomRaycast.GetMapEntityColliderAt(coord);
         if (collision != null) // something is in the way
         {
             IAttackable target = collision.GetComponent <IAttackable>();
             if (target != null) // that something can be attacked
             {
                 Defense      defense = target.GetDefense();
                 Attack       attack  = attacker.BuildAttack();
                 AttackResult result  = attackResolver.ResolvePhysicalAttack(attack, defense);
                 target.Attack(result);
                 time.IncreaseBasedOnSpeed(AttackSpeed);
             }
         }
         else
         {
             transform.position = (Vector2)coord;
             time.IncreaseBasedOnSpeed(MoveSpeed);
         }
     }
 }
Beispiel #3
0
 protected bool CanMoveTo(Coord position)
 {
     return(map.IsWalkable(position) && CustomRaycast.GetMapEntityColliderAt(position) == null);
 }