From 12d134b1dc4a5a2244bc2eb75d36b7d6f23ce7fa Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Fri, 12 Jun 2020 15:54:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=B3=E8=B7=83=E4=BA=8B=E4=BB=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=A2=9E=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 46 +++++++++++++++++++++++++++++++++ _server/MotaActionParser.js | 22 +++++++++++----- _server/editor_blocklyconfig.js | 2 ++ libs/events.js | 14 ++++++++-- 4 files changed, 76 insertions(+), 8 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 53b249a9..d38f21e1 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -664,7 +664,9 @@ action | moveAction_s | moveHero_s | jump_s + | jump_1_s | jumpHero_s + | jumpHero_1_s | playBgm_s | pauseBgm_s | resumeBgm_s @@ -2069,6 +2071,31 @@ var code = '{"type": "jump"'+floorstr+''+IntString_0+Bool_0+Bool_1+'},\n'; return code; */; +jump_1_s + : '跳跃事件' '起始 x' PosString? ',' 'y' PosString? '增量 dx' PosString? ',' 'dy' PosString? '动画时间' IntString? '不消失' Bool '不等待执行完毕' Bool Newline + + +/* jump_1_s +tooltip : jump: 让某个NPC/怪物跳跃,给定增量 +helpUrl : /_docs/#/instruction +default : ["","","0","0",500,true,false] +selectPoint : ["PosString_0", "PosString_1"] +colour : this.mapColor + +var floorstr = ''; +if (PosString_0 && PosString_1) { + floorstr += ', "from": ['+PosString_0+','+PosString_1+']'; +} +if (PosString_2 && PosString_3) { + floorstr += ', "dxy": ['+PosString_2+','+PosString_3+']'; +} +IntString_0 = IntString_0 ?(', "time": '+IntString_0):''; +Bool_0 = Bool_0?', "keep": true':''; +Bool_1 = Bool_1?', "async": true':''; +var code = '{"type": "jump"'+floorstr+''+IntString_0+Bool_0+Bool_1+'},\n'; +return code; +*/; + jumpHero_s : '跳跃勇士' 'x' PosString? ',' 'y' PosString? '动画时间' IntString? '不等待执行完毕' Bool Newline @@ -2089,6 +2116,25 @@ var code = '{"type": "jumpHero"'+floorstr+IntString_0+Bool_0+'},\n'; return code; */; +jumpHero_1_s + : '跳跃勇士' '增量 dx' PosString? ',' 'dy' PosString? '动画时间' IntString? '不等待执行完毕' Bool Newline + + +/* jumpHero_1_s +tooltip : jumpHero: 跳跃勇士,给定增量 +helpUrl : /_docs/#/instruction +default : ["0","0",500,false] +colour : this.dataColor +var floorstr = ''; +if (PosString_0 && PosString_1) { + floorstr = ', "dxy": ['+PosString_0+','+PosString_1+']'; +} +IntString_0 = IntString_0 ?(', "time": '+IntString_0):''; +Bool_0 = Bool_0?', "async": true':''; +var code = '{"type": "jumpHero"'+floorstr+IntString_0+Bool_0+'},\n'; +return code; +*/; + playBgm_s : '播放背景音乐' EvalString '开始播放秒数' Int '持续到下个本事件' Bool Newline diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index b068a776..60f67b12 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -401,14 +401,24 @@ ActionParser.prototype.parseAction = function() { break; case "jump": // 跳跃事件 data.from=data.from||['','']; - data.to=data.to||['','']; - this.next = MotaActionBlocks['jump_s'].xmlText([ - data.from[0],data.from[1],data.to[0],data.to[1],data.time,data.keep||false,data.async||false,this.next]); + if (data.dxy) { + this.next = MotaActionBlocks['jump_1_s'].xmlText([ + data.from[0],data.from[1],data.dxy[0],data.dxy[1],data.time,data.keep||false,data.async||false,this.next]); + } else { + data.to=data.to||['','']; + this.next = MotaActionBlocks['jump_s'].xmlText([ + data.from[0],data.from[1],data.to[0],data.to[1],data.time,data.keep||false,data.async||false,this.next]); + } break; case "jumpHero": // 跳跃勇士 - data.loc=data.loc||['',''] - this.next = MotaActionBlocks['jumpHero_s'].xmlText([ - data.loc[0],data.loc[1],data.time,data.async||false,this.next]); + if (data.dxy) { + this.next = MotaActionBlocks['jumpHero_1_s'].xmlText([ + data.dxy[0],data.dxy[1],data.time,data.async||false,this.next]); + } else { + data.loc=data.loc||['',''] + this.next = MotaActionBlocks['jumpHero_s'].xmlText([ + data.loc[0],data.loc[1],data.time,data.async||false,this.next]); + } break; case "changeFloor": // 楼层转换 if (!data.loc) { diff --git a/_server/editor_blocklyconfig.js b/_server/editor_blocklyconfig.js index 179f0a56..3a0b55da 100644 --- a/_server/editor_blocklyconfig.js +++ b/_server/editor_blocklyconfig.js @@ -124,6 +124,7 @@ editor_blocklyconfig=(function(){ MotaActionBlocks['moveAction_s'].xmlText(), MotaActionBlocks['moveHero_s'].xmlText(), MotaActionBlocks['jumpHero_s'].xmlText(), + MotaActionBlocks['jumpHero_1_s'].xmlText(), MotaActionBlocks['changeFloor_s'].xmlText(), MotaActionBlocks['changePos_s'].xmlText(), MotaActionBlocks['battle_s'].xmlText(), @@ -146,6 +147,7 @@ editor_blocklyconfig=(function(){ MotaActionBlocks['turnBlock_s'].xmlText(), MotaActionBlocks['move_s'].xmlText(), MotaActionBlocks['jump_s'].xmlText(), + MotaActionBlocks['jump_1_s'].xmlText(), MotaActionBlocks['showBgFgMap_s'].xmlText(), MotaActionBlocks['hideBgFgMap_s'].xmlText(), MotaActionBlocks['setBgFgBlock_s'].xmlText(), diff --git a/libs/events.js b/libs/events.js index 29467243..d74cda20 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1464,19 +1464,29 @@ events.prototype._action_moveHero = function (data, x, y, prefix) { } events.prototype._action_jump = function (data, x, y, prefix) { - var from = this.__action_getLoc(data.from, x, y, prefix), + var from = this.__action_getLoc(data.from, x, y, prefix), to; + if (data.dxy) { + to = [from[0] + (core.calValue(data.dxy[0], prefix) || 0), from[1] + (core.calValue(data.dxy[1], prefix) || 0)]; + } else { to = this.__action_getLoc(data.to, x, y, prefix); + } this.__action_doAsyncFunc(data.async, core.jumpBlock, from[0], from[1], to[0], to[1], data.time, data.keep); } events.prototype._precompile_jump = function (data) { data.from = this.__precompile_array(data.from); data.to = this.__precompile_array(data.to); + data.dxy = this.__precompile_array(data.dxy); return data; } events.prototype._action_jumpHero = function (data, x, y, prefix) { - var loc = this.__action_getHeroLoc(data.loc, prefix); + var loc; + if (data.dxy) { + loc = [core.getHeroLoc('x') + (core.calValue(data.dxy[0], prefix) || 0), core.getHeroLoc('y') + (core.calValue(data.dxy[1], prefix) || 0)]; + } else { + loc = this.__action_getHeroLoc(data.loc, prefix); + } this.__action_doAsyncFunc(data.async, core.jumpHero, loc[0], loc[1], data.time); }