コード例 #1
0
 public static void drag(Entity enemy, Vector2 target, float force, int duration) {
   EnemyMovement movement = EntityUtil.getComponent(enemy, EnemyMovement.class);
   if (movement != null) {
     movement.setDraggedTo(target);
     movement.setDragForce(force);
     movement.setDragDuration(duration);
     movement.setStartDrag(TimeUtil.getGameTime());
     movement.setDraggedFrom(PhysicsUtil.getPosition(enemy));
   }
 }
コード例 #2
0
 public static void use(Entity entity, String name) {
   Ability abilityComponent = EntityUtil.getComponent(entity, Ability.class);
   if (abilityComponent == null) {
     return;
   }
   AbilityInfo ability = abilityComponent.getAbility(name);
   if (ability == null) {
     return;
   }
   ability.getAbility().cast(entity);
   ability.setLastCast(TimeUtil.getGameTime());
 }
コード例 #3
0
 public static boolean isAvailable(Entity entity, String name) {
   Ability abilityComponent = EntityUtil.getComponent(entity, Ability.class);
   if (abilityComponent == null) {
     return false;
   }
   AbilityInfo ability = abilityComponent.getAbility(name);
   if (ability == null) {
     return false;
   }
   long lastCast = ability.getLastCast();
   return lastCast == -1 || (TimeUtil.getGameTime() - lastCast > ability.getCooldown());
 }