Commit 6e1b0088 authored by Luboš Horáček's avatar Luboš Horáček

Merge branch 'devel' of gitlab.labs.nic.cz:labs/tablexia into devel

parents af1a1aee 87fab91f
......@@ -83,6 +83,7 @@ public class PronasledovaniActivity extends GameActivity implements IOnSceneTouc
private static final int[] DIFFICULTIES = new int[] { 3, 4, 5 };
private static final String TAG = PronasledovaniActivity.class.getSimpleName();
public static final String BASE_DIR = "pronasledovani/";
public static final String TEXTURES_DIR = "textures/";
private static final int MAPSCOUNT = 14; // pri pridani mapy vzdy pridat souradnice pro auticko
private static final boolean SHUFFLE_MAP = true;
private static final int MINIMUM_ROTATION_FOR_ANIMATION = 20; // o kolik stupnu se musi dilek minimalne otocit,aby
......@@ -95,22 +96,26 @@ public class PronasledovaniActivity extends GameActivity implements IOnSceneTouc
private static final int ASSET_BITMAP_SIZE = 1300;
private static final int GRID_OFFSET_Y = 10;
private static final String MAP_BITMAPS_EXTENSION = ".png";
private static final String[] maps = new String[] { "mapa1", "mapa5", "mapa3", "mapa4", "mapa2", "mapa6", "mapa7", "mapa8", "mapa9", "mapa10", "mapa11", "mapa12", "mapa13", "mapa14" };
private static final ArrayList<Entry<Position, Position>> carStartAndEndPoints = new ArrayList<Map.Entry<Position, Position>>();
{
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(1140, 1230), new Position(340, 250)));//1
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(830, 1161), new Position(271, 397)));//12
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(101, 769), new Position(1027, 381)));//2
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(1231, 875), new Position(237, 555)));//3
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(1215, 1140), new Position(1115, 230)));//14
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(1233, 1075), new Position(589, 885)));//5
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(725, 1230), new Position(465, 230)));//13
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(205, 1049), new Position(1080, 297)));//6
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(180, 1200), new Position(1050, 220)));//7
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(291, 1213), new Position(987, 211)));//8
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(791, 1161), new Position(271, 397)));//9
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(1163, 1083), new Position(263, 193)));//10
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(100, 1220), new Position(1140, 350)));//4
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(233, 1200), new Position(415, 210)));//11
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(1215, 1140), new Position(1115, 230)));//5
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(101, 769), new Position(1027, 381)));//3
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(1231, 875), new Position(237, 555)));//4
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(830, 1161), new Position(271, 397)));//2
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(1233, 1075), new Position(589, 885)));//6
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(725, 1230), new Position(465, 230)));//7
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(205, 1049), new Position(1080, 297)));//8
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(180, 1200), new Position(1050, 220)));//9
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(291, 1213), new Position(987, 211)));//10
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(791, 1161), new Position(271, 397)));//11
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(1163, 1083), new Position(263, 193)));//12
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(100, 1220), new Position(1140, 350)));//13
carStartAndEndPoints.add(new AbstractMap.SimpleEntry<Position, Position>(new Position(233, 1200), new Position(415, 210)));//14
}
......@@ -275,9 +280,9 @@ public class PronasledovaniActivity extends GameActivity implements IOnSceneTouc
if (lastGameManager != null) {
int lastPlayedMapID = lastGameManager.getExtraInt1();
Log.d("MAPID", Integer.toString(lastPlayedMapID));
textureID = (lastPlayedMapID == MAPSCOUNT) ? 1 : lastPlayedMapID + 1;
textureID = (lastPlayedMapID == (MAPSCOUNT - 1)) ? 0 : lastPlayedMapID + 1;
} else {
textureID = 1;// pokud jde o prvni hranou hru, nastavi se ID textury na 1
textureID = 0;// pokud jde o prvni hranou hru, nastavi se ID textury na 0
}
coordinationArrayPointer = 0;
......@@ -294,9 +299,8 @@ public class PronasledovaniActivity extends GameActivity implements IOnSceneTouc
secondFingerCoordinates = new PointerCoords();
initialFirstFingerPosition = new Position(0, 0);
initialSecondFingerPosition = new Position(0, 0);
// Nastaveni těchto proměnných pouze v případě, že hra nebyla
// nahrána z
// předchozího stavu
//hra byla obnovena
if (!gameLoadedFromPreviousState) {
gridSize = DIFFICULTIES[getDifficulty().ordinal()];
gameTime = 0;
......@@ -305,7 +309,8 @@ public class PronasledovaniActivity extends GameActivity implements IOnSceneTouc
Log.d((textureID) + ".png");
// vybrani mapy, ktera je aktualne v poradi a pridani do hry
String currentMapName = new String("mapa" + textureID + ".png");
String currentMapName = maps[textureID] + MAP_BITMAPS_EXTENSION;
cardDeckGenerator = new CardDeckGenerator(this, gridSize, currentMapName, getTextureManager(), displaySize, GRID_OFFSET_Y);
cards = cardDeckGenerator.getCards();
mCardTotextureRegionMap = cardDeckGenerator.getmCardTotextureRegionMap();
......@@ -509,9 +514,10 @@ public class PronasledovaniActivity extends GameActivity implements IOnSceneTouc
getGameManager().setExtraInt1AndSave(textureID);
// Zobrazeni a obsluha auticka po dohrani hry
String currentRedMapName = new String("pronasledovani/textures/mapa" + textureID + "red.png");
String currentRedMapName = BASE_DIR + TEXTURES_DIR + maps[textureID] + "red" + MAP_BITMAPS_EXTENSION;
Log.d(TAG, "Loading red bitmap: " + currentRedMapName);
Entry<Position, Position> carCoords = carStartAndEndPoints.get(textureID - 1);
Entry<Position, Position> carCoords = carStartAndEndPoints.get(textureID);
Position startPosition = carCoords.getKey();
Position endPosition = carCoords.getValue();
// Prepocet startovnich pozic dle aktualnich rozmeru displeje
......@@ -528,7 +534,7 @@ public class PronasledovaniActivity extends GameActivity implements IOnSceneTouc
Position translatedPosFlag = PronasledovaniHelper.translatePositionAccordingToRotation(new Position(flagStartPosX, flagStartPosY), cards.get(0).getRotation() * 90, new Position(
displaySize.x / 2, displaySize.y / 2));
vehicleType = getVehicleTypeByMap(textureID);
vehicleType = getVehicleTypeByMap(maps[textureID]);
vehicleTextureRegion = texturesGenerator.getRandomVehicleTextureRegion(vehicleType);
......@@ -1261,17 +1267,12 @@ public class PronasledovaniActivity extends GameActivity implements IOnSceneTouc
super.onDrawerSlide(drawerView, slideOffset);
}
private VehicleTypeEnum getVehicleTypeByMap(int textureID) {
// vozitko
switch (textureID) {
case 2:
case 13:
return VehicleTypeEnum.BOAT;
case 7:
return VehicleTypeEnum.TRAIN;
default:
return random.nextBoolean() ? VehicleTypeEnum.CAR : VehicleTypeEnum.MOTORCYCLE;
private VehicleTypeEnum getVehicleTypeByMap(String mapName) {
if (mapName.equals("mapa2") || mapName.equals("mapa13")) {
return VehicleTypeEnum.BOAT;
} else if (mapName.equals("mapa7")) {
return VehicleTypeEnum.TRAIN;
}
return random.nextBoolean() ? VehicleTypeEnum.CAR : VehicleTypeEnum.MOTORCYCLE;
}
}
......@@ -52,7 +52,7 @@ public class SwipeMenuFragment extends AbstractMenuFragment {
private static final long FINGER_UP_ANIMATION_TIME = 500;
private static final long FINGER_LEFT_ANIMATION_TIME = 1000;
private static final float FINGER_ACCELERATION_FACTOR = 2.5f;
private static final int FINDER_ANIM_DELAY = 5000;
private static final int FINGER_ANIM_DELAY = 5000;
private Display display;
private Point displaySize;
......@@ -94,7 +94,7 @@ public class SwipeMenuFragment extends AbstractMenuFragment {
@Override
public boolean onTouch(View v, MotionEvent event) {
stopHintFingerAnimation();
handler.postDelayed(bounceRunnable, FINDER_ANIM_DELAY);
handler.postDelayed(bounceRunnable, FINGER_ANIM_DELAY);
return false;
}
});
......@@ -214,7 +214,7 @@ public class SwipeMenuFragment extends AbstractMenuFragment {
fingerHint.setTranslationX(displaySize.x / 4);
fingerHint.setTranslationY(displaySize.y);
handler.postDelayed(bounceRunnable, FINDER_ANIM_DELAY);
handler.postDelayed(bounceRunnable, FINGER_ANIM_DELAY);
}
@Override
......
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