-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bug when not continuing to score screen
References #46
- Loading branch information
1 parent
09a8e2a
commit 16c0601
Showing
4 changed files
with
83 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,8 @@ | |
|
||
|
||
/** | ||
* @author David Schilling - [email protected] | ||
* @author Raphael Schilling | ||
* @author David Schilling - [email protected] | ||
* @author Raphael Schilling | ||
*/ | ||
public class GameFieldView extends Entity { | ||
|
||
|
@@ -32,15 +32,13 @@ public class GameFieldView extends Entity { | |
private final VertexBufferObjectManager vbom; | ||
private final ITextureRegion tilesBorderRegion; | ||
private TileSprite[][] tileSprites; | ||
private TileSprite start; | ||
private TileSprite finish; | ||
private boolean active = true; | ||
private boolean active = false; | ||
|
||
private int countModifier; | ||
private int modifierFinished; | ||
|
||
public GameFieldView(float pX, float pY, float spacePerTile, GameService gameService, | ||
Map<Character, TextureRegion> regionMap, VertexBufferObjectManager vbom, ITextureRegion tilesBorderRegion) { | ||
Map<Character, TextureRegion> regionMap, VertexBufferObjectManager vbom, ITextureRegion tilesBorderRegion) { | ||
|
||
super(pX, pY); | ||
this.gameService = gameService; | ||
|
@@ -60,7 +58,11 @@ public void addTiles(boolean finished) { | |
tileIndex = 0; | ||
} | ||
|
||
|
||
detachChildren(); | ||
if (active){ | ||
oneModifierFinished(true); | ||
} | ||
|
||
Tile[][] field = gameService.getLevel().getField(); | ||
int width = field.length; | ||
|
@@ -76,7 +78,7 @@ public void addTiles(boolean finished) { | |
if (field[x][y].getShortcut() != 'n') { | ||
TextureRegion pTextureRegion = tileRegionMap.get(field[x][y].getShortcut()); | ||
TextureRegion pTextureRegionFilled = tileRegionMap.get(Character.toUpperCase( | ||
field[x][y].getShortcut())); | ||
field[x][y].getShortcut())); | ||
List<ITextureRegion> textureRegions = Arrays.<ITextureRegion>asList(pTextureRegion, | ||
pTextureRegionFilled); | ||
|
||
|
@@ -91,12 +93,12 @@ public void addTiles(boolean finished) { | |
break; | ||
|
||
case FINISH: | ||
finish = createFinishAnsStart(x, y, tilePositionX, tilePositionY, textureRegions, field); | ||
TileSprite finish = createFinishAnsStart(x, y, tilePositionX, tilePositionY, textureRegions, field); | ||
finish.setITextureRegionIndex(tileIndex); | ||
break; | ||
|
||
case START: | ||
start = createFinishAnsStart(x, y, tilePositionX, tilePositionY, textureRegions, field); | ||
TileSprite start = createFinishAnsStart(x, y, tilePositionX, tilePositionY, textureRegions, field); | ||
start.setITextureRegionIndex(tileIndex); | ||
break; | ||
|
||
|
@@ -130,6 +132,7 @@ public void oneStep(final boolean horizontal, int row, final int direction) { | |
} | ||
|
||
gameService.shiftLine(true, row - 1, direction, true); | ||
active = true; | ||
this.countModifier = tileSprites.length - 2; | ||
this.modifierFinished = 0; | ||
|
||
|
@@ -138,20 +141,21 @@ public void oneStep(final boolean horizontal, int row, final int direction) { | |
tileSprite.registerEntityModifier(new MoveXModifier(0.3f, tileSprite.getX(), | ||
tileSprite.getX() + tileSprite.getWidth() * direction, EaseQuadInOut.getInstance()) { | ||
|
||
@Override | ||
protected void onModifierFinished(IEntity pItem) { | ||
@Override | ||
protected void onModifierFinished(IEntity pItem) { | ||
|
||
oneModifierFinished(); | ||
super.onModifierFinished(pItem); | ||
} | ||
}); | ||
oneModifierFinished(false); | ||
super.onModifierFinished(pItem); | ||
} | ||
}); | ||
} | ||
} else { | ||
if (row > tileSprites[0].length - 2) { | ||
return; | ||
} | ||
|
||
gameService.shiftLine(false, row - 1, direction, true); | ||
active = true; | ||
this.countModifier = tileSprites[row].length - 2; | ||
this.modifierFinished = 0; | ||
|
||
|
@@ -160,20 +164,20 @@ protected void onModifierFinished(IEntity pItem) { | |
tileSprite.registerEntityModifier(new MoveYModifier(0.3f, tileSprite.getY(), | ||
tileSprite.getY() + tileSprite.getWidth() * direction, EaseQuadInOut.getInstance()) { | ||
|
||
@Override | ||
protected void onModifierFinished(IEntity pItem) { | ||
@Override | ||
protected void onModifierFinished(IEntity pItem) { | ||
|
||
oneModifierFinished(); | ||
super.onModifierFinished(pItem); | ||
} | ||
}); | ||
oneModifierFinished(false); | ||
super.onModifierFinished(pItem); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
|
||
|
||
private TileSprite createFinishAnsStart(int x, int y, float tilePositionX, float tilePositionY, | ||
List<ITextureRegion> pTextureRegion, Tile[][] field) { | ||
List<ITextureRegion> pTextureRegion, Tile[][] field) { | ||
|
||
TileSprite tileSprite; | ||
|
||
|
@@ -213,26 +217,11 @@ public void dispose() { | |
} | ||
|
||
|
||
public void setTubesState(int state) { | ||
|
||
for (TileSprite[] tileSprite : tileSprites) { | ||
for (TileSprite currentSprite : tileSprite) { | ||
if (currentSprite != null) { | ||
currentSprite.setITextureRegionIndex(state); | ||
} | ||
} | ||
} | ||
|
||
start.setITextureRegionIndex(state); | ||
finish.setITextureRegionIndex(state); | ||
} | ||
|
||
|
||
private void oneModifierFinished() { | ||
private void oneModifierFinished(boolean now) { | ||
|
||
modifierFinished++; | ||
|
||
if (modifierFinished == countModifier) { | ||
if (modifierFinished == countModifier | now) { | ||
active = false; | ||
gameService.notifyAllObserver(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters