Merge pull request #311 from ckcz123/v2.0

V2.0
This commit is contained in:
Zhang Chen 2019-01-25 00:56:23 +08:00 committed by GitHub
commit 403d5f2603
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 94 additions and 64 deletions

View File

@ -442,6 +442,7 @@
<img class="tools" id='img-fly'>
<img class="tools" id='img-toolbox'>
<img class="tools" id='img-keyboard'>
<img class="tools" id='img-shop'>
<img class="tools" id='img-save'>
<img class="tools" id='img-load'>
<img class="tools" id='img-settings'>
@ -452,6 +453,7 @@
<img class="tools" id='img-btn5' style='display:none'>
<img class="tools" id='img-btn6' style='display:none'>
<img class="tools" id='img-btn7' style='display:none'>
<img class="tools" id='img-btn8' style='display:none'>
<p class="statusLabel tools" id="hard"></p>
</div>
<div id="gameDraw">

View File

@ -425,6 +425,7 @@
<img class="tools" id='img-fly'>
<img class="tools" id='img-toolbox'>
<img class="tools" id='img-keyboard'>
<img class="tools" id='img-shop'>
<img class="tools" id='img-save'>
<img class="tools" id='img-load'>
<img class="tools" id='img-settings'>
@ -435,6 +436,7 @@
<img class="tools" id='img-btn5' style='display:none'>
<img class="tools" id='img-btn6' style='display:none'>
<img class="tools" id='img-btn7' style='display:none'>
<img class="tools" id='img-btn8' style='display:none'>
<p class="statusLabel tools" id="hard"></p>
</div>
<div id="gameDraw">

View File

@ -119,6 +119,7 @@
<img class="tools" id='img-fly'>
<img class="tools" id='img-toolbox'>
<img class="tools" id='img-keyboard'>
<img class="tools" id='img-shop'>
<img class="tools" id='img-save'>
<img class="tools" id='img-load'>
<img class="tools" id='img-settings'>
@ -129,6 +130,7 @@
<img class="tools" id='img-btn5' style='display:none'>
<img class="tools" id='img-btn6' style='display:none'>
<img class="tools" id='img-btn7' style='display:none'>
<img class="tools" id='img-btn8' style='display:none'>
<p class="statusLabel tools" id="hard"></p>
</div>
<div id="gameDraw">

View File

@ -2746,6 +2746,7 @@ actions.prototype.exitPaint = function () {
core.deleteCanvas('paint');
core.ui.closePanel();
core.statusBar.image.keyboard.style.opacity = 1;
core.statusBar.image.shop.style.opacity = 1;
core.updateStatusBar();
core.drawTip("退出绘图模式");
}

View File

@ -44,12 +44,17 @@ control.prototype.setRequestAnimationFrame = function () {
}
}());
core.animateFrame.totalTime = Math.max(core.animateFrame.totalTime, core.getLocalStorage('totalTime', 0));
var draw = function(timestamp) {
core.animateFrame.totalTime += timestamp - core.animateFrame.totalTimeStart;
core.animateFrame.totalTimeStart = timestamp;
// move time
if (core.isPlaying() && core.isset(core.status) && core.isset(core.status.hero)
&& core.isset(core.status.hero.statistics)) {
core.status.hero.statistics.totalTime += timestamp-(core.status.hero.statistics.start||timestamp);
core.status.hero.statistics.totalTime = core.animateFrame.totalTime;
core.status.hero.statistics.currTime += timestamp-(core.status.hero.statistics.start||timestamp);
core.status.hero.statistics.start=timestamp;
}
@ -380,11 +385,7 @@ control.prototype.clearStatus = function() {
////// 重置游戏状态和初始数据 //////
control.prototype.resetStatus = function(hero, hard, floorId, route, maps, values) {
var totalTime=0;
if (core.isset(core.status) && core.isset(core.status.hero)
&& core.isset(core.status.hero.statistics) && core.isset(route)) {
totalTime=core.status.hero.statistics.totalTime;
}
var totalTime = core.animateFrame.totalTime;
// 清除游戏数据
core.clearStatus();
@ -417,7 +418,8 @@ control.prototype.resetStatus = function(hero, hard, floorId, route, maps, value
'moveDirectly': 0,
'ignoreSteps': 0,
}
core.status.hero.statistics.totalTime = Math.max(core.status.hero.statistics.totalTime, totalTime);
core.status.hero.statistics.totalTime = core.animateFrame.totalTime =
Math.max(core.status.hero.statistics.totalTime, core.animateFrame.totalTime);
core.status.hero.statistics.start = null;
core.status.hard = hard;
@ -2054,16 +2056,9 @@ control.prototype.openQuickShop = function (need) {
control.prototype.openKeyBoard = function (need) {
if (core.isReplaying()) return;
if (core.platform.extendKeyboard) {
if (!core.checkStatus('keyBoard', need))
return;
core.ui.drawKeyBoard();
}
else {
if (!core.checkStatus('selectShop', need))
return;
core.ui.drawQuickShop();
}
}
////// 点击保存按钮时的打开操作 //////
@ -2139,6 +2134,8 @@ control.prototype.autosave = function (removeLast) {
/////// 实际进行自动存档 //////
control.prototype.checkAutosave = function () {
core.setLocalStorage('totalTime', core.animateFrame.totalTime);
if (core.saves.autosave.data == null || !core.saves.autosave.updated) return;
core.saves.autosave.updated = false;
core.setLocalForage("autoSave", core.saves.autosave.data);
@ -2725,6 +2722,7 @@ control.prototype.updateStatusBar = function () {
core.statusBar.image.toolbox.src = core.statusBar.icons.rewind.src;
core.statusBar.image.keyboard.src = core.statusBar.icons.book.src;
core.statusBar.image.shop.style.opacity = 0;
core.statusBar.image.save.src = core.statusBar.icons.speedDown.src;
@ -2748,8 +2746,8 @@ control.prototype.updateStatusBar = function () {
core.statusBar.image.toolbox.src = core.statusBar.icons.toolbox.src;
core.statusBar.image.keyboard.src =
core.platform.extendKeyboard ? core.statusBar.icons.keyboard.src : core.statusBar.icons.shop.src;
core.statusBar.image.keyboard.src = core.statusBar.icons.keyboard.src;
core.statusBar.image.shop.style.opacity = 1;
core.statusBar.image.save.src = core.statusBar.icons.save.src;
@ -2886,21 +2884,23 @@ control.prototype.setToolbarButton = function (useButton) {
core.domStyle.toolbarBtn = useButton;
if (useButton) {
["book","fly","toolbox","keyboard","save","load","settings"].forEach(function (t) {
["book","fly","toolbox","keyboard","shop","save","load","settings"].forEach(function (t) {
core.statusBar.image[t].style.display = 'none';
});
["btn1","btn2","btn3","btn4","btn5","btn6","btn7"].forEach(function (t) {
["btn1","btn2","btn3","btn4","btn5","btn6","btn7","btn8"].forEach(function (t) {
core.statusBar.image[t].style.display = 'block';
})
}
else {
["btn1","btn2","btn3","btn4","btn5","btn6","btn7"].forEach(function (t) {
["btn1","btn2","btn3","btn4","btn5","btn6","btn7","btn8"].forEach(function (t) {
core.statusBar.image[t].style.display = 'none';
});
["book","fly","toolbox","keyboard","save","load","settings"].forEach(function (t) {
["book","fly","toolbox","save","load","settings"].forEach(function (t) {
core.statusBar.image[t].style.display = 'block';
});
core.statusBar.image.keyboard.style.display = core.domStyle.isVertical ? "block":"none";
core.statusBar.image.keyboard.style.display
= core.statusBar.image.shop.style.display
= core.domStyle.isVertical ? "block":"none";
}
}
@ -3029,13 +3029,13 @@ control.prototype.resize = function(clientWidth, clientHeight) {
toolBarTop = statusBarHeight + canvasWidth;
toolBarBorder = '3px '+borderColor+' solid';
toolsHeight = scale * BASE_LINEHEIGHT;
toolsHeight = scale * BASE_LINEHEIGHT * 0.95;
toolsPMaxwidth = scale * DEFAULT_BAR_WIDTH * .4;
toolsBackground = (core.status.globalAttribute||core.initStatus.globalAttribute).toolsBackground;
borderRight = '3px '+borderColor+' solid';
margin = scale * SPACE * 2;
toolsMargin = scale * SPACE * 4;
toolsMargin = scale * SPACE * 3;
fontSize = DEFAULT_FONT_SIZE * scale;
toolbarFontSize = DEFAULT_FONT_SIZE * scale;
musicBtnRight = 3;

View File

@ -28,6 +28,8 @@ function core() {
'onDownInterval': null,
}
this.animateFrame = {
'totalTime': 0,
'totalTimeStart': 0,
'globalAnimate': false,
'globalTime': 0,
'selectorTime': 0,

View File

@ -2044,7 +2044,7 @@ ui.prototype.drawToolbox = function(index) {
var text = item.text||"该道具暂无描述。";
try {
// 检查能否eval
text = eval(text);
text = core.replaceText(text);
} catch (e) {}
var lines = core.splitLines('ui', text, 406, '17px '+globalFont);
@ -2195,6 +2195,9 @@ ui.prototype.drawEquipbox = function(index) {
core.fillText('ui', equip.name + "" + equipString + "", 10, 32, '#FFD700', "bold 20px "+globalFont)
var text = equip.text||"该装备暂无描述。";
try {
text = core.replaceText(text);
} catch (e) {}
var lines = core.splitLines('ui', text, 406, '17px '+globalFont);
core.fillText('ui', lines[0], 10, 62, '#FFFFFF', '17px '+globalFont);
@ -2833,6 +2836,7 @@ ui.prototype.drawPaint = function () {
core.setStrokeStyle('paint', '#FF0000');
core.statusBar.image.keyboard.style.opacity = 0;
core.statusBar.image.shop.style.opacity = 0;
core.statusBar.image.book.src = core.statusBar.icons.paint.src;
core.statusBar.image.fly.src = core.statusBar.icons.erase.src;

View File

@ -226,21 +226,21 @@ utils.prototype.getLocalForage = function (key, defaultValue, successCallback, e
if (core.isset(errorCallback)) errorCallback(err);
}
else {
if (!core.isset(successCallback)) return;
if (core.isset(value)) {
try {
var output = LZString.decompress(value);
if (core.isset(output) && output.length>0) {
try {
if (core.isset(successCallback))
successCallback(JSON.parse(output));
return;
} catch (ee) {main.log(ee);}
}
catch (ee) {main.log(ee);}
}
if (core.isset(successCallback))
successCallback(JSON.parse(value));
return;
}
if (core.isset(successCallback))
catch (e) {main.log(e);}
}
successCallback(defaultValue);
}
})

66
main.js
View File

@ -100,6 +100,7 @@ function main() {
'fly': document.getElementById("img-fly"),
'toolbox': document.getElementById("img-toolbox"),
'keyboard': document.getElementById("img-keyboard"),
'shop': document.getElementById('img-shop'),
'save': document.getElementById("img-save"),
'load': document.getElementById("img-load"),
'settings': document.getElementById("img-settings"),
@ -109,7 +110,8 @@ function main() {
'btn4': document.getElementById("img-btn4"),
'btn5': document.getElementById("img-btn5"),
'btn6': document.getElementById("img-btn6"),
'btn7': document.getElementById("img-btn7")
'btn7': document.getElementById("img-btn7"),
'btn8': document.getElementById("img-btn8"),
},
'icons': {
'floor': 0,
@ -127,30 +129,31 @@ function main() {
'fly': 11,
'toolbox': 12,
'keyboard': 13,
'save': 14,
'load': 15,
'settings': 16,
'play': 17,
'pause': 18,
'stop': 19,
'speedDown': 20,
'speedUp': 21,
'rewind': 22,
'equipbox': 23,
'mana': 24,
'skill': 25,
'paint': 26,
'erase': 27,
'empty': 28,
'exit': 29,
'btn1': 30,
'btn2': 31,
'btn3': 32,
'btn4': 33,
'btn5': 34,
'btn6': 35,
'btn7': 36,
'shop': 37
'shop': 14,
'save': 15,
'load': 16,
'settings': 17,
'play': 18,
'pause': 19,
'stop': 20,
'speedDown': 21,
'speedUp': 22,
'rewind': 23,
'equipbox': 24,
'mana': 25,
'skill': 26,
'paint': 27,
'erase': 28,
'empty': 29,
'exit': 30,
'btn1': 31,
'btn2': 32,
'btn3': 33,
'btn4': 34,
'btn5': 35,
'btn6': 36,
'btn7': 37,
'btn8': 38
},
'floor': document.getElementById('floor'),
'name': document.getElementById('name'),
@ -509,6 +512,14 @@ main.statusBar.image.keyboard.onclick = function (e) {
main.core.openKeyBoard(true);
}
////// 点击状态栏中的快捷商店键盘时 //////
main.statusBar.image.shop.onclick = function (e) {
e.stopPropagation();
if (main.core.isPlaying())
main.core.openQuickShop(true);
}
////// 点击状态栏中的存档按钮时 //////
main.statusBar.image.save.onclick = function (e) {
e.stopPropagation();
@ -606,6 +617,11 @@ main.statusBar.image.btn7.onclick = function (e) {
main.core.onkeyUp({"keyCode": 55});
};
main.statusBar.image.btn8.onclick = function (e) {
e.stopPropagation();
main.core.onkeyUp({"keyCode": 56});
};
////// 点击“开始游戏”时 //////
main.dom.playGame.onclick = function () {
main.dom.startButtons.style.display='none';

View File

@ -1181,7 +1181,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
'yellowKey', 'blueKey', 'redKey', 'greenKey', 'steelKey',
'redJewel', 'blueJewel', 'greenJewel', 'yellowJewel',
'redPotion', 'bluePotion', 'greenPotion', 'yellowPotion', 'superPotion',
'pickaxe', 'bomb', 'centerFly',
'pickaxe', 'bomb', 'centerFly', 'icePickaxe', 'snow',
'earthquake', 'upFly', 'downFly', 'jumpShoes', 'lifeWand',
'poisonWine', 'weakWine', 'curseWine', 'superWine',
'sword1', 'sword2', 'sword3', 'sword4', 'sword5',
'shield1', 'shield2', 'shield3', 'shield4', 'shield5',

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB