public class AttackerModel extends FeatureModel implements Attacker, Recyclable
Constructor and Description |
---|
AttackerModel()
Create an attacker model.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(AttackerListener listener)
Add an attacker listener.
|
void |
attack(Transformable target)
Define a target to attack.
|
void |
checkListener(Object listener)
Check object interface listening and add them automatically.
|
int |
getAttackDamages()
Get a random attack damages (between min and max).
|
Transformable |
getTarget()
Get the target entity.
|
boolean |
isAttacking()
Check weapon is attacking.
|
void |
prepare(FeatureProvider provider)
Prepare the feature.
|
void |
recycle()
Recycle feature, to make it ready for reuse.
|
void |
setAttackDamages(int min,
int max)
Set attack damages between entity and target.
|
void |
setAttackDistance(int min,
int max)
Set attack distance between entity and target.
|
void |
setAttackFrame(int frame)
Represents the frame number (inside animation) which design the attack action.
|
void |
setAttackTimer(int time)
Set attack pause time between two attacks.
|
void |
stopAttack()
Stop the current attack.
|
void |
update(double extrp) |
getFeature, getFeatures, getFeaturesType, hasFeature
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFeature, getFeatures, getFeaturesType, hasFeature
public AttackerModel()
The Featurable
must have:
public void prepare(FeatureProvider provider)
Feature
Featurable.addFeature(Feature)
or
Featurable.addFeatureAndGet(Feature)
.prepare
in interface Feature
prepare
in class FeatureModel
provider
- The owner reference.public void checkListener(Object listener)
FeatureModel
Feature
provide listeners, this will
allow to add them automatically.
Does nothing by default.
checkListener
in interface Feature
checkListener
in class FeatureModel
listener
- The listener to check.public void addListener(AttackerListener listener)
Attacker
addListener
in interface Attacker
listener
- The attacker listener to add.public void attack(Transformable target)
Attacker
public void stopAttack()
Attacker
stopAttack
in interface Attacker
public void setAttackTimer(int time)
Attacker
setAttackTimer
in interface Attacker
time
- The attack pause time.public void setAttackFrame(int frame)
Attacker
Example: for a footman, the frame number when the sword is going to hurt somebody (between 1-last).
setAttackFrame
in interface Attacker
frame
- The frame attack number.public void setAttackDistance(int min, int max)
Attacker
setAttackDistance
in interface Attacker
min
- The minimum attack distance (in tile).max
- The maximum attack distance (in tile).public void setAttackDamages(int min, int max)
Attacker
setAttackDamages
in interface Attacker
min
- The minimum attack damages.max
- The maximum attack damages.public int getAttackDamages()
Attacker
getAttackDamages
in interface Attacker
public boolean isAttacking()
Attacker
isAttacking
in interface Attacker
true
if currently attacking, false
else.public Transformable getTarget()
Attacker
public final void recycle()
Recyclable
recycle
in interface Recyclable
Copyright © 2017 Byron 3D Games Studio. All rights reserved.