1 package de.jos.game.actions.permanent;
2
3 import java.awt.Graphics2D;
4
5 import com.golden.gamedev.GameObject;
6
7 import de.jos.game.actions.ActionScrollInOut;
8 import de.jos.game.actions.LayerConstants;
9 import de.jos.game.actions.cleanup.CleanupActionNone;
10 import de.jos.game.actions.cleanup.CleanupPuzzleGameOverAction;
11 import de.jos.game.logic.AbstractGameBoard;
12 import de.jos.game.logic.BoardUtils;
13
14 public class ActionPuzzleSolvedCheck extends AbstractPermanentAction implements SpecialEventPermanent {
15
16 private AbstractGameBoard gameBoard = null;
17
18 private boolean gameOver = false;
19
20 public ActionPuzzleSolvedCheck(AbstractGameBoard gameBoard) {
21 this.gameBoard = gameBoard;
22 setCleanupAction(new CleanupActionNone(null));
23 }
24
25 public void init() {
26 super.init();
27 }
28
29 public Integer getLayer() {
30 return LayerConstants.LAYER_1;
31 }
32
33 public boolean isFinished() {
34 return false;
35 }
36
37 public boolean isBlocking() {
38 return false;
39 }
40
41 /***
42 * TODO diese pruefung sollte nur stattfinden, nachdem sich eine kugel bewegt
43 * hat, nicht bei jedem neurendern des spielfelds !
44 */
45 public void update(long elapsedTime, GameObject gameObject) {
46
47 if (gameOver == false && BoardUtils.getAllBoardBullets(getGameBoard()).isEmpty()) {
48 ActionScrollInOut gameOverScroll = new ActionScrollInOut();
49 gameOverScroll.setResourceContainer(getResourceContainer());
50
51 gameOverScroll.setText1(getString("text.scroller.levelSolved", "!"));
52 gameOverScroll.setText2(getString("text.scroller.congratulation", "!"));
53 gameOverScroll.init();
54
55 CleanupPuzzleGameOverAction cleanupAction = new CleanupPuzzleGameOverAction(getGameBoard(), true);
56 gameOverScroll.setCleanupAction(cleanupAction);
57
58 getNewSpecialEventList().add(gameOverScroll);
59
60 gameOver = true;
61 } else if (gameOver == false && BoardUtils.isFutureMovePossible(getGameBoard()) == false) {
62 ActionScrollInOut gameOverScroll = new ActionScrollInOut();
63 gameOverScroll.setResourceContainer(getResourceContainer());
64
65 gameOverScroll.setText1(getString("text.scroller.levelNotSolved", "!"));
66 gameOverScroll.setText2(getString("text.scroller.gameOver", "!"));
67 gameOverScroll.init();
68
69 CleanupPuzzleGameOverAction cleanupAction = new CleanupPuzzleGameOverAction(getGameBoard(), false);
70 gameOverScroll.setCleanupAction(cleanupAction);
71
72 getNewSpecialEventList().add(gameOverScroll);
73
74 gameOver = true;
75 }
76
77 }
78
79 public void update(long elapsedTime, GameObject gameObject, boolean specialActionListEmpty) {
80
81 if (specialActionListEmpty == true) {
82 update(elapsedTime, gameObject);
83 }
84 }
85
86 public void render(Graphics2D graphics, GameObject gameObject) {}
87
88 public AbstractGameBoard getGameBoard() {
89 return gameBoard;
90 }
91
92 public String getName() {
93 return this.getClass().getName();
94 }
95 }