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

Ukladani stavu

parent d566f40d
......@@ -61,6 +61,9 @@ import android.text.SpannableStringBuilder;
import android.text.style.ImageSpan;
import android.util.Log;
import android.util.Pair;
import com.bugsense.trace.BugSenseHandler;
import cz.nic.tablexia.R;
import cz.nic.tablexia.game.GameActivity;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
......@@ -78,11 +81,20 @@ import cz.nic.tablexia.game.games.strelnice.model.Target;
import cz.nic.tablexia.game.games.strelnice.model.Target.OnTargetAreaTouchedListener;
import cz.nic.tablexia.game.games.strelnice.model.Wave;
import cz.nic.tablexia.util.ScalingHelper;
import cz.nic.tablexia.util.SerializableHelper;
public class StrelniceActivity extends GameActivity implements OnTargetAreaTouchedListener {
private static final String TAG = StrelniceActivity.class.getSimpleName();
public static final String BASE_DIR = "strelnice/";
private static final String GAMESTATE_FLOWERS = "gamestate_map";
private static final String GAMESTATE_TIME = "gamestate_time";
private static final String GAMESTATE_FULL_TIME = "gamestate_fulltime";
private static final String GAMESTATE_SCORE = "gamestate_score";
private static final String GAMESTATE_ERROR = "gamestate_error";
private static final String GAMESTATE_HITS = "gamestate_hits";
private static final String GAMESTATE_BOXES = "gamestate_boxes";
public static final int[] CUPS = { 20, 40, 70 };
private static final int CAMERA_WIDTH = 1280;
......@@ -142,6 +154,20 @@ public class StrelniceActivity extends GameActivity implements OnTargetAreaTouch
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
try {
String targetsB64 = SerializableHelper.toString((ArrayList<Target>) targets);
// TODO čas
// TODO skore
// statistiky
} catch (IOException e) {
Log.e(TAG, "Error saving state" + e.getMessage());
BugSenseHandler.sendException(e);
}
}
@Override
public Camera onCreateCamera() {
float scale = displaySize.x / (float) displaySize.y;
......
......@@ -12,16 +12,17 @@ import org.andengine.engine.handler.IUpdateHandler;
* @author lhoracek
*/
public abstract class GameOverUpdateHandler implements IUpdateHandler {
private static final String TAG = TargetPositionUpdateHandler.class.getSimpleName();
private static final String TAG = TargetPositionUpdateHandler.class.getSimpleName();
public static final float ADD_TIME = 5f;
public static final float SUB_TIME = 5f;
public static final float ADD_TIME = 5f;
public static final float SUB_TIME = 5f;
private float elapsedTime = 0;
private float elapsedTime = 0;
private float fullElapsedTime = 0;
private float gameTime;
private boolean done = false;
private boolean running = false;
private float gameSpeed = 1;
private boolean done = false;
private boolean running = false;
private float gameSpeed = 1;
public void setGameSpeed(float gameSpeed) {
this.gameSpeed = gameSpeed;
......@@ -41,6 +42,7 @@ public abstract class GameOverUpdateHandler implements IUpdateHandler {
if (!running) {
onTimeStart();
}
fullElapsedTime += pSecondsElapsed;
elapsedTime += (pSecondsElapsed * gameSpeed);
if (!done) {
if (elapsedTime >= gameTime) {
......
/**
*
*/
package cz.nic.tablexia.game.games.strelnice.gamestate;
import java.io.Serializable;
/**
* @author lhoracek
*/
public class GameState implements Serializable {
private Float fullTime = 0f;
private Float time = 0f;
private Long boxesGood = 0l;
private Long boxesBad = 0l;
private Long errors = 0l;
public GameState() {
super();
// TODO Auto-generated constructor stub
}
public GameState(Float fullTime, Float time, Long boxesGood, Long boxesBad, Long errors) {
super();
this.fullTime = fullTime;
this.time = time;
this.boxesGood = boxesGood;
this.boxesBad = boxesBad;
this.errors = errors;
}
public Float getFullTime() {
return fullTime;
}
public void setFullTime(Float fullTime) {
this.fullTime = fullTime;
}
public Float getTime() {
return time;
}
public void setTime(Float time) {
this.time = time;
}
public Long getBoxesGood() {
return boxesGood;
}
public void setBoxesGood(Long boxesGood) {
this.boxesGood = boxesGood;
}
public Long getBoxesBad() {
return boxesBad;
}
public void setBoxesBad(Long boxesBad) {
this.boxesBad = boxesBad;
}
public Long getErrors() {
return errors;
}
public void setErrors(Long errors) {
this.errors = errors;
}
}
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