diff --git a/README.md b/README.md index 066ff6c4..b81aa04b 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,12 @@ HTML5 canvas制作的魔塔样板,支持全平台游戏! │ ├─ /sounds/ # 音效目录 │ ├─ data.js # 全局变量信息 │ ├─ enemys.js # 怪物属性数据 +│ ├─ events.js # 公共事件 │ ├─ functions.js # 可能会被修改的脚本代码 │ ├─ icons.js # 素材和ID的对应关系定义 │ ├─ items.js # 道具的定义,获得道具的效果 -│ └─ maps.js # 地图和数字的对应关系 +│ ├─ maps.js # 地图和数字的对应关系 +│ └─ plugins.js # 自定义插件 ├── /常用工具/ # 一些常用工具,可以辅助造塔;具体可参见下面的【相关工具】 ├── editor.html # 可视化地图编辑工具 ├── editor-mobile.html # 可视化地图编辑工具(手机版) diff --git a/_docs/event.md b/_docs/event.md index 0ff220b4..73961975 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -901,6 +901,30 @@ needKey是可选的,如果设置为true则需要钥匙才能打开此门。如 !> needKey仅对当前楼层开门有效!跨楼层的门仍然不需要钥匙即可打开,如有需求请自行判定。 +### closeDoor:关门 + +从V2.6开始提供了关门事件`{"type": "closeDoor"}`,拥有关门动画和对应的音效。 + +``` js +"x,y": [ // 实际执行的事件列表 + {"type": "closeDoor", "id": "yellowDoor", "loc": [3,6]}, // 给(3,6)点关上黄门 + {"type": "closeDoor", "id": "specialDoor"}, // 不写loc则视为当前点 +] +``` + +id为你要关门的ID,需要是一个合法的门,系统默认只支持如下几种: + +``` +yellowDoor, blueDoor, redDoor, greenDoor, specialDoor, steelDoor, +yellowWall, blueWall, whiteWall +``` + +如果需要自己添加门,请参考[新增门和对应的钥匙](personalization#新增门和对应的钥匙)。 + +loc可选,为要关的位置,不填默认为当前点。 + +关门事件需要保证该点是空地,否则将无视此事件。 + ### changeFloor:楼层切换 在事件中也可以对楼层进行切换。一个比较典型的例子就是TSW中,勇士在三楼的陷阱被扔到了二楼,就是一个楼层切换事件。 diff --git a/_server/blockly/MotaAction.g4 b/_server/MotaAction.g4 similarity index 99% rename from _server/blockly/MotaAction.g4 rename to _server/MotaAction.g4 index a31b4afd..6cf3b5d3 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -256,6 +256,7 @@ action | waitAsync_s | battle_s | openDoor_s + | closeDoor_s | changeFloor_s | changePos_0_s | changePos_1_s @@ -961,6 +962,23 @@ var code = '{"type": "openDoor"'+floorstr+IdString_0+Bool_0+'},\n'; return code; */; +closeDoor_s + : '关门' 'x' PosString? ',' 'y' PosString? 'ID' IdString Newline + + +/* closeDoor_s +tooltip : closeDoor: 关门事件,需要该点本身无事件 +helpUrl : https://h5mota.com/games/template/docs/#/event?id=opendoor%EF%BC%9A%E5%BC%80%E9%97%A8 +default : ["","","yellowDoor"] +colour : this.dataColor +var floorstr = ''; +if (PosString_0 && PosString_1) { + floorstr = ', "loc": ['+PosString_0+','+PosString_1+']'; +} +var code = '{"type": "closeDoor", "id": "'+IdString_0+'"'+floorstr+'},\n'; +return code; +*/; + changeFloor_s : '楼层切换' IdString? 'x' PosString? ',' 'y' PosString? '朝向' DirectionEx_List '动画时间' Int? Newline @@ -2338,6 +2356,11 @@ ActionParser.prototype.parseAction = function() { this.next = MotaActionBlocks['openDoor_s'].xmlText([ data.loc[0],data.loc[1],data.floorId||'',data.needKey||false,this.next]); break; + case "closeDoor": // 关一个门,需要该点无事件 + data.loc=data.loc||['',''] + this.next = MotaActionBlocks['closeDoor_s'].xmlText([ + data.loc[0],data.loc[1],data.id,this.next]); + break; case "useItem": // 使用道具 this.next = MotaActionBlocks['useItem_s'].xmlText([ data.id,this.next]); diff --git a/_server/editor.js b/_server/editor.js index 0923d516..b675d7ff 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -721,7 +721,7 @@ editor.prototype.listen = function () { mouseOutCheck = 2; setTimeout(clear1); e.stopPropagation(); - uc.clearRect(0, 0, core.__SIZE__, core.__SIZE__); + uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__); var loc = eToLoc(e); var pos = locToPos(loc,true); stepPostfix = []; diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 017805b8..7fdf310f 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -93,6 +93,7 @@ editor_blockly = function () { MotaActionBlocks['changePos_1_s'].xmlText(), MotaActionBlocks['battle_s'].xmlText(), MotaActionBlocks['openDoor_s'].xmlText(), + MotaActionBlocks['closeDoor_s'].xmlText(), MotaActionBlocks['useItem_s'].xmlText(), MotaActionBlocks['openShop_s'].xmlText(), MotaActionBlocks['setBlock_s'].xmlText(), @@ -312,7 +313,8 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){ //console.log(e); e.preventDefault(); var hvScroll = e.shiftKey?'hScroll':'vScroll'; - workspace.scrollbar[hvScroll].handlePosition_+=( ((e.deltaY||0)+(e.detail||0)) >0?20:-20); + var mousewheelOffsetValue=20/380*workspace.scrollbar[hvScroll].handleLength_*3; + workspace.scrollbar[hvScroll].handlePosition_+=( ((e.deltaY||0)+(e.detail||0)) >0?mousewheelOffsetValue:-mousewheelOffsetValue); workspace.scrollbar[hvScroll].onScroll_(); workspace.setScale(workspace.scale); } @@ -442,13 +444,13 @@ function omitedcheckUpdateFunction(event) { xhr.onreadystatechange = function () { if (xhr.readyState != 4) return; if (xhr.status != 200) { - alert("无法在file://下加载"); + alert("图块描述文件加载失败, 请在'启动服务.exe'中打开编辑器"); return; } input_ = xhr.responseText; editor_blockly.runOne(); } - xhr.open('GET', '_server/blockly/MotaAction.g4', true); + xhr.open('GET', '_server/MotaAction.g4', true); xhr.send(null); codeAreaHL = CodeMirror.fromTextArea(document.getElementById("codeArea"), { diff --git a/_server/events.comment.js b/_server/events.comment.js index 62fdbfef..a96301d7 100644 --- a/_server/events.comment.js +++ b/_server/events.comment.js @@ -13,14 +13,21 @@ var events_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_type": "event", "_range": "thiseval instanceof Array", "_event": "commonEvent", - "_data": "打败怪物后进行加点" + "_data": "打败怪物后加点" }, "毒衰咒处理": { "_leaf": true, "_type": "event", "_range": "thiseval instanceof Array", "_event": "commonEvent", - "_data": "对毒衰咒效果进行的处理" + "_data": "毒衰咒效果处理" + }, + "滑冰事件": { + "_leaf": true, + "_type": "event", + "_range": "thiseval instanceof Array", + "_event": "commonEvent", + "_data": "滑冰事件" }, } if (obj[key]) return obj[key]; diff --git a/_server/functions.comment.js b/_server/functions.comment.js index 2120f717..1d295260 100644 --- a/_server/functions.comment.js +++ b/_server/functions.comment.js @@ -42,6 +42,12 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_lint": true, "_data": "切换楼层后" }, + "flyTo": { + "_leaf": true, + "_type": "textarea", + "_lint": true, + "_data": "楼层飞行" + }, "beforeBattle": { "_leaf": true, "_type": "textarea", @@ -147,12 +153,6 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_lint": true, "_data": "读档操作" }, - "flyTo": { - "_leaf": true, - "_type": "textarea", - "_lint": true, - "_data": "楼层飞行" - }, "updateStatusBar": { "_leaf": true, "_type": "textarea", @@ -176,6 +176,12 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_type": "textarea", "_lint": true, "_data": "瞬间移动处理" + }, + "parallelDo": { + "_leaf": true, + "_type": "textarea", + "_lint": true, + "_data": "并行事件处理" } } }, @@ -201,23 +207,6 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_data": "绘制关于界面" } } - }, - "plugins": { - "_type": "object", - "_data": { - "parallelDo": { - "_leaf": true, - "_type": "textarea", - "_lint": true, - "_data": "并行事件处理" - }, - "plugin": { - "_leaf": true, - "_type": "textarea", - "_lint": true, - "_data": "自定义插件编写" - } - } } } } \ No newline at end of file diff --git a/_server/plugins.comment.js b/_server/plugins.comment.js index 20a3f361..e708c576 100644 --- a/_server/plugins.comment.js +++ b/_server/plugins.comment.js @@ -3,17 +3,17 @@ var plugins_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_type": "object", "_data": function (key) { var obj = { - "test": { + "init": { "_leaf": true, "_type": "textarea", "_range": "typeof(thiseval)=='string'", - "_data": "插件函数执行测试, 这个函数在导入后被直接执行(因此不允许删除)" + "_data": "自定义插件" }, "drawLight": { "_leaf": true, "_type": "textarea", "_range": "typeof(thiseval)=='string' || thiseval==null", - "_data": "绘制灯光/漆黑层效果" + "_data": "绘制灯光效果" }, } if (obj[key]) return obj[key]; diff --git a/editor-mobile.html b/editor-mobile.html index 5f9ce2d9..67c58418 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -503,7 +503,7 @@ 此浏览器不支持HTML5 -
+ -
+