com.b3dgs.lionengine.game.strategy.ability
Class AbstractAttackerAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>

java.lang.Object
  extended by com.b3dgs.lionengine.game.strategy.ability.AbstractAttackerAbility<TTile,TSkill,TAttr>
Type Parameters:
TTile - tile type used.
TSkill - skill type used.
TAttr - attributes type used.
All Implemented Interfaces:
AttackerAbility<TTile,TSkill,TAttr>
Direct Known Subclasses:
AbstractAttackerDistanceAbility, AbstractAttackerMeleeAbility

public abstract class AbstractAttackerAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
extends java.lang.Object
implements AttackerAbility<TTile,TSkill,TAttr>

This is the main implementation of the attacker ability. This object can be used by any kind of unit which will receive the ability of attacking.


Field Summary
protected  int frame
          Attack start frame number.
 
Constructor Summary
AbstractAttackerAbility(AbstractUnit<TTile,TSkill,TAttr> attacker)
          Create a new attacker ability.
 
Method Summary
 void attack(AbstractEntry<TTile,TSkill,TAttr> target)
          Define a target to attack.
 boolean isAttacking()
          Check if entry is attacking.
abstract  void onLostTarget()
          Action called when entry lost its target.
abstract  void onPause()
          Action called while entry is waiting for next attack.
abstract  void onReaching()
          Action called while entry is reaching target.
abstract  boolean onStartAttack()
          Action called when entry is going to attack.
 void setAttackFrame(int frame)
          Represent the frame number (inside animation) which design the attack action.
 void setAttackTimer(int time)
          Set attack pause time between two attacks.
 void setMaximalAttackDistance(int max)
          Set maximum attack distance bewteen entry and target.
 void setMinimalAttackDistance(int min)
          Set minimum attack distance bewteen entry and target.
 void stopAttack()
          Stop any action, reset all states.
 void updateAttack(float extrp)
          Update attack routine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

frame

protected int frame
Attack start frame number.

Constructor Detail

AbstractAttackerAbility

public AbstractAttackerAbility(AbstractUnit<TTile,TSkill,TAttr> attacker)
Create a new attacker ability.

Parameters:
attacker - concerned unit reference.
Method Detail

updateAttack

public void updateAttack(float extrp)
Description copied from interface: AttackerAbility
Update attack routine.

Specified by:
updateAttack in interface AttackerAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
Parameters:
extrp - extrapolation value.

attack

public void attack(AbstractEntry<TTile,TSkill,TAttr> target)
Description copied from interface: AttackerAbility
Define a target to attack. Entry will move to target location. Automaticaly updated if target is moving.

Specified by:
attack in interface AttackerAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
Parameters:
target - target.

stopAttack

public void stopAttack()
Description copied from interface: AttackerAbility
Stop any action, reset all states.

Specified by:
stopAttack in interface AttackerAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>

setAttackTimer

public void setAttackTimer(int time)
Description copied from interface: AttackerAbility
Set attack pause time between two attacks.

Specified by:
setAttackTimer in interface AttackerAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
Parameters:
time - attack pause time.

setAttackFrame

public void setAttackFrame(int frame)
Description copied from interface: AttackerAbility
Represent the frame number (inside animation) which design the attack action. Ex: for a footman, the frame number when the sword is going to hurt somebody (bewteen 1-last).

Specified by:
setAttackFrame in interface AttackerAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
Parameters:
frame - frame attack number.

setMinimalAttackDistance

public void setMinimalAttackDistance(int min)
Description copied from interface: AttackerAbility
Set minimum attack distance bewteen entry and target.

Specified by:
setMinimalAttackDistance in interface AttackerAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
Parameters:
min - minimum attack distance.

setMaximalAttackDistance

public void setMaximalAttackDistance(int max)
Description copied from interface: AttackerAbility
Set maximum attack distance bewteen entry and target.

Specified by:
setMaximalAttackDistance in interface AttackerAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
Parameters:
max - maximum attack distance.

isAttacking

public boolean isAttacking()
Description copied from interface: AttackerAbility
Check if entry is attacking.

Specified by:
isAttacking in interface AttackerAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
Returns:
true if currently attacking.

onReaching

public abstract void onReaching()
Action called while entry is reaching target.


onStartAttack

public abstract boolean onStartAttack()
Action called when entry is going to attack.

Returns:
true if attack started.

onPause

public abstract void onPause()
Action called while entry is waiting for next attack.


onLostTarget

public abstract void onLostTarget()
Action called when entry lost its target.