diff --git a/docs/element.md b/docs/element.md index b973698a..21df84a9 100644 --- a/docs/element.md +++ b/docs/element.md @@ -142,10 +142,6 @@ floorId指定的是目标楼层的唯一标识符(ID)。 可以指定time,指定后切换动画时长为指定的数值。 -楼梯和传送门默认可`"穿透"`。所谓穿透,就是当寻路穿过一个楼梯/传送门后,不会触发楼层传送事件,而是继续前进。通过系统Flag可以指定是否穿透,你也可以对每个传送点单独设置该项。 - -![楼层转换穿透](./img/floorset.png) - ## 背景音乐 本塔支持BGM和SE的播放。 diff --git a/libs/core.js b/libs/core.js index 837f9664..bcf766b3 100644 --- a/libs/core.js +++ b/libs/core.js @@ -766,6 +766,22 @@ core.prototype.keyUp = function(keyCode) { if (!core.status.lockControl && core.status.heroStop) core.ui.drawHelp(); break; + case 82: // R + if (!core.status.lockControl && core.status.heroStop) { + core.ui.drawConfirmBox("确定要回放录像吗?", function () { + core.ui.closePanel(); + var hard=core.status.hard, route=core.clone(core.status.route); + core.resetStatus(core.firstData.hero, hard, core.firstData.floorId, null, core.initStatus.maps); + core.events.setInitData(hard); + core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() { + core.setHeroMoveTriggerInterval(); + core.replay(route); + }); + }, function () { + core.ui.closePanel(); + }); + } + break; case 37: // UP break; case 38: // DOWN @@ -1483,18 +1499,16 @@ core.prototype.moveAction = function (callback) { } } -////// 设置勇士的方向(转向) ////// -core.prototype.turnHero = function(direction) { - if (core.isset(direction)) { - core.status.hero.loc.direction = direction; - } - else if (core.status.hero.loc.direction == 'up') core.status.hero.loc.direction = 'right'; +////// 转向 ////// +core.prototype.turnHero = function() { + if (core.status.hero.loc.direction == 'up') core.status.hero.loc.direction = 'right'; else if (core.status.hero.loc.direction == 'right') core.status.hero.loc.direction = 'down'; else if (core.status.hero.loc.direction == 'down') core.status.hero.loc.direction = 'left'; else if (core.status.hero.loc.direction == 'left') core.status.hero.loc.direction = 'up'; core.drawHero(core.status.hero.loc.direction, core.status.hero.loc.x, core.status.hero.loc.y, 'stop', 0, 0); core.status.automaticRoutingTemp = {'destX': 0, 'destY': 0, 'moveStep': []}; core.canvas.ui.clearRect(0, 0, 416, 416); + core.status.route.push("turn"); } ////// 勇士能否前往某方向 ////// @@ -1832,12 +1846,14 @@ core.prototype.trigger = function (x, y) { if (core.isset(mapBlocks[b].event) && core.isset(mapBlocks[b].event.trigger)) { var trigger = mapBlocks[b].event.trigger; // 转换楼层能否穿透 + /* if (trigger=='changeFloor' && (core.status.autoHeroMove || core.status.autoStep=0 && nowIndex>=0) { + var stair=toIndex0 && core.events.canUseQuickShop(shopId)==null) { + var shop=core.status.shops[shopId]; + if (core.isset(shop) && shop.visited) { // 商店可用 + var choices = shop.choices; + var topIndex = 6 - parseInt(choices.length / 2); + core.events.openShop(shopId, false); + var shopInterval = setInterval(function () { + if (selections.length==0) { + clearInterval(shopInterval); + core.events.clickShop(6, topIndex+choices.length); + core.replay(); + return; + } + var selection = parseInt(selections.shift()); + if (isNaN(core.status.event.selection=selection) || selection<0 || selection>=choices.length || !core.events.clickShop(6, topIndex+selection)) { + clearInterval(shopInterval); + core.status.replay.replaying=false; + core.drawTip("录像文件出错"); + return; + } + }, 500); + return; + } + } + } + else if (action=='turn') { + core.turnHero(); + core.replay(); + return; + } + else if (action=='getNext') { + if (core.flags.enableGentleClick && core.getBlock(core.nextX(), core.nextY())!=null) { + var nextX = core.nextX(), nextY = core.nextY(); + var block = core.getBlock(nextX, nextY); + if (block!=null && block.block.event.trigger=='getItem') { + core.getItem(block.block.event.id, 1, nextX, nextY); + core.status.route.push("getNext"); + core.replay(); + return; + } + } + } + + core.status.replay.replaying=false; + core.insertAction("录像文件出错"); } @@ -3748,6 +3826,10 @@ core.prototype.encodeRoute = function (route) { var sp=t.substring(5).split(":"); ans+="S"+shops.indexOf(sp[0])+":"+sp[1]; } + else if (t=='turn') + ans+='T'; + else if (t=='getNext') + ans+='G'; } }); if (cnt>0) { @@ -3788,6 +3870,8 @@ core.prototype.decodeRoute = function (route) { case "F": ans.push("fly:"+core.floorIds[number]); break; case "C": ans.push("choices:"+number); break; case "S": ++index; ans.push("shop:"+shops[number]+":"+getNumber(true)); break; + case "T": ans.push("turn"); break; + case "G": ans.push("getNext"); break; } } return ans; diff --git a/libs/data.js b/libs/data.js index ae052c34..eae23c89 100644 --- a/libs/data.js +++ b/libs/data.js @@ -166,7 +166,6 @@ data.prototype.init = function() { "displayEnemyDamage": true, // 是否地图怪物显伤;用户可以手动在菜单栏中开关 "displayExtraDamage": false, // 是否地图高级显伤(领域、夹击等);用户可以手动在菜单栏中开关 "enableGentleClick": true, // 是否允许轻触(获得面前物品) - "portalWithoutTrigger": true, // 经过楼梯、传送门时是否能“穿透”。穿透的意思是,自动寻路得到的的路径中间经过了楼梯,行走时是否触发楼层转换事件 "potionWhileRouting": false, // 寻路算法是否经过血瓶;如果该项为false,则寻路算法会自动尽量绕过血瓶 } } diff --git a/libs/events.js b/libs/events.js index 7753d333..43b8fbe4 100644 --- a/libs/events.js +++ b/libs/events.js @@ -293,7 +293,12 @@ events.prototype.doAction = function() { this.doAction(); break; case "openShop": // 打开一个全局商店 - core.events.openShop(data.id); + if (core.status.replay.replaying) { // 正在播放录像,简单将visited置为true + core.status.shops[data.id].visited=true; + this.doAction(); + } + else + core.events.openShop(data.id); break; case "disableShop": // 禁用一个全局商店 core.events.disableQuickShop(data.id); @@ -374,6 +379,30 @@ events.prototype.doAction = function() { this.doAction(); break; case "choices": // 提供选项 + if (core.status.replay.replaying) { + if (core.status.replay.toReplay.length==0) { // 回放完毕 + core.status.replay.replaying=false; + core.drawTip("录像回放完毕"); + } + else { + var action = core.status.replay.toReplay.shift(), index; + if (action.indexOf("choices:")==0 && ((index=parseInt(action.substring(8)))>=0) && index eval(use)) { core.drawTip("你的"+use_text+"不足"); - return; + return false; } core.status.event.data.actions.push(y-topIndex); @@ -981,7 +1010,9 @@ events.prototype.clickShop = function(x,y) { core.ui.drawQuickShop(); else core.ui.closePanel(); } + else return false; } + return true; } ////// 商店界面时,按下某个键的操作 ////// @@ -1023,7 +1054,7 @@ events.prototype.clickQuickShop = function(x, y) { if (x >= 5 && x <= 7) { var topIndex = 6 - parseInt(keys.length / 2); if (y>=topIndex && y