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); }
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); } } }
public bool IsItemOnGroundAt(Vector2 location) { Collider2D collider = CustomRaycast.GetItemColliderAt(location); return(collider != null && collider.GetComponent <ItemFilter>() != null); }
protected bool CanMoveTo(Coord position) { return(map.IsWalkable(position) && CustomRaycast.GetMapEntityColliderAt(position) == null); }