1 package de.jos.game.actions.permanent;
2
3 import java.awt.Graphics2D;
4
5 import org.apache.commons.lang.StringUtils;
6
7 import com.golden.gamedev.GameObject;
8
9 import de.jos.game.actions.cleanup.CleanupActionNone;
10
11 public class ActionMoveStatistics extends AbstractPermanentAction implements SpecialEventPermanent {
12
13 private static final int MOVES_X = 480;
14 private static final int MOVES_Y = 100;
15
16 private int moves = 0;
17
18 private String movesString = null;
19
20 public ActionMoveStatistics() {
21 setCleanupAction(new CleanupActionNone(null));
22 }
23
24 public void init() {
25 super.init();
26 moves = 0;
27 updateMoves(0);
28 }
29
30 public boolean isFinished() {
31 return false;
32 }
33
34 public boolean isBlocking() {
35 return false;
36 }
37
38 public void update(long elapsedTime, GameObject gameObject) {}
39
40 public void render(Graphics2D graphics, GameObject gameObject) {
41 getGameFont().drawString(graphics, movesString, MOVES_X, MOVES_Y);
42 }
43
44 public void updateMoves(int movesToAdd) {
45 moves += movesToAdd;
46 StringBuilder sb = new StringBuilder();
47 sb.append(getResourceContainer().getLabelResources().getString("label.moves"));
48 sb.append(":").append(StringUtils.leftPad(String.valueOf(moves), 5));
49 movesString = StringUtils.upperCase(sb.toString());
50 }
51
52 public int getMoves() {
53 return moves;
54 }
55 public String getName() {
56 return this.getClass().getName();
57 }
58
59
60 }