From 276144a1df60d8f0a9f2634bfec27cbcd152f5c2 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Wed, 25 Apr 2018 21:42:24 +0800 Subject: [PATCH] Save while replaying --- README.md | 11 +++++++++++ libs/actions.js | 22 ++++++++++++---------- libs/control.js | 33 ++++++++++++++++++++++++++++----- libs/core.js | 5 +++++ libs/ui.js | 8 +++----- main.js | 6 ++++++ 更新说明.txt | 16 ++++++++-------- 7 files changed, 73 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index e84d092e..4f4c4f88 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,17 @@ HTML5 canvas制作的魔塔样板,支持全平台游戏! ## 更新说明 +### 2018.4.25 V2.1.1 + +* [x] 新增事件:改变勇士行走图 +* [x] 楼传器落点设置 +* [x] 录像回放从任意存档点开始 +* [x] 录像过程中允许存档 +* [x] 血网显伤 +* [x] 重置当前楼层地图core.resetMap() +* [x] 支持部分楼层不允许浏览地图 +* [x] 其他细节优化 + ### 2018.4.19 V2.1 * [x] 编辑器添加新建和删除按钮;地图自动保存 diff --git a/libs/actions.js b/libs/actions.js index 9b35ece8..eb98a683 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -13,7 +13,7 @@ actions.prototype.init = function () { ////// 按下某个键时 ////// actions.prototype.onkeyDown = function (e) { - if (core.isset(core.status.replay)&&core.status.replay.replaying) return; + if (core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!='save') return; if (!core.isset(core.status.holdingKeys))core.status.holdingKeys=[]; var isArrow={37:true,38:true,39:true,40:true}[e.keyCode] if(isArrow && !core.status.lockControl){ @@ -31,7 +31,7 @@ actions.prototype.onkeyDown = function (e) { ////// 放开某个键时 ////// actions.prototype.onkeyUp = function(e) { - if (core.isset(core.status.replay)&&core.status.replay.replaying) { + if (core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!='save') { if (e.keyCode==27) // ESCAPE core.stopReplay(); else if (e.keyCode==90) // Z @@ -42,6 +42,8 @@ actions.prototype.onkeyUp = function(e) { core.triggerReplay(); else if (e.keyCode==65) // A core.rewindReplay(); + else if (e.keyCode==83) + core.saveReplay(); return; } @@ -62,7 +64,7 @@ actions.prototype.onkeyUp = function(e) { ////// 按住某个键时 ////// actions.prototype.pressKey = function (keyCode) { - if (core.isset(core.status.replay)&&core.status.replay.replaying) return; + if (core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!='save') return; if (keyCode === core.status.holdingKeys.slice(-1)[0]) { this.keyDown(keyCode); window.setTimeout(function(){core.pressKey(keyCode);},30); @@ -71,7 +73,7 @@ actions.prototype.pressKey = function (keyCode) { ////// 根据按下键的code来执行一系列操作 ////// actions.prototype.keyDown = function(keyCode) { - if (core.isset(core.status.replay)&&core.status.replay.replaying) return; + if (core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!='save') return; if (core.status.lockControl) { // Ctrl跳过对话 if (keyCode==17) { @@ -191,7 +193,7 @@ actions.prototype.keyDown = function(keyCode) { ////// 根据放开键的code来执行一系列操作 ////// actions.prototype.keyUp = function(keyCode, fromReplay) { - if (!fromReplay&&core.isset(core.status.replay)&&core.status.replay.replaying) return; + if (!fromReplay&&core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!='save') return; if (core.status.lockControl) { core.status.holdingKeys = []; @@ -397,7 +399,7 @@ actions.prototype.keyUp = function(keyCode, fromReplay) { ////// 点击(触摸)事件按下时 ////// actions.prototype.ondown = function (x ,y) { - if (core.isset(core.status.replay)&&core.status.replay.replaying) return; + if (core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!='save') return; if (!core.status.played || core.status.lockControl) { this.onclick(x, y, []); if (core.timeout.onDownTimeout==null) { @@ -425,7 +427,7 @@ actions.prototype.ondown = function (x ,y) { ////// 当在触摸屏上滑动时 ////// actions.prototype.onmove = function (x ,y) { - if (core.isset(core.status.replay)&&core.status.replay.replaying) return; + if (core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!='save') return; // if (core.status.holdingPath==0){return;} //core.status.mouseOutCheck =1; var pos={'x':x,'y':y}; @@ -449,7 +451,7 @@ actions.prototype.onmove = function (x ,y) { ////// 当点击(触摸)事件放开时 ////// actions.prototype.onup = function () { - if (core.isset(core.status.replay)&&core.status.replay.replaying) return; + if (core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!='save') return; clearTimeout(core.timeout.onDownTimeout); core.timeout.onDownTimeout = null; @@ -515,7 +517,7 @@ actions.prototype.getClickLoc = function (x, y) { ////// 具体点击屏幕上(x,y)点时,执行的操作 ////// actions.prototype.onclick = function (x, y, stepPostfix) { - if (core.isset(core.status.replay)&&core.status.replay.replaying) return; + if (core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!='save') return; // console.log("Click: (" + x + "," + y + ")"); stepPostfix=stepPostfix||[]; @@ -669,7 +671,7 @@ actions.prototype.onclick = function (x, y, stepPostfix) { ////// 滑动鼠标滚轮时的操作 ////// actions.prototype.onmousewheel = function (direct) { - if (core.isset(core.status.replay)&&core.status.replay.replaying) return; + if (core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!='save') return; // 向下滚动是 -1 ,向上是 1 // 楼层飞行器 diff --git a/libs/control.js b/libs/control.js index 6e08e974..900441ad 100644 --- a/libs/control.js +++ b/libs/control.js @@ -291,10 +291,6 @@ control.prototype.restart = function() { } - - - - /////////////////////// 寻路算法 & 人物行走控制 /////////////////////// ////// 清除自动寻路路线 ////// @@ -1404,12 +1400,14 @@ control.prototype.startReplay = function (list) { ////// 更改播放状态 ////// control.prototype.triggerReplay = function () { + if (core.status.event.id=='save') return; if (core.status.replay.pausing) this.resumeReplay(); else this.pauseReplay(); } ////// 暂停播放 ////// control.prototype.pauseReplay = function () { + if (core.status.event.id=='save') return; if (!core.status.replay.replaying) return; core.status.replay.pausing = true; core.updateStatusBar(); @@ -1418,6 +1416,7 @@ control.prototype.pauseReplay = function () { ////// 恢复播放 ////// control.prototype.resumeReplay = function () { + if (core.status.event.id=='save') return; if (!core.status.replay.replaying) return; core.status.replay.pausing = false; core.updateStatusBar(); @@ -1427,6 +1426,7 @@ control.prototype.resumeReplay = function () { ////// 加速播放 ////// control.prototype.speedUpReplay = function () { + if (core.status.event.id=='save') return; if (!core.status.replay.replaying) return; core.status.replay.speed = parseInt(10*core.status.replay.speed + 1)/10; if (core.status.replay.speed>3.0) core.status.replay.speed=3.0; @@ -1435,6 +1435,7 @@ control.prototype.speedUpReplay = function () { ////// 减速播放 ////// control.prototype.speedDownReplay = function () { + if (core.status.event.id=='save') return; if (!core.status.replay.replaying) return; core.status.replay.speed = parseInt(10*core.status.replay.speed - 1)/10; if (core.status.replay.speed<0.3) core.status.replay.speed=0.3; @@ -1443,6 +1444,7 @@ control.prototype.speedDownReplay = function () { ////// 停止播放 ////// control.prototype.stopReplay = function () { + if (core.status.event.id=='save') return; if (!core.status.replay.replaying) return; core.status.replay.toReplay = []; core.status.replay.totalList = []; @@ -1457,6 +1459,7 @@ control.prototype.stopReplay = function () { ////// 回退 ////// control.prototype.rewindReplay = function () { + if (core.status.event.id=='save') return; if (!core.status.replay.replaying) return; if (!core.status.replay.pausing) { core.drawTip("请先暂停录像"); @@ -1487,7 +1490,26 @@ control.prototype.rewindReplay = function () { core.updateStatusBar(); core.drawTip("成功回退到上一个节点"); }) +} +////// 回放时存档 ////// +control.prototype.saveReplay = function () { + if (!core.status.replay.replaying) return; + if (!core.status.replay.pausing) { + core.drawTip("请先暂停录像"); + return; + } + if (core.status.replay.animate || core.isset(core.status.event.id)) { + core.drawTip("请等待当前事件的处理结束"); + return; + } + + core.lockControl(); + core.status.event.id='save'; + var saveIndex = core.status.saveIndex; + var page=parseInt((saveIndex-1)/5), offset=saveIndex-5*page; + + core.ui.drawSLPanel(10*page+offset); } ////// 回放 ////// @@ -2241,7 +2263,8 @@ control.prototype.updateStatusBar = function () { core.statusBar.image.load.src = core.statusBar.icons.speedUp.src; core.statusBar.image.load.style.opacity = 1; - core.statusBar.image.settings.style.opacity = 0; + core.statusBar.image.settings.src = core.statusBar.icons.save.src; + core.statusBar.image.settings.style.opacity = 1; } else { diff --git a/libs/core.js b/libs/core.js index ca890c7b..a1fe38db 100644 --- a/libs/core.js +++ b/libs/core.js @@ -923,6 +923,11 @@ core.prototype.stopReplay = function () { core.control.stopReplay(); } +////// 回放时存档 ////// +core.prototype.saveReplay = function () { + core.control.saveReplay(); +} + ////// 回放 ////// core.prototype.replay = function () { core.control.replay(); diff --git a/libs/ui.js b/libs/ui.js index 3ed574e9..cb770991 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1616,11 +1616,9 @@ ui.prototype.drawSLPanel = function(index) { } this.drawPagination(page+1, 30); - if (core.status.event.id == 'save' || core.status.event.id=='load') { - if (core.status.event.selection) - core.setFillStyle('ui', '#FF6A6A'); - core.fillText('ui', '删除模式', 48, 403); - } + if (core.status.event.selection) + core.setFillStyle('ui', '#FF6A6A'); + core.fillText('ui', '删除模式', 48, 403); } diff --git a/main.js b/main.js index e83fb164..6661507a 100644 --- a/main.js +++ b/main.js @@ -433,6 +433,12 @@ main.statusBar.image.load.onclick = function () { ////// 点击状态栏中的系统菜单时 ////// main.statusBar.image.settings.onclick = function () { + + if (core.isset(core.status.replay) && core.status.replay.replaying) { + core.saveReplay(); + return; + } + if (main.core.isPlaying()) main.core.openSettings(true); } diff --git a/更新说明.txt b/更新说明.txt index 9143a14a..51359bac 100644 --- a/更新说明.txt +++ b/更新说明.txt @@ -1,14 +1,14 @@ HTML5魔塔样板V2.1.1 -改变勇士行走图 √ -楼传器落点设置 √ -录像回放从任意存档点开始 √ +新增事件:改变勇士行走图 +楼传器落点设置 +录像回放从任意存档点开始 录像过程中允许存档 -血网显伤 √ -重置当前楼层地图core.resetMap() √ -部分楼层不允许浏览地图 √ -其他细节优化 √ -r +血网显伤 +重置当前楼层地图core.resetMap() +支持部分楼层不允许浏览地图 +其他细节优化 + ----------------------------------------------------------------------- HTML5魔塔样板V2.1