set bg/fg map

This commit is contained in:
oc 2018-09-13 00:22:20 +08:00
parent 2202888419
commit 3d188025ca
5 changed files with 54 additions and 27 deletions

View File

@ -629,7 +629,7 @@ helpUrl : https://ckcz123.github.io/mota-js/#/event?id=changefloor%EF%BC%9A%E6%A
default : ["MT1","0","0",null,500] default : ["MT1","0","0",null,500]
colour : this.dataColor colour : this.dataColor
DirectionEx_List_0 = DirectionEx_List_0 && (', "direction": "'+DirectionEx_List_0+'"'); DirectionEx_List_0 = DirectionEx_List_0 && (', "direction": "'+DirectionEx_List_0+'"');
Int_0 = Int_0 ?(', "time": '+Int_0):''; Int_0 = (Int_0!=='') ?(', "time": '+Int_0):'';
var floorstr = ''; var floorstr = '';
if (PosString_0 && PosString_1) { if (PosString_0 && PosString_1) {
floorstr = ', "loc": ['+PosString_0+','+PosString_1+']'; floorstr = ', "loc": ['+PosString_0+','+PosString_1+']';
@ -1474,8 +1474,10 @@ ActionParser.prototype.parse = function (obj,type) {
obj.floorType=obj.floorId; obj.floorType=obj.floorId;
delete obj.floorId; delete obj.floorId;
} }
if (!this.isset(obj.time)) obj.time=500;
return MotaActionBlocks['changeFloor_m'].xmlText([ return MotaActionBlocks['changeFloor_m'].xmlText([
obj.floorType||'floorId',obj.floorId,obj.stair||'loc',obj.loc[0],obj.loc[1],obj.direction,obj.time||0,!this.isset(obj.portalWithoutTrigger) obj.floorType||'floorId',obj.floorId,obj.stair||'loc',obj.loc[0],obj.loc[1],obj.direction,
obj.time,!this.isset(obj.portalWithoutTrigger)
]); ]);
case 'point': case 'point':

View File

@ -2933,8 +2933,6 @@ control.prototype.resize = function(clientWidth, clientHeight) {
rules: { rules: {
width: (canvasWidth - SPACE*2) + unit, width: (canvasWidth - SPACE*2) + unit,
height:(canvasWidth - SPACE*2) + unit, height:(canvasWidth - SPACE*2) + unit,
top: (canvasTop + SPACE) + unit,
right: SPACE + unit,
} }
}, },
{ {
@ -2942,8 +2940,6 @@ control.prototype.resize = function(clientWidth, clientHeight) {
rules: { rules: {
width: (canvasWidth - SPACE*2) + unit, width: (canvasWidth - SPACE*2) + unit,
height:(canvasWidth - SPACE*2) + unit, height:(canvasWidth - SPACE*2) + unit,
top: (canvasTop + SPACE) + unit,
right: SPACE + unit,
} }
}, },
{ {
@ -2951,8 +2947,6 @@ control.prototype.resize = function(clientWidth, clientHeight) {
rules: { rules: {
width: (canvasWidth - SPACE*2) + unit, width: (canvasWidth - SPACE*2) + unit,
height:(canvasWidth - SPACE*2) + unit, height:(canvasWidth - SPACE*2) + unit,
top: (canvasTop + SPACE) + unit,
right: SPACE + unit,
} }
}, },
{ {

View File

@ -340,20 +340,54 @@ maps.prototype.drawBlock = function (block, animate, dx, dy) {
} }
} }
////// 背景/前景图块的绘制 //////
maps.prototype.drawBgFgMap = function (floorId, canvas, name) {
var width = core.floors[floorId].width || 13;
var height = core.floors[floorId].height || 13;
var groundId = core.floors[floorId].defaultGround || "ground";
var blockIcon = core.material.icons.terrains[groundId];
var blockImage = core.material.images.terrains;
var getMapArray = function (name) {
var arr = core.floors[floorId][name+"map"] || [];
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
arr[y] = arr[y] || [];
if (core.hasFlag(name + "_" + floorId + "_" + x + "_" + y)) arr[y][x] = 0;
else arr[y][x] = core.getFlag(name + "v_" + floorId + "_" + x + "_" + y, arr[y][x] || 0);
}
}
return arr;
}
var arr = getMapArray(name);
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
if (name=='bg')
canvas.drawImage(blockImage, 0, blockIcon * 32, 32, 32, x * 32, y * 32, 32, 32);
if (arr[y][x]>0) {
var block = core.maps.initBlock(x, y, arr[y][x]);
if (core.isset(block.event)) {
var id = block.event.id, cls = block.event.cls;
if (cls == 'autotile')
core.drawAutotile(canvas, arr, block, 32, 0, 0);
else
canvas.drawImage(core.material.images[cls], 0, core.material.icons[cls][id] * 32, 32, 32, x * 32, y * 32, 32, 32);
}
}
}
}
}
////// 绘制某张地图 ////// ////// 绘制某张地图 //////
maps.prototype.drawMap = function (mapName, callback) { maps.prototype.drawMap = function (mapName, callback) {
core.clearMap('all'); core.clearMap('all');
core.removeGlobalAnimate(null, null, true); core.removeGlobalAnimate(null, null, true);
var drawBg = function(){ var drawBg = function(){
var groundId = core.floors[mapName].defaultGround || "ground";
var blockIcon = core.material.icons.terrains[groundId]; core.maps.drawBgFgMap(mapName, core.canvas.bg, "bg");
var blockImage = core.material.images.terrains; core.maps.drawBgFgMap(mapName, core.canvas.event2, "event2");
for (var x = 0; x < core.bigmap.width; x++) {
for (var y = 0; y < core.bigmap.height; y++) {
core.canvas.bg.drawImage(blockImage, 0, blockIcon * 32, 32, 32, x * 32, y * 32, 32, 32);
}
}
var images = []; var images = [];
if (core.isset(core.floors[mapName].images)) { if (core.isset(core.floors[mapName].images)) {

View File

@ -1826,15 +1826,9 @@ ui.prototype.drawThumbnail = function(floorId, canvas, blocks, x, y, size, cente
tempCanvas.canvas.height = tempHeight; tempCanvas.canvas.height = tempHeight;
tempCanvas.clearRect(0, 0, tempWidth, tempHeight); tempCanvas.clearRect(0, 0, tempWidth, tempHeight);
var groundId = core.floors[floorId].defaultGround || "ground"; // background map
var blockIcon = core.material.icons.terrains[groundId]; core.maps.drawBgFgMap(floorId, tempCanvas, "bg");
var blockImage = core.material.images.terrains;
// background
for (var j=0;j<mh;j++) {
for (var i=0;i<mw;i++) {
tempCanvas.drawImage(blockImage, 0, blockIcon * 32, 32, 32, i * 32, j * 32, 32, 32);
}
}
// background image // background image
var images = []; var images = [];
if (core.isset(core.floors[floorId].images)) { if (core.isset(core.floors[floorId].images)) {
@ -1882,6 +1876,9 @@ ui.prototype.drawThumbnail = function(floorId, canvas, blocks, x, y, size, cente
var height = core.material.images.images[heroIcon].height/4; var height = core.material.images.images[heroIcon].height/4;
tempCanvas.drawImage(core.material.images.images[heroIcon], icon.stop * 32, icon.loc * height, 32, height, 32*heroLoc.x, 32*heroLoc.y+32-height, 32, height); tempCanvas.drawImage(core.material.images.images[heroIcon], icon.stop * 32, icon.loc * height, 32, height, 32*heroLoc.x, 32*heroLoc.y+32-height, 32, height);
} }
// foreground map
core.maps.drawBgFgMap(floorId, tempCanvas, "event2");
// draw fg // draw fg
images.forEach(function (t) { images.forEach(function (t) {
var dx=parseInt(t[0]), dy=parseInt(t[1]), p=t[2]; var dx=parseInt(t[0]), dy=parseInt(t[1]), p=t[2];

View File

@ -289,7 +289,7 @@ span#poison, span#weak, span#curse, span#pickaxe, span#bomb, span#fly {
} }
#route { #route {
z-index: 105; z-index: 95;
} }
#ui { #ui {