From fd57f77c95257826e71a44b1841ab3b37a0c03c4 Mon Sep 17 00:00:00 2001 From: oc Date: Sat, 28 Apr 2018 23:31:18 +0800 Subject: [PATCH] event:wait --- _server/blockly/MotaAction.g4 | 17 +++++++++++++++++ _server/editor_blockly.js | 1 + docs/event.md | 4 ++++ libs/actions.js | 8 ++++---- libs/enemys.js | 4 ++-- libs/events.js | 7 +++++-- libs/utils.js | 4 +++- 更新说明.txt | 16 +++++++++++++++- 8 files changed, 51 insertions(+), 10 deletions(-) diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4 index 55944530..0653e8ad 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/blockly/MotaAction.g4 @@ -168,6 +168,7 @@ action | setHeroIcon_s | update_s | sleep_s + | wait_s | battle_s | openDoor_s | changeFloor_s @@ -455,6 +456,18 @@ var code = '{"type": "sleep", "time": '+Int_0+'},\n'; return code; */ +wait_s + : '等待用户操作' + ; + +/* wait_s +tooltip : wait: 等待用户操作 +helpUrl : https://ckcz123.github.io/mota-js/#/event?id=wait-%e7%ad%89%e5%be%85%e7%94%a8%e6%88%b7%e6%93%8d%e4%bd%9c +colour : this.soundColor +var code = '{"type": "wait"},\n'; +return code; +*/ + battle_s : '强制战斗' IdString Newline ; @@ -1433,6 +1446,10 @@ ActionParser.prototype.parseAction = function() { this.next = MotaActionBlocks['sleep_s'].xmlText([ data.time,this.next]); break; + case "wait": // 等待用户操作 + this.next = MotaActionBlocks['wait_s'].xmlText([ + this.next]); + break; case "revisit": // 立刻重新执行该事件 this.next = MotaActionBlocks['revisit_s'].xmlText([ this.next]); diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 3c8ff664..70ad514f 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -102,6 +102,7 @@ editor_blockly = function () { MotaActionBlocks['disableShop_s'].xmlText(), '', MotaActionBlocks['sleep_s'].xmlText(), + MotaActionBlocks['wait_s'].xmlText(), MotaActionBlocks['animate_s'].xmlText(), MotaActionBlocks['setFg_0_s'].xmlText(), MotaActionBlocks['setFg_1_s'].xmlText(), diff --git a/docs/event.md b/docs/event.md index 1d60fad1..89300fc6 100644 --- a/docs/event.md +++ b/docs/event.md @@ -519,6 +519,10 @@ name是可选的,代表目标行走图的文件名。 ] ``` +### wait:等待用户操作 + +使用 `{"type": "wait"}` 可以等待用户进行操作(如点击、回车等)。 + ### battle: 强制战斗 调用battle可强制与某怪物进行战斗(而无需去触碰到它)。 diff --git a/libs/actions.js b/libs/actions.js index eb98a683..85324e71 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -712,7 +712,7 @@ actions.prototype.longClick = function () { core.drawText(); return true; } - if (core.status.event.id=='action' && core.status.event.data.type=='text') { + if (core.status.event.id=='action' && (core.status.event.data.type=='text' || core.status.event.data.type=='wait')) { core.doAction(); return true; } @@ -725,7 +725,7 @@ actions.prototype.keyDownCtrl = function () { core.drawText(); return; } - if (core.status.event.id=='action' && core.status.event.data.type=='text') { + if (core.status.event.id=='action' && (core.status.event.data.type=='text' || core.status.event.data.type=='wait')) { core.doAction(); return; } @@ -766,7 +766,7 @@ actions.prototype.keyUpConfirmBox = function (keycode) { ////// 自定义事件时的点击操作 ////// actions.prototype.clickAction = function (x,y) { - if (core.status.event.data.type=='text') { + if (core.status.event.data.type=='text' || core.status.event.data.type=='wait') { // 文字 core.doAction(); return; @@ -808,7 +808,7 @@ actions.prototype.keyDownAction = function (keycode) { ////// 自定义事件时,放开某个键的操作 ////// actions.prototype.keyUpAction = function (keycode) { - if (core.status.event.data.type=='text' && (keycode==13 || keycode==32 || keycode==67)) { + if ((core.status.event.data.type=='text' || core.status.event.data.type=='wait') && (keycode==13 || keycode==32 || keycode==67)) { core.doAction(); return; } diff --git a/libs/enemys.js b/libs/enemys.js index e72ea82f..1b4158ff 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -33,8 +33,8 @@ enemys.prototype.hasSpecial = function (special, test) { ////// 获得所有特殊属性的名称 ////// enemys.prototype.getSpecialText = function (enemyId) { - if (enemyId == undefined) return ""; - var enemy = this.enemys[enemyId]; + var enemy = core.material.enemys[enemyId]; + if (!core.isset(enemy)) return []; var special = enemy.special; var text = []; if (this.hasSpecial(special, 1)) text.push("先攻"); diff --git a/libs/events.js b/libs/events.js index 43fdfd49..b35adc60 100644 --- a/libs/events.js +++ b/libs/events.js @@ -57,8 +57,7 @@ events.prototype.init = function () { callback(); }, 'action': function (data, core, callback) { - core.events.doEvents(data.event.data, data.x, data.y); - if (core.isset(callback)) callback(); + core.events.insertAction(data.event.data, data.x, data.y, callback); } } } @@ -670,6 +669,10 @@ events.prototype.doAction = function() { }, data.time); } break; + case "wait": + if (core.status.replay.replaying) + core.events.doAction(); + break; case "revisit": // 立刻重新执行该事件 { var block=core.getBlock(x,y); // 重新获得事件 diff --git a/libs/utils.js b/libs/utils.js index 9d11609b..fd69165d 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -167,6 +167,8 @@ utils.prototype.formatBigNumber = function (x) { x = parseFloat(x); if (!core.isset(x)) return '???'; + if (x<=999999) return x; + var all = [ {"val": 1e20, "c": "g"}, {"val": 1e16, "c": "j"}, @@ -177,7 +179,7 @@ utils.prototype.formatBigNumber = function (x) { for (var i=0;i=100*one.val) { + if (x>=10*one.val) { var v = x/one.val; return v.toFixed(Math.max(0, Math.floor(4-Math.log10(v+1)))) + one.c; } diff --git a/更新说明.txt b/更新说明.txt index a2ed95eb..ce56bbcd 100644 --- a/更新说明.txt +++ b/更新说明.txt @@ -1,4 +1,18 @@ -HTML5魔塔样板V2.1.1 +HTML5魔塔样板V2.1.2 + +事件坐标可用变量指定 +全局商店也可以使用图块编辑 +图片移动事件 +提供core.random函数提供随机数 +作弊处理(成绩范围控制,通关不上传则按照最低分) +格子有事件则高亮显示 +状态栏绘制 +等待用户点击事件 +事件:设置BGM音量 + +----------------------------------------------------------------------- + +HTML5魔塔样板V2.1.1 新增事件:改变勇士行走图 楼传器落点设置