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); + }); } } diff --git a/libs/core.js b/libs/core.js index 62235906..b5996306 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, @@ -100,6 +99,7 @@ function core() { 'lastDirection': null, 'cursorX': null, 'cursorY': null, + "moveDirectly": false, }, // 按下键的时间:为了判定双击 @@ -805,7 +805,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(); }); @@ -1157,7 +1156,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 () { @@ -1284,8 +1282,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) { @@ -1563,16 +1563,18 @@ 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 () { - 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.status.heroMoving==0) { + 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; @@ -2013,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; @@ -2041,17 +2046,18 @@ core.prototype.moveHero = function (direction, callback) { core.setHeroLoc('direction', direction); if (!core.isset(callback)) { // 如果不存在回调函数,则使用heroMoveTrigger core.status.heroStop = false; - if (core.interval.heroMoveTriggerInterval==null) { - core.moveAction(); - core.interval.heroMoveTriggerInterval = setInterval(function () { - if (!core.status.heroStop) { - core.moveAction(); - } - else { - core.stopHero(); - } - }, 50) + core.status.automaticRoute.moveDirectly = false; + + var doAction = function () { + if (!core.status.heroStop) { + core.moveAction(); + setTimeout(doAction, 50); + } + else { + core.stopHero(); + } } + doAction(); } else { // 否则,只向某个方向移动一步,然后调用callback core.moveAction(function () { @@ -2147,6 +2153,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'); @@ -2158,8 +2165,6 @@ core.prototype.waitHeroToStop = function(callback) { ////// 停止勇士的移动状态 ////// core.prototype.stopHero = function () { core.status.heroStop = true; - clearInterval(core.interval.heroMoveTriggerInterval); - core.interval.heroMoveTriggerInterval=null; } ////// 绘制勇士 ////// @@ -2385,6 +2390,7 @@ core.prototype.trigger = function (x, y) { } } } + core.status.automaticRoute.moveDirectly = false; core.material.events[trigger](mapBlocks[b], core, function (data) { }); @@ -4472,7 +4478,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)); }); } @@ -4626,10 +4631,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); } @@ -4798,7 +4803,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(); }); } 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;