diff --git a/_server/data.comment.js b/_server/data.comment.js index bad2978f..c4ad3175 100644 --- a/_server/data.comment.js +++ b/_server/data.comment.js @@ -253,12 +253,6 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = } } }, - "flyRange": { - "_leaf": true, - "_type": "textarea", - "_range": "thiseval instanceof Array", - "_data": "初始可飞的楼层;一般留空数组即可" - }, "loc": { "_type": "object", diff --git a/_server/editor_mode.js b/_server/editor_mode.js index 15950e8e..d23f4abe 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -339,7 +339,6 @@ editor_mode = function (editor) { editor_mode.prototype.indent = function (field) { var num = '\t'; if (field.indexOf("['main']") === 0) return 0; - if (field.indexOf("['flyRange']") !== -1) return 0; if (field === "['special']") return 0; return num; } diff --git a/libs/actions.js b/libs/actions.js index 00650fe4..7d5cba93 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -660,8 +660,8 @@ actions.prototype._sys_onmousewheel = function (direct) { // 楼层飞行器 if (core.status.lockControl && core.status.event.id == 'fly') { - if (direct==1) core.ui.drawFly(core.status.event.data+1); - if (direct==-1) core.ui.drawFly(core.status.event.data-1); + if (direct==1) core.ui.drawFly(this._getNextFlyFloor(1)); + if (direct==-1) core.ui.drawFly(this._getNextFlyFloor(-1)); return; } @@ -990,25 +990,44 @@ actions.prototype._clickBookDetail = function () { ////// 楼层传送器界面时的点击操作 ////// actions.prototype._clickFly = function(x,y) { - if ((x==10 || x==11) && y==9) core.ui.drawFly(core.status.event.data-1); - if ((x==10 || x==11) && y==5) core.ui.drawFly(core.status.event.data+1); - if ((x==10 || x==11) && y==10) core.ui.drawFly(core.status.event.data-10); - if ((x==10 || x==11) && y==4) core.ui.drawFly(core.status.event.data+10); + if ((x==10 || x==11) && y==9) core.ui.drawFly(this._getNextFlyFloor(-1)); + if ((x==10 || x==11) && y==5) core.ui.drawFly(this._getNextFlyFloor(1)); + if ((x==10 || x==11) && y==10) core.ui.drawFly(this._getNextFlyFloor(-10)); + if ((x==10 || x==11) && y==4) core.ui.drawFly(this._getNextFlyFloor(10)); if (x>=5 && x<=7 && y==12) core.ui.closePanel(); if (x>=0 && x<=9 && y>=3 && y<=11) - core.control.flyTo(core.status.hero.flyRange[core.status.event.data]); + core.control.flyTo(core.floorIds[core.status.event.data]); return; } ////// 楼层传送器界面时,按下某个键的操作 ////// actions.prototype._keyDownFly = function (keycode) { - if (keycode==37) core.ui.drawFly(core.status.event.data-10); - else if (keycode==38) core.ui.drawFly(core.status.event.data+1); - else if (keycode==39) core.ui.drawFly(core.status.event.data+10); - else if (keycode==40) core.ui.drawFly(core.status.event.data-1); + if (keycode==37) core.ui.drawFly(this._getNextFlyFloor(-10)); + else if (keycode==38) core.ui.drawFly(this._getNextFlyFloor(1)); + else if (keycode==39) core.ui.drawFly(this._getNextFlyFloor(10)); + else if (keycode==40) core.ui.drawFly(this._getNextFlyFloor(-1)); return; } +actions.prototype._getNextFlyFloor = function (delta, index) { + if (!core.isset(index)) index = core.status.event.data; + if (delta == 0) return index; + var sign = Math.sign(delta); + delta = Math.abs(delta); + var ans = index; + while (true) { + index += sign; + if (index < 0 || index >= core.floorIds.length) break; + var floorId = core.floorIds[index]; + if (core.status.maps[floorId].canFlyTo && core.hasVisitedFloor(floorId)) { + delta--; + ans = index; + } + if (delta == 0) break; + } + return ans; +} + ////// 楼层传送器界面时,放开某个键的操作 ////// actions.prototype._keyUpFly = function (keycode) { if (keycode==71 || keycode==27 || keycode==88) diff --git a/libs/control.js b/libs/control.js index a3e706f5..c44f8a70 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1912,9 +1912,8 @@ control.prototype.replay = function () { } else if (action.indexOf("fly:")==0) { var floorId=action.substring(4); - var toIndex=core.status.hero.flyRange.indexOf(floorId); - var nowIndex=core.status.hero.flyRange.indexOf(core.status.floorId); - if (core.hasItem('fly') && toIndex>=0 && nowIndex>=0) { + var toIndex=core.floorIds.indexOf(floorId); + if (core.hasItem('fly')) { core.ui.drawFly(toIndex); setTimeout(function () { if (!core.control.flyTo(floorId, function () {core.replay()})) { diff --git a/libs/events.js b/libs/events.js index 2631afec..3048b431 100644 --- a/libs/events.js +++ b/libs/events.js @@ -452,12 +452,6 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback core.clearContinueAutomaticRoute(); core.status.replay.animate=true; - if (core.status.maps[floorId].canFlyTo && core.status.hero.flyRange.indexOf(floorId)<0) { - core.status.hero.flyRange.push(floorId); - core.status.hero.flyRange.sort(function (a, b) { - return core.floorIds.indexOf(a) - core.floorIds.indexOf(b); - }) - } this._changeFloor_beforeChange(info, callback); } diff --git a/libs/maps.js b/libs/maps.js index 22c42747..5d7eb87e 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -51,7 +51,9 @@ maps.prototype._mapIntoBlocks = function (map,floor,floorId){ var mh = core.floors[floorId].height; for (var i = 0; i < mh; i++) { for (var j = 0; j < mw; j++) { - blocks.push(this.initBlock(j, i, (map[i]||[])[j], true, floor)); + var block = this.initBlock(j, i, (map[i]||[])[j], true, floor); + if (block.id != 0 || block.event.trigger) + blocks.push(block); } } return blocks; diff --git a/libs/ui.js b/libs/ui.js index b5bdfe4e..d055aada 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1575,11 +1575,9 @@ ui.prototype.drawBookDetail = function (index) { ////// 绘制楼层传送器 ////// ui.prototype.drawFly = function(page) { - if (page<0) page=0; - if (page>=core.status.hero.flyRange.length) page=core.status.hero.flyRange.length-1; core.status.event.data = page; - var floorId = core.status.hero.flyRange[page]; + var floorId = core.floorIds[page]; var title = core.status.maps[floorId].title; core.clearMap('ui'); @@ -1591,12 +1589,12 @@ ui.prototype.drawFly = function(page) { core.fillText('ui', '楼层跳跃', 208, 60, '#FFFFFF', "bold 28px "+globalFont); core.fillText('ui', '返回游戏', 208, 403, '#FFFFFF', "bold 15px "+globalFont) core.fillText('ui', title, 356, 247, '#FFFFFF', "bold 19px "+globalFont); - if (page0) { + if (core.actions._getNextFlyFloor(-1) != page) { core.fillText('ui', '▼', 356, 247 + 64, '#FFFFFF', "17px "+globalFont); core.fillText('ui', '▼', 356, 247 + 96, '#FFFFFF', "17px "+globalFont); core.fillText('ui', '▼', 356, 247 + 96 + 7, '#FFFFFF', "17px "+globalFont); diff --git a/project/data.js b/project/data.js index cfecf74f..4affc3ea 100644 --- a/project/data.js +++ b/project/data.js @@ -95,7 +95,6 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "tools": {}, "equips": {} }, - "flyRange": [], "loc": { "direction": "up", "x": 6, diff --git a/project/items.js b/project/items.js index 1abd9db9..1c464161 100644 --- a/project/items.js +++ b/project/items.js @@ -360,7 +360,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = }, "useItemEffect": { "book": "core.ui.drawBook(0);", - "fly": "core.ui.drawFly(core.status.hero.flyRange.indexOf(core.status.floorId));", + "fly": "core.ui.drawFly(core.floorIds.indexOf(core.status.floorId));", "earthquake": "core.removeBlockByIds(core.status.floorId, core.status.event.ui);\ncore.drawMap(core.status.floorId, function () {\n\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n});", "pickaxe": "core.playSound('pickaxe.mp3');\ncore.removeBlockByIds(core.status.floorId, core.status.event.ui);\ncore.drawMap(core.status.floorId, function () {\n\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n});", "icePickaxe": "core.removeBlockByIds(core.status.floorId, core.status.event.ui);\ncore.drawMap(core.status.floorId, function () {\n\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n});", @@ -389,7 +389,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = }, "canUseItemEffect": { "book": "true", - "fly": "(function () {\n\treturn core.status.hero.flyRange.indexOf(core.status.floorId)>=0 && (core.status.maps[core.status.floorId]||{}).canFlyTo;\n})();", + "fly": "(function () {\n\treturn core.status.maps[core.status.floorId].canFlyTo;\n})();", "pickaxe": "(function() {\n\tvar ids = [], id2s = [];\n\tfor (var i in core.status.thisMap.blocks) {\n\t\tvar block = core.status.thisMap.blocks[i];\n\t\tif (!block.disable && core.nearHero(block.x, block.y) && \n\t\t\t(block.event.canBreak || block.event.id == 'yellowWall' || block.event.id=='whiteWall' || block.event.id=='blueWall')) { // 能破哪些墙\n\t\t\t// 四个方向\n\t\t\tif (core.flags.pickaxeFourDirections || (block.x == core.nextX() && block.y == core.nextY()))\n\t\t\t\tids.push(i);\n\t\t\telse id2s.push(i);\n\t\t}\n\t}\n\tif (ids.length>0) {\n\t\tcore.status.event.ui = ids;\n\t\treturn true;\n\t}\n\telse if (id2s.length==1) {\n\t\tcore.status.event.ui = id2s;\n\t\treturn true;\n\t}\n\treturn false;\n})();", "icePickaxe": "(function() {\n\tfor (var i in core.status.thisMap.blocks) {\n\t\tvar block = core.status.thisMap.blocks[i];\n\t\tif (!block.disable && block.x==core.nextX() && block.y==core.nextY() && block.event.id=='ice') {\n\t\t\tcore.status.event.ui = [i];\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n})();", "bomb": "(function () {\n\tvar ids = [], id2s = [];\n\tfor (var i in core.status.thisMap.blocks) {\n\t\tvar block = core.status.thisMap.blocks[i];\n\t\tif (!block.disable && block.event.cls.indexOf('enemy')==0 && core.nearHero(block.x, block.y)) {\n\t\t\tvar enemy = core.material.enemys[block.event.id];\n\t\t\tif (core.isset(enemy) && enemy.notBomb) continue;\n\t\t\tif (core.flags.bombFourDirections || (block.x==core.nextX() && block.y==core.nextY()))\n\t\t\t\tids.push(i);\n\t\t\telse\n\t\t\t\tid2s.push(i);\n\t\t}\n\t}\n\tif (ids.length>0) {\n\t\tcore.status.event.ui = ids;\n\t\treturn true;\n\t}\n\tif (id2s.length==1) {\n\t\tcore.status.event.ui = id2s;\n\t\treturn true;\n\t}\n\treturn false;\n})();",