setBlock multiple locs
This commit is contained in:
parent
83828e57a7
commit
7de3964525
@ -756,7 +756,7 @@ return code;
|
||||
*/;
|
||||
|
||||
setBlock_s
|
||||
: '转变图块为' EvalString 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline
|
||||
: '转变图块为' EvalString 'x' EvalString? ',' 'y' EvalString? '楼层' IdString? Newline
|
||||
|
||||
|
||||
/* setBlock_s
|
||||
@ -765,8 +765,21 @@ helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setblock%EF%BC%9A%E
|
||||
colour : this.mapColor
|
||||
default : ["yellowDoor","","",""]
|
||||
var floorstr = '';
|
||||
if (PosString_0 && PosString_1) {
|
||||
floorstr = ', "loc": ['+PosString_0+','+PosString_1+']';
|
||||
if (EvalString_1 && EvalString_2) {
|
||||
var pattern1 = MotaActionFunctions.pattern.id;
|
||||
if(pattern1.test(EvalString_1) || pattern1.test(EvalString_2)){
|
||||
EvalString_1=MotaActionFunctions.PosString_pre(EvalString_1);
|
||||
EvalString_2=MotaActionFunctions.PosString_pre(EvalString_2);
|
||||
EvalString_1=[EvalString_1,EvalString_2]
|
||||
} else {
|
||||
var pattern2 = /^([+-]?\d+)(,[+-]?\d+)*$/;
|
||||
if(!pattern2.test(EvalString_1) || !pattern2.test(EvalString_2))throw new Error('坐标格式错误,请右键点击帮助查看格式');
|
||||
EvalString_1=EvalString_1.split(',');
|
||||
EvalString_2=EvalString_2.split(',');
|
||||
if(EvalString_1.length!==EvalString_2.length)throw new Error('坐标格式错误,请右键点击帮助查看格式');
|
||||
for(var ii=0;ii<EvalString_1.length;ii++)EvalString_1[ii]='['+EvalString_1[ii]+','+EvalString_2[ii]+']';
|
||||
}
|
||||
floorstr = ', "loc": ['+EvalString_1.join(',')+']';
|
||||
}
|
||||
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
|
||||
var code = '{"type": "setBlock", "number": "'+EvalString_0+'"'+floorstr+IdString_0+'},\n';
|
||||
@ -898,7 +911,7 @@ return code;
|
||||
*/;
|
||||
|
||||
setBgFgBlock_s
|
||||
: '转变图层块' Bg_Fg_List '为' EvalString 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline
|
||||
: '转变图层块' Bg_Fg_List '为' EvalString 'x' EvalString? ',' 'y' EvalString? '楼层' IdString? Newline
|
||||
|
||||
|
||||
/* setBgFgBlock_s
|
||||
@ -907,8 +920,21 @@ helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setblock%EF%BC%9A%E
|
||||
colour : this.mapColor
|
||||
default : ["bg","yellowDoor","","",""]
|
||||
var floorstr = '';
|
||||
if (PosString_0 && PosString_1) {
|
||||
floorstr = ', "loc": ['+PosString_0+','+PosString_1+']';
|
||||
if (EvalString_1 && EvalString_2) {
|
||||
var pattern1 = MotaActionFunctions.pattern.id;
|
||||
if(pattern1.test(EvalString_1) || pattern1.test(EvalString_2)){
|
||||
EvalString_1=MotaActionFunctions.PosString_pre(EvalString_1);
|
||||
EvalString_2=MotaActionFunctions.PosString_pre(EvalString_2);
|
||||
EvalString_1=[EvalString_1,EvalString_2]
|
||||
} else {
|
||||
var pattern2 = /^([+-]?\d+)(,[+-]?\d+)*$/;
|
||||
if(!pattern2.test(EvalString_1) || !pattern2.test(EvalString_2))throw new Error('坐标格式错误,请右键点击帮助查看格式');
|
||||
EvalString_1=EvalString_1.split(',');
|
||||
EvalString_2=EvalString_2.split(',');
|
||||
if(EvalString_1.length!==EvalString_2.length)throw new Error('坐标格式错误,请右键点击帮助查看格式');
|
||||
for(var ii=0;ii<EvalString_1.length;ii++)EvalString_1[ii]='['+EvalString_1[ii]+','+EvalString_2[ii]+']';
|
||||
}
|
||||
floorstr = ', "loc": ['+EvalString_1.join(',')+']';
|
||||
}
|
||||
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
|
||||
var code = '{"type": "setBgFgBlock", "name": "' + Bg_Fg_List_0 + '", "number": "'+EvalString_0+'"'+floorstr+IdString_0+'},\n';
|
||||
@ -2846,9 +2872,16 @@ ActionParser.prototype.parseAction = function() {
|
||||
x_str.join(','),y_str.join(','),data.floorId||'',data.time||0,data.async||false,this.next]);
|
||||
break;
|
||||
case "setBlock": // 设置图块
|
||||
data.loc=data.loc||['',''];
|
||||
data.loc=data.loc||[];
|
||||
if (!(data.loc[0] instanceof Array))
|
||||
data.loc = [data.loc];
|
||||
var x_str=[],y_str=[];
|
||||
data.loc.forEach(function (t) {
|
||||
x_str.push(t[0]);
|
||||
y_str.push(t[1]);
|
||||
})
|
||||
this.next = MotaActionBlocks['setBlock_s'].xmlText([
|
||||
data.number||0,data.loc[0],data.loc[1],data.floorId||'',this.next]);
|
||||
data.number||0,x_str.join(','),y_str.join(','),data.floorId||'',this.next]);
|
||||
break;
|
||||
case "showFloorImg": // 显示贴图
|
||||
data.loc=data.loc||[];
|
||||
@ -2899,9 +2932,16 @@ ActionParser.prototype.parseAction = function() {
|
||||
data.name||'bg', x_str.join(','),y_str.join(','),data.floorId||'',this.next]);
|
||||
break;
|
||||
case "setBgFgBlock": // 设置图块
|
||||
data.loc=data.loc||['',''];
|
||||
data.loc=data.loc||[];
|
||||
if (!(data.loc[0] instanceof Array))
|
||||
data.loc = [data.loc];
|
||||
var x_str=[],y_str=[];
|
||||
data.loc.forEach(function (t) {
|
||||
x_str.push(t[0]);
|
||||
y_str.push(t[1]);
|
||||
})
|
||||
this.next = MotaActionBlocks['setBgFgBlock_s'].xmlText([
|
||||
data.name||"bg", data.number||0,data.loc[0],data.loc[1],data.floorId||'',this.next]);
|
||||
data.name||'bg', data.number||0, x_str.join(','),y_str.join(','),data.floorId||'',this.next]);
|
||||
break;
|
||||
case "setHeroIcon": // 改变勇士
|
||||
this.next = MotaActionBlocks['setHeroIcon_s'].xmlText([
|
||||
|
||||
@ -769,7 +769,8 @@ function omitedcheckUpdateFunction(event) {
|
||||
"showFloorImg_s": ["EvalString_0", "EvalString_1", "IdString_0"],
|
||||
"hideFloorImg_s": ["EvalString_0", "EvalString_1", "IdString_0"],
|
||||
"trigger_s": ["PosString_0", "PosString_1"],
|
||||
"insert_2_s": ["PosString_0", "PosString_1", "IdString_0"]
|
||||
"insert_2_s": ["PosString_0", "PosString_1", "IdString_0"],
|
||||
"animate_s": ["EvalString_0", "EvalString_0"]
|
||||
}
|
||||
|
||||
editor_blockly.selectPoint = function () {
|
||||
@ -778,6 +779,10 @@ function omitedcheckUpdateFunction(event) {
|
||||
if (block != null && block.type in selectPointBlocks) {
|
||||
arr = selectPointBlocks[block.type];
|
||||
var xv = parseInt(block.getFieldValue(arr[0])), yv = parseInt(block.getFieldValue(arr[1]));
|
||||
if (block.type == 'animate_s') {
|
||||
var v = block.getFieldValue(arr[0]).split(",");
|
||||
xv = parseInt(v[0]); yv = parseInt(v[1]);
|
||||
}
|
||||
if (!isNaN(xv)) x = xv;
|
||||
if (!isNaN(yv)) y = yv;
|
||||
if (arr[2] != null) floorId = block.getFieldValue(arr[2]) || floorId;
|
||||
@ -788,8 +793,13 @@ function omitedcheckUpdateFunction(event) {
|
||||
if (fv != editor.currentFloorId) block.setFieldValue(fv, arr[2]);
|
||||
else block.setFieldValue(arr[3] ? fv : "", arr[2]);
|
||||
}
|
||||
if (block.type == 'animate_s') {
|
||||
block.setFieldValue(xv+","+yv, arr[0]);
|
||||
}
|
||||
else {
|
||||
block.setFieldValue(xv+"", arr[0]);
|
||||
block.setFieldValue(yv+"", arr[1]);
|
||||
}
|
||||
if (block.type == 'changeFloor_m') {
|
||||
block.setFieldValue("floorId", "Floor_List_0");
|
||||
block.setFieldValue("loc", "Stair_List_0");
|
||||
|
||||
@ -782,7 +782,10 @@ editor.constructor.prototype.listen=function () {
|
||||
var brushMod3=document.getElementById('brushMod3');
|
||||
if(brushMod3) {
|
||||
brushMod3.onchange=function(){
|
||||
tip.showHelp(5)
|
||||
// tip.showHelp(5)
|
||||
tip.isSelectedBlock(false)
|
||||
tip.msgs[11] = String('tileset贴图模式下可以按选中tileset素材,并在地图上拖动来一次绘制一个区域');
|
||||
tip.whichShow(12);
|
||||
editor.brushMod=brushMod3.value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -496,7 +496,7 @@ uievent.setPoint = function (floorId, x, y) {
|
||||
uievent.values.floorId = floorId;
|
||||
uievent.elements.selectFloor.value = floorId;
|
||||
uievent.values.x = x != null ? x : ( uievent.values.x || 0);
|
||||
uievent.values.y = y != null ? y : ( uievent.values.x || 0);
|
||||
uievent.values.y = y != null ? y : ( uievent.values.y || 0);
|
||||
uievent.values.width = core.floors[uievent.values.floorId].width || core.__SIZE__;
|
||||
uievent.values.height = core.floors[uievent.values.floorId].height || core.__SIZE__;
|
||||
uievent.values.left = core.clamp(uievent.values.x - core.__HALF_SIZE__, 0, uievent.values.width - core.__SIZE__);
|
||||
|
||||
@ -1030,8 +1030,10 @@ events.prototype._action_hide = function (data, x, y, prefix) {
|
||||
}
|
||||
|
||||
events.prototype._action_setBlock = function (data, x, y, prefix) {
|
||||
var loc = this.__action_getLoc(data.loc, x, y, prefix);
|
||||
core.setBlock(data.number, loc[0], loc[1], data.floorId);
|
||||
data.loc = this.__action_getLoc2D(data.loc, x, y, prefix);
|
||||
data.loc.forEach(function (t) {
|
||||
core.setBlock(data.number, t[0], t[1], data.floorId);
|
||||
});
|
||||
core.doAction();
|
||||
}
|
||||
|
||||
@ -1052,8 +1054,10 @@ events.prototype._action_hideBgFgMap = function (data, x, y, prefix) {
|
||||
}
|
||||
|
||||
events.prototype._action_setBgFgBlock = function (data, x, y, prefix) {
|
||||
var loc = this.__action_getLoc(data.loc, x, y, prefix);
|
||||
core.setBgFgBlock(data.name, data.number, loc[0], loc[1], data.floorId);
|
||||
data.loc = this.__action_getLoc2D(data.loc, x, y, prefix);
|
||||
data.loc.forEach(function (t) {
|
||||
core.setBgFgBlock(data.name, data.number, t[0], t[1], data.floorId);
|
||||
});
|
||||
core.doAction();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user