Commit 0723a198 authored by Matyáš Latner's avatar Matyáš Latner

#83 Zobrazení mapy pro tutorial při prvním spuštění hry

parent 46a007c9
......@@ -23,6 +23,7 @@
<string name="game_potme_loading_text_2">Přetahuj správné úkony do pásu vpravo a dávej pozor na všechny překážky. Teprve až budeš mít naplánovanou celou trasu, stiskni tlačítko HOTOVO.</string>
<string name="game_potme_start">HOTOVO</string>
<string name="game_potme_floor">Patro</string>
<string name="game_potme_victory_tutorial">Gratuluji! A teď to zkus sám&#8230;</string>
<string name="game_potme_victory_0">Au au, tolik chyb! To muselo bolet.</string>
<string name="game_potme_victory_1">Krůček za krůčkem. To chce klid, soustředit se a úspěchy se brzy dostaví.</string>
<string name="game_potme_victory_2">Chybička se vždycky vloudí, ale dobrému detektivovi by se to stávat nemělo.</string>
......
......@@ -116,6 +116,7 @@ public abstract class GameActivity extends LayoutGameActivity implements MenuAct
protected boolean afterResume = false;
protected boolean paused = false;
private boolean playVictorySpeech = false;
private boolean useGameManager = true;
private static final int STEPS_PER_SECOUND = 60;
protected static final int VICTORY_SCREEN_STARS_COUNT = 3;
......@@ -169,6 +170,10 @@ public abstract class GameActivity extends LayoutGameActivity implements MenuAct
public boolean isGameActive(GamesDefinition gameDefinitionToCheck) {
return (gamesDefinition == gameDefinitionToCheck) && (gameState == GameState.STARTED);
}
protected void disableGameManagerForCurrentGame() {
useGameManager = false;
}
/* //////////////////////////////////////////// TABLEXIA LIFECYCLE */
......@@ -220,6 +225,7 @@ public abstract class GameActivity extends LayoutGameActivity implements MenuAct
scene.clearTouchAreas();
clearScene();
useGameManager = true;
gameManager = null;
}
......@@ -252,7 +258,7 @@ public abstract class GameActivity extends LayoutGameActivity implements MenuAct
*/
protected void initGame() {
getTablexiaContext().showScreenContent(null);
if (gameManager == null) {
if (gameManager == null && useGameManager) {
gameManager = new GameManager(gamesDefinition, getTablexiaContext().getSelectedUser(), getDifficulty());
}
}
......@@ -302,8 +308,11 @@ public abstract class GameActivity extends LayoutGameActivity implements MenuAct
if (gameTrophy == null) {
gameTrophy = GameTrophy.createGameTrophyAndSave(userId, gameNumber);
}
List<TrophyEnum> trophies = gameTrophy.nextGameComplete(getDifficulty(), score);
trophies.addAll(UserTrophyDefinition.processUserTrophies(selectedUser));
List<TrophyEnum> trophies = null;
if (score >= 0) {
trophies = gameTrophy.nextGameComplete(getDifficulty(), score);
trophies.addAll(UserTrophyDefinition.processUserTrophies(selectedUser));
}
showVictoryScreen(score, trophies);
GameTrophy.logAllGameTrophysForUser(userId);
}
......@@ -906,7 +915,9 @@ public abstract class GameActivity extends LayoutGameActivity implements MenuAct
@Override
public void run() {
if (playVictorySpeech == true) {
soundControl.playSound(getVictorySpeech()[score], false);
if (score >= 0 && score < getVictorySpeech().length) {
soundControl.playSound(getVictorySpeech()[score], false);
}
}
}
......@@ -952,12 +963,13 @@ public abstract class GameActivity extends LayoutGameActivity implements MenuAct
* @param trophies game trophies
*/
private void showTrophies(List<TrophyEnum> trophies) {
for (int i = 0; i < trophies.size(); i++) {
if (i < VICTORY_SCREEN_TROPHIES_LAYOUTS.length) {
showTrophyImage(VICTORY_SCREEN_TROPHIES_LAYOUTS[i], trophies.get(i));
}
}
if (trophies != null) {
for (int i = 0; i < trophies.size(); i++) {
if (i < VICTORY_SCREEN_TROPHIES_LAYOUTS.length) {
showTrophyImage(VICTORY_SCREEN_TROPHIES_LAYOUTS[i], trophies.get(i));
}
}
}
}
/**
......@@ -1008,15 +1020,24 @@ public abstract class GameActivity extends LayoutGameActivity implements MenuAct
* @param score score to show in victory screen (number of stars)
*/
private void setVictoryScreenScore(int score) {
if (score > 0) {
showStar((FrameLayout) victoryLayout.findViewById(R.id.victoryscreen_ratingstar1), SfxSounds.VICTORYSCREEN_STAR1_SOUND, VICTORYSCREEN_STAR1_DELAY);
}
if (score > 1) {
showStar((FrameLayout) victoryLayout.findViewById(R.id.victoryscreen_ratingstar2), SfxSounds.VICTORYSCREEN_STAR2_SOUND, VICTORYSCREEN_STAR2_DELAY);
}
if (score > 2) {
showStar((FrameLayout) victoryLayout.findViewById(R.id.victoryscreen_ratingstar3), SfxSounds.VICTORYSCREEN_STAR3_SOUND, VICTORYSCREEN_STAR3_DELAY);
}
if (score < 0) {
victoryLayout.findViewById(R.id.victoryscreen_ratingstar1).setVisibility(View.GONE);
victoryLayout.findViewById(R.id.victoryscreen_ratingstar2).setVisibility(View.GONE);
victoryLayout.findViewById(R.id.victoryscreen_ratingstar3).setVisibility(View.GONE);
} else {
victoryLayout.findViewById(R.id.victoryscreen_ratingstar1).setVisibility(View.VISIBLE);
victoryLayout.findViewById(R.id.victoryscreen_ratingstar2).setVisibility(View.VISIBLE);
victoryLayout.findViewById(R.id.victoryscreen_ratingstar3).setVisibility(View.VISIBLE);
if (score > 0) {
showStar((FrameLayout) victoryLayout.findViewById(R.id.victoryscreen_ratingstar1), SfxSounds.VICTORYSCREEN_STAR1_SOUND, VICTORYSCREEN_STAR1_DELAY);
}
if (score > 1) {
showStar((FrameLayout) victoryLayout.findViewById(R.id.victoryscreen_ratingstar2), SfxSounds.VICTORYSCREEN_STAR2_SOUND, VICTORYSCREEN_STAR2_DELAY);
}
if (score > 2) {
showStar((FrameLayout) victoryLayout.findViewById(R.id.victoryscreen_ratingstar3), SfxSounds.VICTORYSCREEN_STAR3_SOUND, VICTORYSCREEN_STAR3_DELAY);
}
}
}
/**
......@@ -1074,14 +1095,14 @@ public abstract class GameActivity extends LayoutGameActivity implements MenuAct
* @param score score to show on victory screen
*/
public void setVictoriousTextsAndProgress(int score) {
TextView txtvVictory = (TextView) victoryLayout.findViewById(R.id.victoryscreen_message);
txtvVictory.setText(getVictoryText(score));
TextView tvStats = (TextView) victoryLayout.findViewById(R.id.victoryscreen_result);
tvStats.setText(getStatsText());
resetVictoryScreenScore();
setVictoryScreenScore(score);
TextView txtvVictory = (TextView) victoryLayout.findViewById(R.id.victoryscreen_message);
txtvVictory.setText(getVictoryText(score));
TextView tvStats = (TextView) victoryLayout.findViewById(R.id.victoryscreen_result);
tvStats.setText(getStatsText());
resetVictoryScreenScore();
setVictoryScreenScore(score);
}
/**
......
......@@ -74,6 +74,7 @@ import cz.nic.tablexia.game.games.potme.map.mapobject.MapObjectType;
import cz.nic.tablexia.game.games.potme.map.tile.Tile;
import cz.nic.tablexia.game.games.potme.map.widget.MapWidget;
import cz.nic.tablexia.game.games.potme.map.widget.MapWidget.TileMapClickListener;
import cz.nic.tablexia.game.manager.GameManager;
/**
* Activity for "Potmě" game
......@@ -176,7 +177,10 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
public static int ACTION_SIZE_SMALLER;
private int planningStartTime = 0;
private PotmeDifficulty potmeDifficulty;
private boolean currentFirstPlay = true;
private RandomAccess randomAccess;
private ActionsStripWidget actionsStripWidget;
private ActionsWidget actionsWidget;
......@@ -335,6 +339,8 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
protected void resetGame() {
super.resetGame();
potmeDifficulty = null;
randomAccess = null;
mapWidgets = null;
......@@ -348,6 +354,10 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
@Override
protected void initGame() {
if (!getPotmeDifficulty().hasResults()) {
disableGameManagerForCurrentGame();
currentFirstPlay = false;
}
super.initGame();
// calculate widgets sizes
......@@ -359,8 +369,7 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
TILE_SIZE = (int)(((displaySize.x - actionStripWidgetWidth - actionPanelWidth) / MAP_X_SIZE) * TILE_SIZE_RATIO);
MAP_START_POSITION_X = (int)(TILE_SIZE * MAP_START_X_TILE_SIZE_RATIO);
MAP_START_POSITION_Y = (int)(displaySize.y - (TILE_SIZE * MAP_START_Y_TILE_SIZE_RATIO));
PotmeDifficulty potmeDifficulty = PotmeDifficulty.getPotmeDifficultyForGameDifficulty(getDifficulty());
mapWidgets = new ArrayList<MapWidget>();
errorCount = 0;
......@@ -371,11 +380,11 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
GameLayer.attachLayersToScene(scene);
showMapWidgets(potmeDifficulty);
showMapWidgets(getPotmeDifficulty());
prepareBackground();
actionsStripWidget = showActionsStripWidget(actionStripWidgetWidth);
actionsWidget = showActionsWidget(potmeDifficulty, actionStripWidgetWidth);
actionsWidget = showActionsWidget(getPotmeDifficulty(), actionStripWidgetWidth);
startButton = showStartButton((int)actionsWidget.getX());
//TODO remove and use event bus
actionsStripWidget.setStartButton(startButton);
......@@ -491,34 +500,34 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
private void showMapWidgets(PotmeDifficulty potmeDifficulty) {
try {
Tile lastFinishPosition = null;
int floorCount = potmeDifficulty.getFloorCount();
boolean hasKey = potmeDifficulty.hasDifficultyActionType(ActionType.KEY);
for (int i = 0; i < floorCount; i++) {
MapObjectType finishMapObjetcMapObjectType;
if (i == (floorCount - 1)) {
finishMapObjetcMapObjectType = MapObjectType.SAFE;
} else {
finishMapObjetcMapObjectType = MapObjectType.STAIRS;
}
boolean floorHasKey = hasKey && ((floorCount - 1) / 2) == i;
MapWidget mapWidget = new MapWidget(lastFinishPosition, finishMapObjetcMapObjectType, i, floorCount > 1, MAP_START_POSITION_X, MAP_START_POSITION_Y, MAP_X_SIZE, MAP_Y_SIZE, floorHasKey, randomAccess, getResources().getText(R.string.game_potme_floor).toString(), getVertexBufferObjectManager());
mapWidgets.add(mapWidget);
if (i == 0) {
mapWidget.setInFront();
} else {
mapWidget.setInBottom();
}
mapWidget.setClickable(scene, this);
GameLayer.MAP_LAYER.getLayerEntity().attachChild(mapWidget);
lastFinishPosition = mapWidget.getTileMap().getTileAtPosition(mapWidget.getTileMap().getMapFinishPosition());
}
Tile lastFinishPosition = null;
int floorCount = potmeDifficulty.getFloorCount();
boolean hasKey = potmeDifficulty.hasDifficultyActionType(ActionType.KEY);
for (int i = 0; i < floorCount; i++) {
MapObjectType finishMapObjetcMapObjectType;
if (i == (floorCount - 1)) {
finishMapObjetcMapObjectType = MapObjectType.SAFE;
} else {
finishMapObjetcMapObjectType = MapObjectType.STAIRS;
}
boolean floorHasKey = hasKey && ((floorCount - 1) / 2) == i;
MapWidget mapWidget = new MapWidget(potmeDifficulty.getMapProviderNewInstance(randomAccess), lastFinishPosition, finishMapObjetcMapObjectType, i, floorCount > 1, MAP_START_POSITION_X, MAP_START_POSITION_Y, MAP_X_SIZE, MAP_Y_SIZE, floorHasKey, getResources().getText(R.string.game_potme_floor).toString(), getVertexBufferObjectManager());
mapWidgets.add(mapWidget);
if (i == 0) {
mapWidget.setInFront();
} else {
mapWidget.setInBottom();
}
mapWidget.setClickable(scene, this);
GameLayer.MAP_LAYER.getLayerEntity().attachChild(mapWidget);
lastFinishPosition = mapWidget.getTileMap().getTileAtPosition(mapWidget.getTileMap().getMapFinishPosition());
}
} catch (Throwable t) {
throw new RuntimeException("Error during generating map with random seed: " + randomAccess.getRandomSeed(), t);
}
......@@ -615,7 +624,9 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
}
private void goToPlayMode() {
getGameManager().setExtraInt1(getGameManager().getExtraInt1() + ((int)scene.getSecondsElapsedTotal() - planningStartTime));
if (getGameManager() != null) {
getGameManager().setExtraInt1(getGameManager().getExtraInt1() + ((int)scene.getSecondsElapsedTotal() - planningStartTime));
}
startButton.disable();
actionsWidget.disableActions();
actionsStripWidget.disableControl();
......@@ -728,7 +739,7 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
}
MapObject mapObject = tileMap.getTileAtPosition(player.getActualTileMapPosition()).getMapObject();
if ((mapObject != null) &&
(!PotmeDifficulty.getPotmeDifficultyForGameDifficulty(getDifficulty()).hasDifficultyActionType(ActionType.KEY) || player.hasKey()) &&
(!getPotmeDifficulty().hasDifficultyActionType(ActionType.KEY) || player.hasKey()) &&
(mapObject.getMapObjectType() == MapObjectType.SAFE) &&
(selectedActionPosition == selectedActions.size() - 1)) {
......@@ -739,7 +750,9 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
player.registerEntityModifier(new DelayModifier(FINISH_ACTION_DELAY, new EntityModifierListenerAdapter() {
@Override
public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
getGameManager().setCounterAndSave(errorCount);
if (getGameManager() != null) {
getGameManager().setCounterAndSave(errorCount);
}
gameComplete();
}
}));
......@@ -901,24 +914,36 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
seedTextView.setPadding(0, 0, 200, 0);
}
}
/* //////////////////////////////////////////// POTME DIFFICULTY */
public PotmeDifficulty getPotmeDifficulty() {
if (potmeDifficulty == null) {
boolean firstPlay = currentFirstPlay && (getTablexiaContext().getSelectedUser() != null) && (GameManager.getGamePlayCountForUser(getTablexiaContext().getSelectedUser(), getGameDefinition()) == 0);
potmeDifficulty = PotmeDifficulty.getPotmeDifficultyForGameDifficulty(getDifficulty(), firstPlay);
}
return potmeDifficulty;
}
/* //////////////////////////////////////////// VICTORY SCREEN CALLBACKS */
@Override
public CharSequence getVictoryText(int progress) {
switch (progress) {
case 0:
return getString(R.string.game_potme_victory_0);
case 1:
return getString(R.string.game_potme_victory_1);
case 2:
return getString(R.string.game_potme_victory_2);
case 3:
return getString(R.string.game_potme_victory_3);
default:
throw new IllegalStateException("Unknown progress");
}
switch (progress) {
case -1:
return getString(R.string.game_potme_victory_tutorial);
case 0:
return getString(R.string.game_potme_victory_0);
case 1:
return getString(R.string.game_potme_victory_1);
case 2:
return getString(R.string.game_potme_victory_2);
case 3:
return getString(R.string.game_potme_victory_3);
default:
throw new IllegalStateException("Unknown progress");
}
}
@Override
public String[] getVictorySpeech() {
......@@ -927,12 +952,14 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
@Override
public CharSequence getStatsText() {
return Html.fromHtml(getString(R.string.game_potme_error_count, errorCount));
return !getPotmeDifficulty().hasResults() ? "" : Html.fromHtml(getString(R.string.game_potme_error_count, errorCount));
}
@Override
public int countProgress() {
if (errorCount < 1) {
if (!getPotmeDifficulty().hasResults()) {
return -1;
} else if (errorCount < 1) {
return 3;
} else if (errorCount < 3) {
return 2;
......
......@@ -3,8 +3,13 @@ package cz.nic.tablexia.game.games.potme;
import java.util.Arrays;
import java.util.List;
import android.util.Log;
import cz.nic.tablexia.game.common.RandomAccess;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.potme.action.ActionType;
import cz.nic.tablexia.game.games.potme.map.IMapProvider;
import cz.nic.tablexia.game.games.potme.map.MapGenerator;
import cz.nic.tablexia.game.games.potme.map.MapTutorial;
/**
* Game potme difficulty definition and mapping to game difficulty
......@@ -14,18 +19,27 @@ import cz.nic.tablexia.game.games.potme.action.ActionType;
*/
public enum PotmeDifficulty {
EASY (GameDifficulty.EASY, 1, Arrays.asList(new ActionType[]{})),
MEDIUM (GameDifficulty.MEDIUM, 1, Arrays.asList(new ActionType[]{ActionType.KEY})),
HARD (GameDifficulty.HARD, 2, Arrays.asList(new ActionType[]{ActionType.KEY}));
TUTORIAL(null, false, MapTutorial.class, 1, Arrays.asList(new ActionType[]{})),
EASY (GameDifficulty.EASY, true, MapGenerator.class, 1, Arrays.asList(new ActionType[]{})),
MEDIUM (GameDifficulty.MEDIUM, true, MapGenerator.class, 1, Arrays.asList(new ActionType[]{ActionType.KEY})),
HARD (GameDifficulty.HARD, true, MapGenerator.class, 2, Arrays.asList(new ActionType[]{ActionType.KEY}));
private GameDifficulty gameDifficulty;
private int floorCount;
private List<ActionType> difficultyActionTypes;
private Class<? extends IMapProvider> mapProviderClass;
private boolean hasResults;
private PotmeDifficulty(GameDifficulty gameDifficulty, int floorCount, List<ActionType> difficultyActionTypes) {
this.gameDifficulty = gameDifficulty;
this.floorCount = floorCount;
this.difficultyActionTypes = difficultyActionTypes;
private PotmeDifficulty(GameDifficulty gameDifficulty, boolean hasResults, Class<? extends IMapProvider> mapProviderClass, int floorCount, List<ActionType> difficultyActionTypes) {
this.gameDifficulty = gameDifficulty;
this.hasResults = hasResults;
this.mapProviderClass = mapProviderClass;
this.floorCount = floorCount;
this.difficultyActionTypes = difficultyActionTypes;
}
public boolean hasResults() {
return hasResults;
}
public int getFloorCount() {
......@@ -36,7 +50,10 @@ public enum PotmeDifficulty {
return difficultyActionTypes.contains(actionType);
}
public static PotmeDifficulty getPotmeDifficultyForGameDifficulty(GameDifficulty gameDifficulty) {
public static PotmeDifficulty getPotmeDifficultyForGameDifficulty(GameDifficulty gameDifficulty, boolean isFirstGame) {
if (isFirstGame) {
return TUTORIAL;
}
for (PotmeDifficulty potmeDifficulty : PotmeDifficulty.values()) {
if (potmeDifficulty.gameDifficulty == gameDifficulty) {
return potmeDifficulty;
......@@ -45,4 +62,13 @@ public enum PotmeDifficulty {
return null;
}
public IMapProvider getMapProviderNewInstance(RandomAccess randomAccess) {
try {
return mapProviderClass.getConstructor(RandomAccess.class).newInstance(randomAccess);
} catch (Exception e) {
Log.e(PotmeDifficulty.class.getCanonicalName(), "Cannot create instance for IMapProvider class: " + mapProviderClass, e);
}
return null;
}
}
package cz.nic.tablexia.game.games.potme.map;
import cz.nic.tablexia.game.games.potme.map.mapobject.MapObjectType;
import cz.nic.tablexia.game.games.potme.map.tile.Tile;
public interface IMapProvider {
public TileMap prepareMap(Tile lastFinishTile, int mapXSize, int mapYSize, MapObjectType finishMapObject, boolean hasKey);
}
......@@ -39,7 +39,7 @@ import cz.nic.tablexia.game.games.potme.map.tile.TileType;
* @author Matyáš Latner
*
*/
public class MapGenerator {
public class MapGenerator implements IMapProvider {
private static final double OBSTACLE_PROBABILITY = 0.4;
......@@ -82,7 +82,7 @@ public class MapGenerator {
this.randomAccess = randomAccess;
}
public TileMap generateRandomMap(Tile lastFinishTile, int mapXSize, int mapYSize, MapObjectType finishMapObject, boolean hasKey) {
public TileMap prepareMap(Tile lastFinishTile, int mapXSize, int mapYSize, MapObjectType finishMapObject, boolean hasKey) {
Log.d(MapGenerator.class.getCanonicalName(), "Start generating with random seed: " + randomAccess.getRandomSeed());
TileMap tileMap = new TileMap(mapXSize, mapYSize);
......@@ -103,7 +103,7 @@ public class MapGenerator {
// connect all tile groups
connectAllGroups(tileMap, Arrays.asList(new TileMapPosition[] {startPosition}));
// selects best tile for safe
// select best tile for safe
Tile finishTile = createFinishTile(tileMap, finishMapObject);
tileMap.setMapFinishPosition(finishTile.getTileMapPosition());
......
package cz.nic.tablexia.game.games.potme.map;
import android.util.Log;
import cz.nic.tablexia.game.common.RandomAccess;
import cz.nic.tablexia.game.games.potme.PotmeActivity;
import cz.nic.tablexia.game.games.potme.map.TileMap.TileMapPosition;
import cz.nic.tablexia.game.games.potme.map.mapobject.MapObjectType;
import cz.nic.tablexia.game.games.potme.map.mapobstacle.MapObstacleType;
import cz.nic.tablexia.game.games.potme.map.mapobstacle.MapObstacleType.MapObstaclePosition;
import cz.nic.tablexia.game.games.potme.map.tile.Tile;
import cz.nic.tablexia.game.games.potme.map.tile.TileType;
public class MapTutorial implements IMapProvider {
protected RandomAccess randomAccess;
public MapTutorial(RandomAccess randomAccess) {
this.randomAccess = randomAccess;
}
@Override
public TileMap prepareMap(Tile lastFinishTile, int mapXSize, int mapYSize, MapObjectType finishMapObject, boolean hasKey) {
Log.d(MapGenerator.class.getCanonicalName(), "Start preparing tutorial map with random seed: " + randomAccess.getRandomSeed());
TileMap tileMap = new TileMap(mapXSize, mapYSize);
TileMapPosition position1 = PotmeActivity.DEFAULT_MAP_START_POSITION;
TileMapPosition position2 = new TileMapPosition(position1.getPositionX() - 1, position1.getPositionY());
TileMapPosition position3 = new TileMapPosition(position1.getPositionX() - 1, position1.getPositionY() - 1);
tileMap.setMapStartPosition(position1);
tileMap.setMapFinishPosition(position3);
Tile tile1 = new Tile(TileType.TILE_2IH);
Tile tile2 = new Tile(TileType.TILE_2LA);
Tile tile3 = new Tile(TileType.TILE_1C);
tileMap.addTileAtPosition(position1, tile1);
tileMap.addTileAtPosition(position2, tile2);
tileMap.addTileAtPosition(position3, tile3);
tile3.setMapObstacle(MapObstaclePosition.BOTTOM_POSITION, MapObstacleType.DOOR_H);
tile3.setMapObject(finishMapObject);
// fill all map
for (int i = 0; i < tileMap.getMapXSize(); i++) {
for (int j = 0; j < tileMap.getMapYSize(); j++) {
if (!tileMap.isTileAtPosition(i, j)) {
Tile tile = new Tile(TileType.TILE_0);
tileMap.addTileAtPosition(i, j, tile);
}
}
}
return tileMap;
}
}
\ No newline at end of file
......@@ -30,10 +30,9 @@ import org.andengine.opengl.vbo.DrawType;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.util.adt.color.Color;
import cz.nic.tablexia.game.common.RandomAccess;
import cz.nic.tablexia.game.games.potme.PotmeActivity;
import cz.nic.tablexia.game.games.potme.ResourceManager;
import cz.nic.tablexia.game.games.potme.map.MapGenerator;
import cz.nic.tablexia.game.games.potme.map.IMapProvider;
import cz.nic.tablexia.game.games.potme.map.TileMap;
import cz.nic.tablexia.game.games.potme.map.mapobject.MapObject;
import cz.nic.tablexia.game.games.potme.map.mapobject.MapObjectType;
......@@ -100,7 +99,7 @@ public class MapWidget extends Entity {
}
public MapWidget(Tile lastFinishTile, MapObjectType finishMapObjetcType, int floorNumber, boolean hasBookmark, int positionX, int positionY, int mapXSize, int mapYSize, boolean hasKey, RandomAccess randomAccess, String buttonText, VertexBufferObjectManager vertexBufferObjectManager) {
public MapWidget(IMapProvider mapProvider, Tile lastFinishTile, MapObjectType finishMapObjetcType, int floorNumber, boolean hasBookmark, int positionX, int positionY, int mapXSize, int mapYSize, boolean hasKey, String buttonText, VertexBufferObjectManager vertexBufferObjectManager) {
super();
this.buttonText = buttonText;
this.floorNumber = floorNumber;
......@@ -113,7 +112,7 @@ public class MapWidget extends Entity {
mapLayer = new Entity();
attachChild(mapLayer);
tileMap = new MapGenerator(randomAccess).generateRandomMap(lastFinishTile, mapXSize, mapYSize, finishMapObjetcType, hasKey);
tileMap = mapProvider.prepareMap(lastFinishTile, mapXSize, mapYSize, finishMapObjetcType, hasKey);
if (hasBookmark) {
showBookmarkButton(vertexBufferObjectManager);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment