Пример #1
0
        ItemFilter GetItemFilter(Vector2 location)
        {
            Collider2D collider = CustomRaycast.GetItemColliderAt(location);

            if (collider != null)
            {
                ItemFilter itemFilter = collider.GetComponent <ItemFilter>();
                Assert.IsNotNull(itemFilter, "Found item without an item filter component.");
                return(itemFilter);
            }
            return(null);
        }
Пример #2
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);
         }
     }
 }
Пример #3
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
             {
                 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);
         }
     }
 }
Пример #4
0
        public bool IsItemOnGroundAt(Vector2 location)
        {
            Collider2D collider = CustomRaycast.GetItemColliderAt(location);

            return(collider != null && collider.GetComponent <ItemFilter>() != null);
        }
Пример #5
0
 protected bool CanMoveTo(Coord position)
 {
     return(map.IsWalkable(position) && CustomRaycast.GetMapEntityColliderAt(position) == null);
 }