2014-05-26 01:59:33 +00:00
|
|
|
function exportSaveState() {
|
2014-05-26 03:52:35 +00:00
|
|
|
var state = {};
|
2014-06-24 13:42:38 +00:00
|
|
|
|
2014-06-28 01:19:57 +00:00
|
|
|
if(gameState == 1 || gameState == -1 || (gameState === 0 && localStorage.getItem('saveState') !== undefined)) {
|
2014-05-26 03:52:35 +00:00
|
|
|
state = {
|
2014-07-04 16:47:37 +00:00
|
|
|
hex: $.extend(true, {}, MainHex),
|
2014-06-28 17:44:43 +00:00
|
|
|
blocks: $.extend(true, [], blocks),
|
2014-05-26 03:52:35 +00:00
|
|
|
score: score,
|
|
|
|
wavegen: waveone,
|
|
|
|
gdx: gdx,
|
|
|
|
gdy: gdy,
|
2014-07-04 16:42:22 +00:00
|
|
|
comboTime:settings.comboTime
|
2014-06-28 01:19:57 +00:00
|
|
|
};
|
2014-06-28 15:57:22 +00:00
|
|
|
|
2014-07-04 16:47:37 +00:00
|
|
|
state.hex.blocks.map(function(a){
|
2014-06-28 17:44:43 +00:00
|
|
|
for (var i = 0; i < a.length; i++) {
|
|
|
|
a[i] = $.extend(true, {}, a[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
a.map(descaleBlock);
|
|
|
|
});
|
|
|
|
|
|
|
|
for (var i = 0; i < state.blocks.length; i++) {
|
|
|
|
state.blocks[i] = $.extend(true, {}, state.blocks[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
state.blocks.map(descaleBlock);
|
2014-05-26 01:59:33 +00:00
|
|
|
}
|
|
|
|
|
2014-07-24 15:16:53 +00:00
|
|
|
localStorage.setItem('highscores', JSON.stringify(highscores));
|
|
|
|
|
2014-05-26 03:52:35 +00:00
|
|
|
return JSONfn.stringify(state);
|
|
|
|
}
|
2014-05-26 05:11:13 +00:00
|
|
|
|
2014-06-28 17:44:43 +00:00
|
|
|
function descaleBlock(b) {
|
|
|
|
b.distFromHex /= settings.scale;
|
|
|
|
}
|
|
|
|
|
2014-07-26 13:23:03 +00:00
|
|
|
function writeHighScores() {
|
|
|
|
if (Object.prototype.toString.call(highscores) === '[object Array]') {
|
|
|
|
localStorage.setItem("highscores", JSON.stringify(highscores));
|
|
|
|
} else {
|
|
|
|
debugger;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-26 05:11:13 +00:00
|
|
|
function clearSaveState() {
|
2014-06-28 17:44:43 +00:00
|
|
|
localStorage.setItem("saveState", "{}");
|
2014-05-26 05:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function isStateSaved() {
|
2014-07-05 13:57:51 +00:00
|
|
|
return localStorage.getItem("saveState") != "{}" && localStorage.getItem("saveState") != undefined;
|
2014-05-30 23:06:16 +00:00
|
|
|
}
|