From d931145716d417fbd34d0b08e03ef81106624f6a Mon Sep 17 00:00:00 2001 From: qweasz687 <66411718+qweasz687@users.noreply.github.com> Date: Tue, 10 Aug 2021 15:34:20 +0800 Subject: [PATCH 01/11] Create control.js --- libs/control.js | 94 ++++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/libs/control.js b/libs/control.js index e4b899bb..8b338b1e 100644 --- a/libs/control.js +++ b/libs/control.js @@ -195,7 +195,12 @@ control.prototype._animationFrame_heroMoving = function (timestamp) { core.animateFrame.leftLeg = !core.animateFrame.leftLeg; core.animateFrame.moveTime = timestamp; } - core.drawHero(core.animateFrame.leftLeg?'leftFoot':'rightFoot', 4*core.status.heroMoving); + var way = core.utils.scan2[core.getHeroLoc('direction')], + heroMoving = core.status.heroMoving; + core.drawHero(core.animateFrame.leftLeg ? 'leftFoot' : 'rightFoot', { + x: way.x * 4 * heroMoving, + y: way.y * 4 * heroMoving + }); } control.prototype._animationFrame_weather = function (timestamp) { @@ -800,26 +805,35 @@ control.prototype.drawHero = function (status, offset, frame) { if (!core.isPlaying() || !core.status.floorId || core.status.gameOver) return; var x = core.getHeroLoc('x'), y = core.getHeroLoc('y'), direction = core.getHeroLoc('direction'); status = status || 'stop'; - offset = offset || 0; + offset = offset || {}; + offset.x = offset.x || 0; + offset.y = offset.y || 0; + var way = core.utils.scan2[direction]; - var dx = way.x, dy = way.y, offsetX = dx * offset, offsetY = dy * offset; - core.bigmap.offsetX = core.clamp((x - core.__HALF_SIZE__) * 32 + offsetX, 0, 32*core.bigmap.width-core.__PIXELS__); - core.bigmap.offsetY = core.clamp((y - core.__HALF_SIZE__) * 32 + offsetY, 0, 32*core.bigmap.height-core.__PIXELS__); - core.clearAutomaticRouteNode(x+dx, y+dy); + var dx = way.x, dy = way.y; + var offsetX = offset.x, offsetY = offset.y; + + core.clearAutomaticRouteNode(x + dx, y + dy); core.clearMap('hero'); core.status.heroCenter.px = 32 * x + offsetX + 16; core.status.heroCenter.py = 32 * y + offsetY + 32 - core.material.icons.hero.height / 2; + this._drawHero_updateViewport(x, y, offset); if (!core.hasFlag('hideHero')) { this._drawHero_draw(direction, x, y, status, offset, frame); - } - - this._drawHero_updateViewport(); + } } -control.prototype._drawHero_updateViewport = function () { - core.control.updateViewport(); +control.prototype._drawHero_updateViewport = function (x, y, offset) { core.setGameCanvasTranslate('hero', 0, 0); + if (flags.__lockViewport__) return; + var offsetX = offset.x, offsetY = offset.y; + var ox = (x - core.__HALF_SIZE__) * 32 + offsetX, + oy = (y - core.__HALF_SIZE__) * 32 + offsetY; + + core.bigmap.offsetX = core.clamp(ox, 0, 32 * core.bigmap.width - core.__PIXELS__); + core.bigmap.offsetY = core.clamp(oy, 0, 32 * core.bigmap.height - core.__PIXELS__); + core.control.updateViewport(); } control.prototype._drawHero_draw = function (direction, x, y, status, offset, frame) { @@ -830,6 +844,35 @@ control.prototype._drawHero_draw = function (direction, x, y, status, offset, fr }); } +control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, offset) { + var heroIconArr = core.material.icons.hero, drawObjs = [], index = 0; + drawObjs.push({ + "img": core.material.images.hero, + "width": core.material.icons.hero.width || 32, + "height": core.material.icons.hero.height, + "heroIcon": heroIconArr[direction], + "posx": x * 32 - core.bigmap.offsetX + offset.x, + "posy": y * 32 - core.bigmap.offsetY + offset.y, + "status": status, + "index": index++, + }); + core.status.hero.followers.forEach(function (t) { + drawObjs.push({ + "img": core.material.images.images[t.name], + "width": core.material.images.images[t.name].width/4, + "height": core.material.images.images[t.name].height/4, + "heroIcon": heroIconArr[t.direction], + "posx": 32*t.x - core.bigmap.offsetX + (t.stop?0:core.utils.scan2[t.direction].x*Math.abs(offset.x)), + "posy": 32*t.y - core.bigmap.offsetY + (t.stop?0:core.utils.scan2[t.direction].y*Math.abs(offset.y)), + "status": t.stop?"stop":status, + "index": index++ + }); + }); + return drawObjs.sort(function(a, b) { + return a.posy==b.posy?b.index-a.index:a.posy-b.posy; + }); +} + control.prototype.triggerHero = function (type, time, callback) { if (type == null) { type = core.hasFlag('hideHero') ? 'show' : 'hide'; @@ -870,35 +913,6 @@ control.prototype._triggerHero_animate = function (type, delta, callback) { core.animateFrame.asyncId[animate] = true; } -control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, offset) { - var heroIconArr = core.material.icons.hero, drawObjs = [], index = 0; - drawObjs.push({ - "img": core.material.images.hero, - "width": core.material.icons.hero.width || 32, - "height": core.material.icons.hero.height, - "heroIcon": heroIconArr[direction], - "posx": x * 32 - core.bigmap.offsetX + core.utils.scan2[direction].x * offset, - "posy": y * 32 - core.bigmap.offsetY + core.utils.scan2[direction].y * offset, - "status": status, - "index": index++, - }); - core.status.hero.followers.forEach(function (t) { - drawObjs.push({ - "img": core.material.images.images[t.name], - "width": core.material.images.images[t.name].width/4, - "height": core.material.images.images[t.name].height/4, - "heroIcon": heroIconArr[t.direction], - "posx": 32*t.x - core.bigmap.offsetX + (t.stop?0:core.utils.scan2[t.direction].x*Math.abs(offset)), - "posy": 32*t.y - core.bigmap.offsetY + (t.stop?0:core.utils.scan2[t.direction].y*Math.abs(offset)), - "status": t.stop?"stop":status, - "index": index++ - }); - }); - return drawObjs.sort(function(a, b) { - return a.posy==b.posy?b.index-a.index:a.posy-b.posy; - }); -} - // ------ 画布、位置、阻激夹域,显伤 ------ // ////// 设置画布偏移 From f642c2a11b8dc334328c6188c71ded587989989f Mon Sep 17 00:00:00 2001 From: qweasz687 <66411718+qweasz687@users.noreply.github.com> Date: Tue, 10 Aug 2021 15:39:40 +0800 Subject: [PATCH 02/11] Update events.js --- libs/events.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libs/events.js b/libs/events.js index a63c887e..e01801a3 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1533,6 +1533,16 @@ events.prototype._action_setViewport = function (data, x, y, prefix) { this.__action_doAsyncFunc(data.async, core.moveViewport, data.loc[0], data.loc[1], data.moveMode, data.time); } +events.prototype._action_lockViewport = function (data, x, y, prefix) { + flags.__lockViewport__ = true; + core.doAction(); +} + +events.prototype._action_unlockViewport = function (data, x, y, prefix) { + flags.__lockViewport__ = false; + core.doAction(); +} + events.prototype._action_move = function (data, x, y, prefix) { var loc = this.__action_getLoc(data.loc, x, y, prefix); this.__action_doAsyncFunc(data.async, core.moveBlock, loc[0], loc[1], data.steps, data.time, data.keep); From 24af8595a6011113d38ceab3b37f99b7461683c4 Mon Sep 17 00:00:00 2001 From: qweasz687 <66411718+qweasz687@users.noreply.github.com> Date: Tue, 10 Aug 2021 15:56:08 +0800 Subject: [PATCH 03/11] Update control.js --- libs/control.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/libs/control.js b/libs/control.js index 8b338b1e..4edc7b2a 100644 --- a/libs/control.js +++ b/libs/control.js @@ -801,7 +801,7 @@ control.prototype.tryMoveDirectly = function (destX, destY) { } ////// 绘制勇士 ////// -control.prototype.drawHero = function (status, offset, frame) { +control.prototype.drawHero = function (status, offset, frame, noGather) { if (!core.isPlaying() || !core.status.floorId || core.status.gameOver) return; var x = core.getHeroLoc('x'), y = core.getHeroLoc('y'), direction = core.getHeroLoc('direction'); status = status || 'stop'; @@ -820,7 +820,7 @@ control.prototype.drawHero = function (status, offset, frame) { this._drawHero_updateViewport(x, y, offset); if (!core.hasFlag('hideHero')) { - this._drawHero_draw(direction, x, y, status, offset, frame); + this._drawHero_draw(direction, x, y, status, offset, frame, noGather); } } @@ -836,15 +836,15 @@ control.prototype._drawHero_updateViewport = function (x, y, offset) { core.control.updateViewport(); } -control.prototype._drawHero_draw = function (direction, x, y, status, offset, frame) { - this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) { +control.prototype._drawHero_draw = function (direction, x, y, status, offset, frame, noGather) { + this._drawHero_getDrawObjs(direction, x, y, status, offset, noGather).forEach(function (block) { core.drawImage('hero', block.img, (block.heroIcon[block.status] + (frame || 0))%4*block.width, block.heroIcon.loc * block.height, block.width, block.height, block.posx+(32-block.width)/2, block.posy+32-block.height, block.width, block.height); }); } -control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, offset) { +control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, offset, noGather) { var heroIconArr = core.material.icons.hero, drawObjs = [], index = 0; drawObjs.push({ "img": core.material.images.hero, @@ -856,18 +856,21 @@ control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, off "status": status, "index": index++, }); - core.status.hero.followers.forEach(function (t) { - drawObjs.push({ - "img": core.material.images.images[t.name], - "width": core.material.images.images[t.name].width/4, - "height": core.material.images.images[t.name].height/4, - "heroIcon": heroIconArr[t.direction], - "posx": 32*t.x - core.bigmap.offsetX + (t.stop?0:core.utils.scan2[t.direction].x*Math.abs(offset.x)), - "posy": 32*t.y - core.bigmap.offsetY + (t.stop?0:core.utils.scan2[t.direction].y*Math.abs(offset.y)), - "status": t.stop?"stop":status, - "index": index++ + // 不重绘跟随者 比如说跳跃时…… + if (!noGather) { + core.status.hero.followers.forEach(function(t) { + drawObjs.push({ + "img": core.material.images.images[t.name], + "width": core.material.images.images[t.name].width / 4, + "height": core.material.images.images[t.name].height / 4, + "heroIcon": heroIconArr[t.direction], + "posx": 32 * t.x - core.bigmap.offsetX + (t.stop ? 0 : core.utils.scan2[t.direction].x * Math.abs(offset.x)), + "posy": 32 * t.y - core.bigmap.offsetY + (t.stop ? 0 : core.utils.scan2[t.direction].y * Math.abs(offset.y)), + "status": t.stop ? "stop" : status, + "index": index++ + }); }); - }); + } return drawObjs.sort(function(a, b) { return a.posy==b.posy?b.index-a.index:a.posy-b.posy; }); From e9fafb9504d596c9253525015182ec88f2ddd444 Mon Sep 17 00:00:00 2001 From: qweasz687 <66411718+qweasz687@users.noreply.github.com> Date: Tue, 10 Aug 2021 16:07:56 +0800 Subject: [PATCH 04/11] Create events.js --- libs/events.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libs/events.js b/libs/events.js index e01801a3..5484e169 100644 --- a/libs/events.js +++ b/libs/events.js @@ -3540,14 +3540,13 @@ events.prototype._jumpHero_doJump = function (jumpInfo, callback) { events.prototype._jumpHero_jumping = function (jumpInfo) { core.clearMap('hero'); core.maps.__updateJumpInfo(jumpInfo); + var x = core.getHeroLoc('x'), + y = core.getHeroLoc('y'); var nowx = jumpInfo.px, nowy = jumpInfo.py, width = jumpInfo.width || 32, height = jumpInfo.height; - core.bigmap.offsetX = core.clamp(nowx - 32*core.__HALF_SIZE__, 0, 32*core.bigmap.width-core.__PIXELS__); - core.bigmap.offsetY = core.clamp(nowy - 32*core.__HALF_SIZE__, 0, 32*core.bigmap.height-core.__PIXELS__); - core.control.updateViewport(); - core.drawImage('hero', core.material.images.hero, jumpInfo.icon.stop, jumpInfo.icon.loc * height, width, height, - nowx + (32 - width) / 2 - core.bigmap.offsetX, nowy + 32-height - core.bigmap.offsetY, width, height); - core.status.heroCenter.px = nowx + 16; - core.status.heroCenter.py = nowy + 32 - height / 2; + core.drawHero(null, { + x: nowx - 32 * x, + y: nowy - 32 * y + }, 0, true); } events.prototype._jumpHero_finished = function (animate, ex, ey, callback) { From 994692eaaf58cfd2905f17c6a471fa666c86ae4f Mon Sep 17 00:00:00 2001 From: qweasz687 <66411718+qweasz687@users.noreply.github.com> Date: Tue, 10 Aug 2021 16:12:35 +0800 Subject: [PATCH 05/11] Update MotaAction.g4 --- _server/MotaAction.g4 | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index ae25dcec..d6d185bb 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -822,6 +822,8 @@ action | changePos_s | setViewport_s | setViewport_1_s + | lockViewport_s + | unlockViewport_s | useItem_s | loadEquip_s | unloadEquip_s @@ -2090,6 +2092,30 @@ var code = '{"type": "setViewport"'+loc+MoveMode_List_0+Int_0+Bool_0+'},\n'; return code; */; +lockViewport_s + : '锁定视角' Newline + +/* lockViewport_s +tooltip : lockViewport: 锁定视角 +helpUrl : /_docs/#/instruction +default : [] +colour : this.soundColor +var code = '{"type": "lockViewport"},\n'; +return code; +*/; + +unlockViewport_s + : '解锁视角' Newline + +/* unlockViewport_s +tooltip : unlockViewport: 解锁视角 +helpUrl : /_docs/#/instruction +default : [] +colour : this.soundColor +var code = '{"type": "unlockViewport"},\n'; +return code; +*/; + showImage_s : '显示图片' '图片编号' NInt '图片' EvalString '翻转' Reverse_List BGNL? '绘制的起点像素' 'x' PosString 'y' PosString '不透明度' Number '时间' Int '不等待执行完毕' Bool Newline @@ -4103,4 +4129,4 @@ this.block('idTemp_e').output='idString_e'; MotaActionParser() -*/ \ No newline at end of file +*/ From 73256d176d93b13e1d5f669abe53172eab993072 Mon Sep 17 00:00:00 2001 From: qweasz687 <66411718+qweasz687@users.noreply.github.com> Date: Tue, 10 Aug 2021 16:14:15 +0800 Subject: [PATCH 06/11] Update MotaActionParser.js --- _server/MotaActionParser.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index fa6e9ab5..e25069b4 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -560,6 +560,14 @@ ActionParser.prototype.parseAction = function() { data.loc[0],data.loc[1],data.moveMode||'', data.time||0,data.async||false,this.next]); } break; + case "lockViewport": + this.next = MotaActionBlocks['lockViewport_s'].xmlText([ + this.next]); + break; + case "unlockViewport": + this.next = MotaActionBlocks['unlockViewport_s'].xmlText([ + this.next]); + break; case "vibrate": // 画面震动 this.next = MotaActionBlocks['vibrate_s'].xmlText([data.direction||'horizontal', data.time||0, data.speed, data.power, data.async||false, this.next]); @@ -1708,4 +1716,4 @@ MotaActionFunctions.replaceFromName = function (str) { return str; } -} \ No newline at end of file +} From 372dc310b83a9ae59bdb3bb576e037835d4d299b Mon Sep 17 00:00:00 2001 From: qweasz687 <66411718+qweasz687@users.noreply.github.com> Date: Tue, 10 Aug 2021 17:44:48 +0800 Subject: [PATCH 07/11] Update events.js --- libs/events.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libs/events.js b/libs/events.js index 5484e169..f30dc7c6 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1534,12 +1534,7 @@ events.prototype._action_setViewport = function (data, x, y, prefix) { } events.prototype._action_lockViewport = function (data, x, y, prefix) { - flags.__lockViewport__ = true; - core.doAction(); -} - -events.prototype._action_unlockViewport = function (data, x, y, prefix) { - flags.__lockViewport__ = false; + flags.__lockViewport__ = data.lock; core.doAction(); } @@ -3492,10 +3487,16 @@ events.prototype._eventMoveHero_moving = function (step, moveSteps) { return true; } if (step <= 4) { - core.drawHero('leftFoot', 4 * o * step); + core.drawHero('leftFoot', { + x: 4 * o * step, + y: 4 * o * step + }); } else if (step <= 8) { - core.drawHero('rightFoot', 4 * o * step); + core.drawHero('rightFoot', { + x: 4 * o * step, + y: 4 * o * step + }); } if (step == 8) { core.setHeroLoc('x', x + o * core.utils.scan2[direction].x, true); From b795a321b055797310c70560d2a15c3e4147224a Mon Sep 17 00:00:00 2001 From: qweasz687 <66411718+qweasz687@users.noreply.github.com> Date: Tue, 10 Aug 2021 17:48:46 +0800 Subject: [PATCH 08/11] Create MotaAction.g4 --- _server/MotaAction.g4 | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index d6d185bb..6fc77c7e 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -823,7 +823,6 @@ action | setViewport_s | setViewport_1_s | lockViewport_s - | unlockViewport_s | useItem_s | loadEquip_s | unloadEquip_s @@ -2093,26 +2092,15 @@ return code; */; lockViewport_s - : '锁定视角' Newline + : '是否锁定视角' Bool Newline /* lockViewport_s -tooltip : lockViewport: 锁定视角 +tooltip : lockViewport: 是否锁定视角 helpUrl : /_docs/#/instruction default : [] colour : this.soundColor -var code = '{"type": "lockViewport"},\n'; -return code; -*/; - -unlockViewport_s - : '解锁视角' Newline - -/* unlockViewport_s -tooltip : unlockViewport: 解锁视角 -helpUrl : /_docs/#/instruction -default : [] -colour : this.soundColor -var code = '{"type": "unlockViewport"},\n'; +Bool_0 = Bool_0 ? (', "lock": true') : ''; +var code = '{"type": "lockViewport"'+Bool_0+'},\n'; return code; */; From ba53ae76dc0b0b4a69fc9ecd3b3a0e4dd3ad9ed4 Mon Sep 17 00:00:00 2001 From: qweasz687 <66411718+qweasz687@users.noreply.github.com> Date: Tue, 10 Aug 2021 17:50:41 +0800 Subject: [PATCH 09/11] Update MotaActionParser.js --- _server/MotaActionParser.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index e25069b4..329e6df7 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -561,11 +561,7 @@ ActionParser.prototype.parseAction = function() { } break; case "lockViewport": - this.next = MotaActionBlocks['lockViewport_s'].xmlText([ - this.next]); - break; - case "unlockViewport": - this.next = MotaActionBlocks['unlockViewport_s'].xmlText([ + this.next = MotaActionBlocks['lockViewport_s'].xmlText([data.lock, this.next]); break; case "vibrate": // 画面震动 From e6c793eb4c7585b6a33386f68ba9467afd3607be Mon Sep 17 00:00:00 2001 From: qweasz687 <66411718+qweasz687@users.noreply.github.com> Date: Tue, 10 Aug 2021 17:52:57 +0800 Subject: [PATCH 10/11] Create editor_blocklyconfig.js --- _server/editor_blocklyconfig.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_server/editor_blocklyconfig.js b/_server/editor_blocklyconfig.js index 51ecdd02..6132edb6 100644 --- a/_server/editor_blocklyconfig.js +++ b/_server/editor_blocklyconfig.js @@ -205,6 +205,7 @@ editor_blocklyconfig=(function(){ MotaActionBlocks['animate_1_s'].xmlText(), MotaActionBlocks['setViewport_s'].xmlText(), MotaActionBlocks['setViewport_1_s'].xmlText(), + MotaActionBlocks['lockViewport_s'].xmlText(), MotaActionBlocks['showStatusBar_s'].xmlText(), MotaActionBlocks['hideStatusBar_s'].xmlText(), MotaActionBlocks['showHero_s'].xmlText(), @@ -708,4 +709,4 @@ function omitedcheckUpdateFunction(event) { // end mark sfergsvae -}).toString().split('// start mark sfergsvae')[1].split('// end mark sfergsvae')[0] \ No newline at end of file +}).toString().split('// start mark sfergsvae')[1].split('// end mark sfergsvae')[0] From 7b4ddb87f07b03b09de32257248aa920e5a01e7a Mon Sep 17 00:00:00 2001 From: qweasz687 <66411718+qweasz687@users.noreply.github.com> Date: Tue, 10 Aug 2021 18:01:05 +0800 Subject: [PATCH 11/11] Update MotaAction.g4 --- _server/MotaAction.g4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 6fc77c7e..4b94420f 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -2097,7 +2097,7 @@ lockViewport_s /* lockViewport_s tooltip : lockViewport: 是否锁定视角 helpUrl : /_docs/#/instruction -default : [] +default : [false] colour : this.soundColor Bool_0 = Bool_0 ? (', "lock": true') : ''; var code = '{"type": "lockViewport"'+Bool_0+'},\n';