You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.2 KiB
69 lines
2.2 KiB
//Only change if added more cases in LevelSwitcher
|
|
var levelCount = 5;
|
|
|
|
//Global: Amount of reached levels
|
|
var levelReached = null;
|
|
|
|
//Global: Erases every Cookie and starts Level 1 with 0 levelReached
|
|
function deleteMemory(){
|
|
clearStorage();
|
|
currentGame.totalBricksDestroyed = getTotalBricksDestroyed(currentGame.levelNum);
|
|
currentGame.recordTime = getRecordTime(currentGame.levelNum);
|
|
setRekordInfo();
|
|
$("#currentLevel").text("1");
|
|
checkLevelButtons(1);
|
|
currentGame = new Level(1);
|
|
}
|
|
|
|
//Level: Returns the shortest time ever played on that level
|
|
function getRecordTime(level){
|
|
var time = getItem("rekordTime" + level);
|
|
time = time == null ? Infinity : parseInt(time);
|
|
return time;
|
|
}
|
|
|
|
//Global: Returns the total time played from every level
|
|
function getTotalTimePlayed(){
|
|
var time = getItem("totalTimePlayed");
|
|
time = time == null ? 0 : parseInt(time);
|
|
return time;
|
|
}
|
|
|
|
//Level: Returns the total amount of destroyed bricks of that level
|
|
function getTotalBricksDestroyed(level){
|
|
var bricks = getItem("totalBricksDestroyed" + level);
|
|
bricks = bricks == null ? 0 : parseInt(bricks);
|
|
return bricks;
|
|
}
|
|
|
|
//Global: Returns the total global amount of destroyed bricks
|
|
function getTotalBricksDestroyedGlobal(){
|
|
var totalBricks = 0;
|
|
for (var i = 1; i <= levelCount; i++){
|
|
var bricks = getItem("totalBricksDestroyed" + i);
|
|
bricks = bricks == null ? 0 : parseInt(bricks);
|
|
totalBricks += bricks;
|
|
}
|
|
return totalBricks;
|
|
}
|
|
|
|
//Level: Sets a new record time for a specific level
|
|
function setRecordTime(level, time){
|
|
//storeItem("rekordTime" + level, String(time), 10);
|
|
time = toTimeString(time);
|
|
$("#rekordInfo table:eq(1) tr:eq(" + level + ") td:eq(2)").text(time);
|
|
}
|
|
|
|
//Global: Sets the total time played from every level
|
|
function setTotalTimePlayed(time){
|
|
//storeItem("totalTimePlayed", String(time), 10);
|
|
time = toTimeString(time, true);
|
|
$("#totalTimePlayed").text(time);
|
|
}
|
|
|
|
//Level: Sets the total amount of destroyed bricks for a specific level
|
|
function setTotalBricksDestroyed(level, bricks){
|
|
//storeItem("totalBricksDestroyed" + level, String(bricks), 10);
|
|
$("#rekordInfo table:eq(1) tr:eq(" + level + ") td:eq(0)").text(bricks);
|
|
$("#totalBricksDestroyed").text(getTotalBricksDestroyedGlobal());
|
|
} |