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

java.lang.Object
  extended by com.b3dgs.lionengine.game.strategy.AbstractSkill<TTile,TSkill,TAttr>
Type Parameters:
TTile - tile type used.
TSkill - skill type used.
TAttr - attributes type used.

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

Abstract structure of a skill, used by any kind of entry. It already contains name, displayble name, description, level, and icon. This model has to be implemented in order to specify the action. To be created, it needs the filename containing skills data, and the skill name.

See Also:
SkillData

Field Summary
protected  int destX
          Skill action destination (if target is null).
protected  int destY
          Skill action destination (if target is null).
 AbstractEntry<TTile,TSkill,TAttr> owner
          Skill owner.
protected  AbstractEntry<TTile,TSkill,TAttr> target
          Skill action destination (if destX/Y are negative).
 
Constructor Summary
AbstractSkill(java.lang.String file, java.lang.String name, int priority, AbstractEntry<TTile,TSkill,TAttr> owner)
          Create a new skill.
 
Method Summary
abstract  void action()
          Action executed on cast.
 java.lang.String getDesc()
          Get skill description.
 java.lang.String getDisplayName()
          Get the displayed skill name.
 int getIcon()
          Get skill icon.
 int getLvl()
          Get skill level.
 java.lang.String getName()
          Get skill name.
 int getPriority()
          Set priority level.
 boolean isActive()
          Get active state.
 boolean isIgnored()
          Get ignorance state.
 boolean isOrder()
          Check if skill is an order or a simple button.
 boolean isSelected()
          Get skill selection state.
 boolean isUnlocked()
          Check if skill is unlocked.
abstract  void onClick()
          Action called when clicked on skill from panel.
abstract  void renderOnMap(java.awt.Graphics2D g, AbstractControlPanel<TTile,TSkill,TAttr> panel, StrategyCursor cursor)
          Rendering routine on map.
abstract  void renderOnPanel(java.awt.Graphics2D g, AbstractControlPanel<TTile,TSkill,TAttr> panel, StrategyCursor cursor, TiledSprite icons, int x, int y, int w, int h)
          Rendering routine on panel.
 void setActive(boolean state)
          Set active state (true when using).
 void setDestination(int destX, int destY)
          Set the skill action destination (in real value; it will be automatically converted to map tile).
 void setIcon(int icon)
          Set icon number.
 void setIgnore(boolean state)
          Set ignorance state (it can be used to hide a certain part of skills).
 void setLvl(int lvl)
          Set skill level.
 void setOrder(boolean state)
          Set order state (an order will require a left click on map to assign it).
 void setRetry(boolean state)
          Set entry owner keeping selection mode.
 void setSelected(boolean state)
          Set skill selection state.
 void setTarget(AbstractEntry<TTile,TSkill,TAttr> target)
          Set the skill action target.
 void setUnlocked(boolean state)
          Set unlock state.
abstract  void updateOnMap(float extrp)
          Update routine on map.
abstract  void updateOnPanel(AbstractControlPanel<TTile,TSkill,TAttr> panel)
          Update routine on panel.
 boolean willRetry()
          Check if skill will retry click.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

owner

public final AbstractEntry<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes> owner
Skill owner.


destX

protected int destX
Skill action destination (if target is null).


destY

protected int destY
Skill action destination (if target is null).


target

protected AbstractEntry<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes> target
Skill action destination (if destX/Y are negative).

Constructor Detail

AbstractSkill

public AbstractSkill(java.lang.String file,
                     java.lang.String name,
                     int priority,
                     AbstractEntry<TTile,TSkill,TAttr> owner)
Create a new skill.

Parameters:
file - skill data file name.
name - skill name.
priority - skill priority.
owner - entry owner reference.
Method Detail

updateOnMap

public abstract void updateOnMap(float extrp)
Update routine on map.

Parameters:
extrp - extrapolation value.

updateOnPanel

public abstract void updateOnPanel(AbstractControlPanel<TTile,TSkill,TAttr> panel)
Update routine on panel.

Parameters:
panel - panel reference.

renderOnMap

public abstract void renderOnMap(java.awt.Graphics2D g,
                                 AbstractControlPanel<TTile,TSkill,TAttr> panel,
                                 StrategyCursor cursor)
Rendering routine on map.

Parameters:
g - graphic output.
panel - panel reference.
cursor - cursor reference.

renderOnPanel

public abstract void renderOnPanel(java.awt.Graphics2D g,
                                   AbstractControlPanel<TTile,TSkill,TAttr> panel,
                                   StrategyCursor cursor,
                                   TiledSprite icons,
                                   int x,
                                   int y,
                                   int w,
                                   int h)
Rendering routine on panel.

Parameters:
g - graphic output.
panel - panel reference.
cursor - cursor reference.
icons - set if icons.
x - skill location x on panel.
y - skill location y on panel.
w - skill width on panel.
h - skill height on panel.

action

public abstract void action()
Action executed on cast. Effects has to be updated in update function.


setDestination

public void setDestination(int destX,
                           int destY)
Set the skill action destination (in real value; it will be automatically converted to map tile).

Parameters:
destX - real destination x (from cursor).
destY - real destination y (from cursor).

setTarget

public void setTarget(AbstractEntry<TTile,TSkill,TAttr> target)
Set the skill action target.

Parameters:
target - skill target.

getName

public java.lang.String getName()
Get skill name.

Returns:
skill name.

getDisplayName

public java.lang.String getDisplayName()
Get the displayed skill name.

Returns:
displayed skill name.

getDesc

public java.lang.String getDesc()
Get skill description.

Returns:
skill description.

getLvl

public int getLvl()
Get skill level.

Returns:
skill level.

setLvl

public void setLvl(int lvl)
Set skill level.

Parameters:
lvl - level to set.

setIcon

public void setIcon(int icon)
Set icon number.

Parameters:
icon - icon number.

getIcon

public int getIcon()
Get skill icon.

Returns:
skill icon.

getPriority

public int getPriority()
Set priority level. It is used during skill rendering, to know which is rendered first.

Returns:
priority level.

setOrder

public void setOrder(boolean state)
Set order state (an order will require a left click on map to assign it). Setting it to false means that a single click on the icon will call action(). Setting it to true means that it will need another click to set the map destination.

Parameters:
state - order state.

isOrder

public boolean isOrder()
Check if skill is an order or a simple button.

Returns:
order state.

setIgnore

public void setIgnore(boolean state)
Set ignorance state (it can be used to hide a certain part of skills).

Parameters:
state - ignorance state.

isIgnored

public boolean isIgnored()
Get ignorance state.

Returns:
ignorance state.

setActive

public void setActive(boolean state)
Set active state (true when using).

Parameters:
state - active state.

isActive

public boolean isActive()
Get active state.

Returns:
true if currently in use.

setSelected

public void setSelected(boolean state)
Set skill selection state.

Parameters:
state - selection state.

isSelected

public boolean isSelected()
Get skill selection state.

Returns:
skill selection state.

setUnlocked

public void setUnlocked(boolean state)
Set unlock state.

Parameters:
state - unlocked state.

isUnlocked

public boolean isUnlocked()
Check if skill is unlocked.

Returns:
unlocked state

setRetry

public void setRetry(boolean state)
Set entry owner keeping selection mode.

Parameters:
state - retry state.

willRetry

public boolean willRetry()
Check if skill will retry click.

Returns:
retry state.

onClick

public abstract void onClick()
Action called when clicked on skill from panel.