Merge pull request #53 from zhaouv/dev-2.0-appendPic-20180218

Update editor-blockly-template
This commit is contained in:
Zhang Chen 2018-02-25 15:55:57 +08:00 committed by GitHub
commit 3ad7bf528e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 43 deletions

View File

@ -112,6 +112,13 @@ initscript=String.raw`
MotaActionBlocks['evalString_e'].xmlText(), MotaActionBlocks['evalString_e'].xmlText(),
], ],
'template':[ 'template':[
'<label text="检测音乐如果没有开启则系统提示开启"></label>',
MotaActionFunctions.actionParser.parseList({"type": "if", "condition": "!core.musicStatus.bgmStatus",
"true": [
"\t[系统提示]你当前音乐处于关闭状态,本塔开音乐游戏效果更佳"
],
"false": []
}),
'<label text="战前剧情"></label>', '<label text="战前剧情"></label>',
MotaActionFunctions.actionParser.parse({ MotaActionFunctions.actionParser.parse({
"trigger": "action", "trigger": "action",
@ -363,19 +370,19 @@ editor_blockly.doubleClickBlock = function (blockId){
var b=editor_blockly.workspace.getBlockById(blockId); var b=editor_blockly.workspace.getBlockById(blockId);
console.log(b); console.log(b);
var textStringDict = { var textStringDict = {
'text_0_s':'EvalString_0', 'text_0_s':'EvalString_0',
'text_1_s':'EvalString_2', 'text_1_s':'EvalString_2',
'choices_s':'EvalString_0', 'choices_s':'EvalString_0',
'function_s':'RawEvalString_0', 'function_s':'RawEvalString_0',
} }
var f=textStringDict[b.type]; var f=b?textStringDict[b.type]:null;
if(f){ if(f){
var value = b.getFieldValue(f); var value = b.getFieldValue(f);
//多行编辑 //多行编辑
editor_blockly.multiLineEdit(value,b,f,function(newvalue,b,f){ editor_blockly.multiLineEdit(value,b,f,function(newvalue,b,f){
if(textStringDict[b.type]!=='RawEvalString_0'){} if(textStringDict[b.type]!=='RawEvalString_0'){}
b.setFieldValue(newvalue.split('\n').join('\\n'),f); b.setFieldValue(newvalue.split('\n').join('\\n'),f);
}); });
} }
} }

View File

@ -19,7 +19,6 @@ function core() {
'turnHeroTimeout': null, 'turnHeroTimeout': null,
} }
this.interval = { this.interval = {
'heroMoveTriggerInterval': null,
'heroMoveInterval': null, 'heroMoveInterval': null,
"tipAnimate": null, "tipAnimate": null,
'openDoorAnimate': null, 'openDoorAnimate': null,
@ -100,6 +99,7 @@ function core() {
'lastDirection': null, 'lastDirection': null,
'cursorX': null, 'cursorX': null,
'cursorY': 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.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.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() {
//core.setHeroMoveTriggerInterval();
if (core.isset(callback)) callback(); 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.resetStatus(core.firstData.hero, hard, core.firstData.floorId, null, core.initStatus.maps);
core.events.setInitData(hard); core.events.setInitData(hard);
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() { core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() {
//core.setHeroMoveTriggerInterval();
core.startReplay(route); core.startReplay(route);
}); });
}, function () { }, function () {
@ -1284,8 +1282,10 @@ core.prototype.onup = function () {
var posx=core.status.stepPostfix[0].x; var posx=core.status.stepPostfix[0].x;
var posy=core.status.stepPostfix[0].y; var posy=core.status.stepPostfix[0].y;
core.status.stepPostfix=[]; core.status.stepPostfix=[];
core.canvas.ui.clearRect(0, 0, 416,416); if (!core.status.lockControl) {
core.canvas.ui.restore(); 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) { 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; var lastX = core.status.automaticRoute.destX, lastY=core.status.automaticRoute.destY;
core.stopAutomaticRoute(); core.stopAutomaticRoute();
if (lastX==destX && lastY==destY) { if (lastX==destX && lastY==destY) {
core.lockControl(); core.status.automaticRoute.moveDirectly = true;
setTimeout(function () { setTimeout(function () {
core.unLockControl(); if (core.status.automaticRoute.moveDirectly && core.status.heroMoving==0) {
if (core.canMoveDirectly(destX, destY)) { if (core.canMoveDirectly(destX, destY)) {
core.clearMap('hero', 0, 0, 416, 416); core.clearMap('hero', 0, 0, 416, 416);
core.setHeroLoc('x', destX); core.setHeroLoc('x', destX);
core.setHeroLoc('y', destY); core.setHeroLoc('y', destY);
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop'); core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
core.status.route.push("move:"+destX+":"+destY); core.status.route.push("move:"+destX+":"+destY);
}
} }
core.status.automaticRoute.moveDirectly = false;
}, 100); }, 100);
} }
return; return;
@ -2013,6 +2015,9 @@ core.prototype.canMoveDirectly = function (destX,destY) {
var fromX = core.getHeroLoc('x'), fromY = core.getHeroLoc('y'); var fromX = core.getHeroLoc('x'), fromY = core.getHeroLoc('y');
if (fromX==destX&&fromY==destY) return false; if (fromX==destX&&fromY==destY) return false;
if (core.getBlock(fromX,fromY)!=null||core.status.checkBlock.damage[13*fromX+fromY]>0)
return false;
// BFS // BFS
var visited=[], queue=[]; var visited=[], queue=[];
visited[13*fromX+fromY]=true; visited[13*fromX+fromY]=true;
@ -2041,17 +2046,18 @@ core.prototype.moveHero = function (direction, callback) {
core.setHeroLoc('direction', direction); core.setHeroLoc('direction', direction);
if (!core.isset(callback)) { // 如果不存在回调函数则使用heroMoveTrigger if (!core.isset(callback)) { // 如果不存在回调函数则使用heroMoveTrigger
core.status.heroStop = false; core.status.heroStop = false;
if (core.interval.heroMoveTriggerInterval==null) { core.status.automaticRoute.moveDirectly = false;
core.moveAction();
core.interval.heroMoveTriggerInterval = setInterval(function () { var doAction = function () {
if (!core.status.heroStop) { if (!core.status.heroStop) {
core.moveAction(); core.moveAction();
} setTimeout(doAction, 50);
else { }
core.stopHero(); else {
} core.stopHero();
}, 50) }
} }
doAction();
} }
else { // 否则只向某个方向移动一步然后调用callback else { // 否则只向某个方向移动一步然后调用callback
core.moveAction(function () { core.moveAction(function () {
@ -2147,6 +2153,7 @@ core.prototype.waitHeroToStop = function(callback) {
if (core.isset(callback)) { if (core.isset(callback)) {
core.status.replay.animate=true; core.status.replay.animate=true;
core.lockControl(); core.lockControl();
core.status.automaticRoute.moveDirectly = false;
setTimeout(function(){ setTimeout(function(){
core.status.replay.animate=false; core.status.replay.animate=false;
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop'); 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.prototype.stopHero = function () {
core.status.heroStop = true; 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) { 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.resetStatus(core.firstData.hero, data.hard, core.firstData.floorId, null, core.initStatus.maps);
core.events.setInitData(data.hard); core.events.setInitData(data.hard);
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() { core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() {
//core.setHeroMoveTriggerInterval();
core.startReplay(core.decodeRoute(data.route)); core.startReplay(core.decodeRoute(data.route));
}); });
} }
@ -4626,10 +4631,10 @@ core.prototype.syncLoad = function () {
} }
}; };
xhr.ontimeout = function() { xhr.ontimeout = function() {
core.drawText("出错啦!\n无法同步存档到服务器。\n错误原因Timeout"); core.drawText("出错啦!\n无法从服务器同步存档。\n错误原因Timeout");
} }
xhr.onerror = function() { xhr.onerror = function() {
core.drawText("出错啦!\n无法同步存档到服务器。\n错误原因XHR Error"); core.drawText("出错啦!\n无法从服务器同步存档。\n错误原因XHR Error");
} }
xhr.send(formData); xhr.send(formData);
} }
@ -4798,7 +4803,6 @@ core.prototype.loadData = function (data, callback) {
core.events.afterLoadData(data); core.events.afterLoadData(data);
core.changeFloor(data.floorId, null, data.hero.loc, 0, function() { core.changeFloor(data.floorId, null, data.hero.loc, 0, function() {
//core.setHeroMoveTriggerInterval();
if (core.isset(callback)) callback(); if (core.isset(callback)) callback();
}); });
} }

View File

@ -375,9 +375,11 @@ events.prototype.doAction = function() {
originBlock.block.id = data.number; originBlock.block.id = data.number;
originBlock.block.event = block.event; originBlock.block.event = block.event;
} }
core.drawMap(floorId); if (floorId==core.status.floorId) {
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop'); core.drawMap(floorId);
core.updateStatusBar(); core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
core.updateStatusBar();
}
} }
this.doAction(); this.doAction();
break; break;