|
@ -21,6 +21,10 @@ window.addEventListener( |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function startGame(data) { |
|
|
function startGame(data) { |
|
|
|
|
|
if (state === 2) { |
|
|
|
|
|
location.reload(); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
const { count, game, status, param } = data; |
|
|
const { count, game, status, param } = data; |
|
|
config.count = count.duration; |
|
|
config.count = count.duration; |
|
|
config.duration = game.duration; |
|
|
config.duration = game.duration; |
|
@ -28,7 +32,6 @@ window.addEventListener( |
|
|
config.times = game.totalTimes; |
|
|
config.times = game.totalTimes; |
|
|
config.level = game.level; |
|
|
config.level = game.level; |
|
|
config.config = game.config; |
|
|
config.config = game.config; |
|
|
state = status; |
|
|
|
|
|
|
|
|
|
|
|
window.timeInstance.setDuration(game.duration); |
|
|
window.timeInstance.setDuration(game.duration); |
|
|
// 开始倒计时
|
|
|
// 开始倒计时
|
|
@ -36,10 +39,11 @@ window.addEventListener( |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function playGame(data) { |
|
|
function playGame(data) { |
|
|
|
|
|
if (state !== 1) return; |
|
|
const { score, times, status, param } = data; |
|
|
const { score, times, status, param } = data; |
|
|
state = status; |
|
|
|
|
|
config.currentScore = score; |
|
|
config.currentScore = score; |
|
|
config.currentTimes = times; |
|
|
config.currentTimes = times; |
|
|
|
|
|
state = status; |
|
|
if (config.config.directions[times - 1] === param.direction) { |
|
|
if (config.config.directions[times - 1] === param.direction) { |
|
|
main.play(); |
|
|
main.play(); |
|
|
} else { |
|
|
} else { |
|
@ -48,12 +52,14 @@ window.addEventListener( |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function pauseGame(data) { |
|
|
function pauseGame(data) { |
|
|
|
|
|
if (state !== 1) return; |
|
|
state = data.status; |
|
|
state = data.status; |
|
|
Suspend.of(); |
|
|
Suspend.of(); |
|
|
window.timeInstance.pause(); |
|
|
window.timeInstance.pause(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function continueGame(data) { |
|
|
function continueGame(data) { |
|
|
|
|
|
if (state !== 3) return; |
|
|
state = data.status; |
|
|
state = data.status; |
|
|
window.timeInstance.start(); |
|
|
window.timeInstance.start(); |
|
|
} |
|
|
} |
|
@ -63,6 +69,8 @@ window.addEventListener( |
|
|
state = status; |
|
|
state = status; |
|
|
config.total = score; |
|
|
config.total = score; |
|
|
config.times = times; |
|
|
config.times = times; |
|
|
|
|
|
End.of(score || 0); |
|
|
|
|
|
window.timeInstance.setDuration(0); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
false, |
|
|
false, |
|
|