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.
58 lines
1.0 KiB
58 lines
1.0 KiB
4 years ago
|
// 判断是否在演示模式 能否直接开始游戏
|
||
|
function isHash() {
|
||
|
if (location.hash && location.hash === '#p') {
|
||
|
isDemo = true;
|
||
|
Demo.of();
|
||
|
Count.of(countOver);
|
||
|
} else {
|
||
|
// 连点7次触发倒计时
|
||
|
startGame();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function startGame() {
|
||
|
var count = 0,
|
||
|
timer;
|
||
|
document.onclick = function () {
|
||
|
if (isDemo || config.mode !== 1) return;
|
||
|
if (count < 6) {
|
||
|
if (timer) {
|
||
|
clearTimeout(timer);
|
||
|
}
|
||
|
count++;
|
||
|
timer = setTimeout(function () {
|
||
|
count = 0;
|
||
|
}, 300);
|
||
|
} else if (count === 6) {
|
||
|
count = 0;
|
||
|
clearTimeout(timer);
|
||
|
sevenClick();
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function sevenClick() {
|
||
|
isDemo = true;
|
||
|
Count.of(countOver);
|
||
|
addHash();
|
||
|
}
|
||
|
|
||
|
// 倒计时结束 开始游戏
|
||
|
function countOver() {
|
||
|
timeInstance.start();
|
||
|
}
|
||
|
|
||
|
// 添加hash值
|
||
|
function addHash() {
|
||
|
location.hash = '#p';
|
||
|
Demo.of();
|
||
|
}
|
||
|
|
||
|
function test() {
|
||
|
document.addEventListener('click', () => {
|
||
|
if (!isDemo) return;
|
||
|
main.play(config.config.directions[config.currentTimes]);
|
||
|
});
|
||
|
}
|
||
|
test();
|