From ca660b481a44d75d01bb7eb0e7c494ca6764f038 Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 21 Feb 2018 23:06:26 +0800 Subject: [PATCH 1/7] Fix SetBlock Bug --- libs/events.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/events.js b/libs/events.js index e0ed7b83..95a8283d 100644 --- a/libs/events.js +++ b/libs/events.js @@ -375,9 +375,11 @@ events.prototype.doAction = function() { originBlock.block.id = data.number; originBlock.block.event = block.event; } - core.drawMap(floorId); - core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop'); - core.updateStatusBar(); + if (floorId==core.status.floorId) { + core.drawMap(floorId); + core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop'); + core.updateStatusBar(); + } } this.doAction(); break; From 7b2c7c3509444f1c0cea36ca0caa2d8dd573d63b Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Fri, 23 Feb 2018 16:28:49 +0800 Subject: [PATCH 2/7] Update editor-blockly-template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 事件模板中添加 检测音乐如果没有开启则系统提示开启 --- _server/editor_blockly.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 9ece3a08..7d6da9ea 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -112,6 +112,13 @@ initscript=String.raw` MotaActionBlocks['evalString_e'].xmlText(), ], 'template':[ + '', + MotaActionFunctions.actionParser.parseList({"type": "if", "condition": "!core.musicStatus.bgmStatus", + "true": [ + "\t[系统提示]你当前音乐处于关闭状态,本塔开音乐游戏效果更佳" + ], + "false": [] + }), '', MotaActionFunctions.actionParser.parse({ "trigger": "action", @@ -363,19 +370,19 @@ editor_blockly.doubleClickBlock = function (blockId){ var b=editor_blockly.workspace.getBlockById(blockId); console.log(b); var textStringDict = { - 'text_0_s':'EvalString_0', - 'text_1_s':'EvalString_2', - 'choices_s':'EvalString_0', - 'function_s':'RawEvalString_0', + 'text_0_s':'EvalString_0', + 'text_1_s':'EvalString_2', + 'choices_s':'EvalString_0', + 'function_s':'RawEvalString_0', } - var f=textStringDict[b.type]; + var f=b?textStringDict[b.type]:null; if(f){ - var value = b.getFieldValue(f); - //多行编辑 - editor_blockly.multiLineEdit(value,b,f,function(newvalue,b,f){ - if(textStringDict[b.type]!=='RawEvalString_0'){} - b.setFieldValue(newvalue.split('\n').join('\\n'),f); - }); + var value = b.getFieldValue(f); + //多行编辑 + editor_blockly.multiLineEdit(value,b,f,function(newvalue,b,f){ + if(textStringDict[b.type]!=='RawEvalString_0'){} + b.setFieldValue(newvalue.split('\n').join('\\n'),f); + }); } } From ef901990a0a0873f336b5870fee8786038ed2e93 Mon Sep 17 00:00:00 2001 From: oc Date: Fri, 23 Feb 2018 23:52:04 +0800 Subject: [PATCH 3/7] Fix Move Directly Bug --- libs/core.js | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/libs/core.js b/libs/core.js index 21bcc4bb..77d4e136 100644 --- a/libs/core.js +++ b/libs/core.js @@ -100,6 +100,7 @@ function core() { 'lastDirection': null, 'cursorX': null, 'cursorY': null, + "moveDirectly": false, }, // 按下键的时间:为了判定双击 @@ -1279,8 +1280,10 @@ core.prototype.onup = function () { var posx=core.status.stepPostfix[0].x; var posy=core.status.stepPostfix[0].y; core.status.stepPostfix=[]; - core.canvas.ui.clearRect(0, 0, 416,416); - core.canvas.ui.restore(); + if (!core.status.lockControl) { + core.canvas.ui.clearRect(0, 0, 416,416); + core.canvas.ui.restore(); + } // 长按 if (!core.status.lockControl && stepPostfix.length==0 && core.status.downTime!=null && new Date()-core.status.downTime>=1000) { @@ -1559,15 +1562,19 @@ core.prototype.setAutomaticRoute = function (destX, destY, stepPostfix) { core.stopAutomaticRoute(); if (lastX==destX && lastY==destY) { core.lockControl(); + core.status.automaticRoute.moveDirectly = true; setTimeout(function () { - core.unLockControl(); - if (core.canMoveDirectly(destX, destY)) { - core.clearMap('hero', 0, 0, 416, 416); - core.setHeroLoc('x', destX); - core.setHeroLoc('y', destY); - core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop'); - core.status.route.push("move:"+destX+":"+destY); + if (core.status.automaticRoute.moveDirectly) { + core.unLockControl(); + if (core.canMoveDirectly(destX, destY)) { + core.clearMap('hero', 0, 0, 416, 416); + core.setHeroLoc('x', destX); + core.setHeroLoc('y', destY); + core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop'); + core.status.route.push("move:"+destX+":"+destY); + } } + core.status.automaticRoute.moveDirectly = false; }, 100); } return; @@ -2008,6 +2015,9 @@ core.prototype.canMoveDirectly = function (destX,destY) { var fromX = core.getHeroLoc('x'), fromY = core.getHeroLoc('y'); if (fromX==destX&&fromY==destY) return false; + if (core.getBlock(fromX,fromY)!=null||core.status.checkBlock.damage[13*fromX+fromY]>0) + return false; + // BFS var visited=[], queue=[]; visited[13*fromX+fromY]=true; @@ -2142,6 +2152,7 @@ core.prototype.waitHeroToStop = function(callback) { if (core.isset(callback)) { core.status.replay.animate=true; core.lockControl(); + core.status.automaticRoute.moveDirectly = false; setTimeout(function(){ core.status.replay.animate=false; core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop'); @@ -2153,6 +2164,7 @@ core.prototype.waitHeroToStop = function(callback) { ////// 停止勇士的移动状态 ////// core.prototype.stopHero = function () { core.status.heroStop = true; + core.status.automaticRoute.moveDirectly = false; clearInterval(core.interval.heroMoveTriggerInterval); core.interval.heroMoveTriggerInterval=null; } @@ -2380,6 +2392,7 @@ core.prototype.trigger = function (x, y) { } } } + core.status.automaticRoute.moveDirectly = false; core.material.events[trigger](mapBlocks[b], core, function (data) { }); From a2d85bbc633656e6f7fa0f5c2ffd9feed3e8d08a Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 25 Feb 2018 01:28:09 +0800 Subject: [PATCH 4/7] Fix Move Directly Bug --- libs/core.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libs/core.js b/libs/core.js index 77d4e136..9e08155b 100644 --- a/libs/core.js +++ b/libs/core.js @@ -1561,11 +1561,9 @@ core.prototype.setAutomaticRoute = function (destX, destY, stepPostfix) { var lastX = core.status.automaticRoute.destX, lastY=core.status.automaticRoute.destY; core.stopAutomaticRoute(); if (lastX==destX && lastY==destY) { - core.lockControl(); core.status.automaticRoute.moveDirectly = true; setTimeout(function () { if (core.status.automaticRoute.moveDirectly) { - core.unLockControl(); if (core.canMoveDirectly(destX, destY)) { core.clearMap('hero', 0, 0, 416, 416); core.setHeroLoc('x', destX); @@ -2046,6 +2044,7 @@ core.prototype.moveHero = function (direction, callback) { core.setHeroLoc('direction', direction); if (!core.isset(callback)) { // 如果不存在回调函数,则使用heroMoveTrigger core.status.heroStop = false; + core.status.automaticRoute.moveDirectly = false; if (core.interval.heroMoveTriggerInterval==null) { core.moveAction(); core.interval.heroMoveTriggerInterval = setInterval(function () { @@ -4606,10 +4605,10 @@ core.prototype.syncLoad = function () { } }; xhr.ontimeout = function() { - core.drawText("出错啦!\n无法同步存档到服务器。\n错误原因:Timeout"); + core.drawText("出错啦!\n无法从服务器同步存档。\n错误原因:Timeout"); } xhr.onerror = function() { - core.drawText("出错啦!\n无法同步存档到服务器。\n错误原因:XHR Error"); + core.drawText("出错啦!\n无法从服务器同步存档。\n错误原因:XHR Error"); } xhr.send(formData); } From be2696c4062ac2bb02b8105304ea082a5c2f3165 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sun, 25 Feb 2018 12:31:13 +0800 Subject: [PATCH 5/7] Fix SetInterval Bug --- libs/core.js | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/libs/core.js b/libs/core.js index 9e08155b..f4fb69c5 100644 --- a/libs/core.js +++ b/libs/core.js @@ -19,7 +19,6 @@ function core() { 'turnHeroTimeout': null, } this.interval = { - 'heroMoveTriggerInterval': null, 'heroMoveInterval': null, "tipAnimate": null, 'openDoorAnimate': null, @@ -801,7 +800,6 @@ core.prototype.startGame = function (hard, callback) { core.resetStatus(core.firstData.hero, hard, core.firstData.floorId, null, core.initStatus.maps); core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() { - //core.setHeroMoveTriggerInterval(); if (core.isset(callback)) callback(); }); @@ -1153,7 +1151,6 @@ core.prototype.keyUp = function(keyCode) { core.resetStatus(core.firstData.hero, hard, core.firstData.floorId, null, core.initStatus.maps); core.events.setInitData(hard); core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() { - //core.setHeroMoveTriggerInterval(); core.startReplay(route); }); }, function () { @@ -2045,17 +2042,17 @@ core.prototype.moveHero = function (direction, callback) { if (!core.isset(callback)) { // 如果不存在回调函数,则使用heroMoveTrigger core.status.heroStop = false; core.status.automaticRoute.moveDirectly = false; - if (core.interval.heroMoveTriggerInterval==null) { - core.moveAction(); - core.interval.heroMoveTriggerInterval = setInterval(function () { - if (!core.status.heroStop) { - core.moveAction(); - } - else { - core.stopHero(); - } - }, 50) + + var doAction = function () { + if (!core.status.heroStop) { + core.moveAction(); + setTimeout(doAction, 50); + } + else { + core.stopHero(); + } } + doAction(); } else { // 否则,只向某个方向移动一步,然后调用callback core.moveAction(function () { @@ -2163,9 +2160,6 @@ core.prototype.waitHeroToStop = function(callback) { ////// 停止勇士的移动状态 ////// core.prototype.stopHero = function () { core.status.heroStop = true; - core.status.automaticRoute.moveDirectly = false; - clearInterval(core.interval.heroMoveTriggerInterval); - core.interval.heroMoveTriggerInterval=null; } ////// 绘制勇士 ////// @@ -4451,7 +4445,6 @@ core.prototype.doSL = function (id, type) { core.resetStatus(core.firstData.hero, data.hard, core.firstData.floorId, null, core.initStatus.maps); core.events.setInitData(data.hard); core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() { - //core.setHeroMoveTriggerInterval(); core.startReplay(core.decodeRoute(data.route)); }); } @@ -4777,7 +4770,6 @@ core.prototype.loadData = function (data, callback) { core.events.afterLoadData(data); core.changeFloor(data.floorId, null, data.hero.loc, 0, function() { - //core.setHeroMoveTriggerInterval(); if (core.isset(callback)) callback(); }); } From cdf8d6ccff2031836e5c7d770d1034b1867109e2 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sun, 25 Feb 2018 13:55:10 +0800 Subject: [PATCH 6/7] Fix SetInterval Bug --- libs/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/core.js b/libs/core.js index f4fb69c5..df506406 100644 --- a/libs/core.js +++ b/libs/core.js @@ -1570,7 +1570,7 @@ core.prototype.setAutomaticRoute = function (destX, destY, stepPostfix) { } } core.status.automaticRoute.moveDirectly = false; - }, 100); + }, 200); } return; } From 0b548955c4681c633a379d6ecbf144bad0b28942 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sun, 25 Feb 2018 14:24:32 +0800 Subject: [PATCH 7/7] Fix Move Directly Bug --- libs/core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/core.js b/libs/core.js index df506406..699806ad 100644 --- a/libs/core.js +++ b/libs/core.js @@ -1560,7 +1560,7 @@ core.prototype.setAutomaticRoute = function (destX, destY, stepPostfix) { if (lastX==destX && lastY==destY) { core.status.automaticRoute.moveDirectly = true; setTimeout(function () { - if (core.status.automaticRoute.moveDirectly) { + if (core.status.automaticRoute.moveDirectly && core.status.heroMoving==0) { if (core.canMoveDirectly(destX, destY)) { core.clearMap('hero', 0, 0, 416, 416); core.setHeroLoc('x', destX); @@ -1570,7 +1570,7 @@ core.prototype.setAutomaticRoute = function (destX, destY, stepPostfix) { } } core.status.automaticRoute.moveDirectly = false; - }, 200); + }, 100); } return; }