fPalette = new GruntPalette(fColor, GruntzGame.resourceManager().rez().file("GRUNTZ/PALETTEZ/" + fColor + "TOOL", "pal"));
animate("IDLE1", "IDLE");
fCursor = new MonolithANI(GruntzGame.resourceManager().rez().file("GAME/ANIZ/GRUNTSELECTEDSPRITE", "ani"), "GAME/IMAGEZ/GRUNTSELECTEDSPRITE").sprite();
// Health
fHealthSprite = new Sprite(new MonolithPID(GruntzGame.resourceManager().rez().file("GAME/IMAGEZ/GRUNTHEALTHSPRITE/FRAME001", "pid")).image());
fHealthSprite.position(new Vector2f(-12, -26));
fStaminaSprite = new Sprite(new MonolithPID(GruntzGame.resourceManager().rez().file("GAME/IMAGEZ/GRUNTSTAMINASPRITE/FRAME001", "pid")).image());
fStaminaSprite.position(new Vector2f(-12, -32));
// Setup the grunt movement
fMovement = new GridAlignedMovementOld<Grunt>(this, new MovementMinion(), 0, 0) {
/**
* Serial key
*/
private static final long serialVersionUID = -3074929548144342979L;
@Override
public boolean canMove(GridCoordinate target) {
TreeSet<String> traits = fMap.traits(target);
return (!traits.contains("solid") && !traits.contains("nogo") && !traits.contains("water") && gridManager().getFirstEntityOfTypeAt(target, Grunt.class, Grunt.this) == null);
}
};
fMovement.setup(500, new LinearLerper());
// Setup the tile watcher
fTileWatcher = new Minion<GridEvent>() {
public long run(com.pointcliki.event.Dispatcher<GridEvent> dispatcher, String type, GridEvent event) {
checkTile();
return Minion.CONTINUE;
};
};
fHurter = new PeriodicRogue<Grunt>(this, null, 40, 0) {
/**
* Serial key
*/
private static final long serialVersionUID = 6455636894570231644L;
@Override
public void run(Grunt entity, long currentFrame) {
if (attributeAsBoolean("hurtable")) setStateHealth(fHealth.value() - 2);
}
};
fStaminater = new PeriodicRogue<Grunt>(this, null, 4, 0) {
/**
* Serial key
*/
private static final long serialVersionUID = 6455636894570231644L;
@Override
public void run(Grunt entity, long currentFrame) {
fStamina.assign(fStamina.value() + 1);
int val = Math.max(0, attributeAsInteger("stamina"));
String s = (21 - val) + "";
while (s.length() < 3) s = "0" + s;
fStaminaSprite.image(new MonolithPID(GruntzGame.resourceManager().rez().file("GAME/IMAGEZ/GRUNTSTAMINASPRITE/FRAME" + s, "pid")).image());
if ((fStamina).value() == 20) {
removeChild(fStaminaSprite);
cancel();
}