diff --git a/_server/editor.js b/_server/editor.js index b76134b0..536e0df5 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -252,92 +252,6 @@ editor.prototype.updateMap = function () { } //ctx.drawImage(editor.material.images[tileInfo.images], 0, tileInfo.y*32, 32, 32, x*32, y*32, 32, 32); } - /* - // autotile的相关处理 - var indexArrs = [ //16种组合的图块索引数组; // 将autotile分割成48块16*16的小块; 数组索引即对应各个小块 - // +----+----+----+----+----+----+ - [10, 9, 4, 3 ], //0 bin:0000 | 1 | 2 | 3 | 4 | 5 | 6 | - [10, 9, 4, 13], //1 bin:0001 +----+----+----+----+----+----+ - [10, 9, 18, 3 ], //2 bin:0010 | 7 | 8 | 9 | 10 | 11 | 12 | - [10, 9, 16, 15], //3 bin:0011 +----+----+----+----+----+----+ - [10, 43, 4, 3 ], //4 bin:0100 | 13 | 14 | 15 | 16 | 17 | 18 | - [10, 31, 4, 25], //5 bin:0101 +----+----+----+----+----+----+ - [10, 7, 2, 3 ], //6 bin:0110 | 19 | 20 | 21 | 22 | 23 | 24 | - [10, 31, 16, 5 ], //7 bin:0111 +----+----+----+----+----+----+ - [48, 9, 4, 3 ], //8 bin:1000 | 25 | 26 | 27 | 28 | 29 | 30 | - [ 8, 9, 4, 1 ], //9 bin:1001 +----+----+----+----+----+----+ - [36, 9, 30, 3 ], //10 bin:1010 | 31 | 32 | 33 | 34 | 35 | 36 | - [36, 9, 6, 15], //11 bin:1011 +----+----+----+----+----+----+ - [46, 45, 4, 3 ], //12 bin:1100 | 37 | 38 | 39 | 40 | 41 | 42 | - [46, 11, 4, 25], //13 bin:1101 +----+----+----+----+----+----+ - [12, 45, 30, 3 ], //14 bin:1110 | 43 | 44 | 45 | 46 | 47 | 48 | - [34, 33, 28, 27] //15 bin:1111 +----+----+----+----+----+----+ - ]; - var drawBlockByIndex = function(ctx, dx, dy, autotileImg, index){ //index为autotile的图块索引1-48 - var sx = 16*((index-1)%6), sy = 16*(~~((index-1)/6)); - ctx.drawImage(autotileImg, sx, sy, 16, 16, dx, dy, 16, 16); - } - var isAutotile = function(info){ - if(typeof(info)=='object' && hasOwnProp(info, 'images') && info.images=='autotile') return true; - return false; - } - var getAutotileAroundId = function(currId, x, y){ //与autotile当前idnum一致返回1,否则返回0 - if(x>=0 && y >=0 && x<13 && y<13 && isAutotile(editor.map[y][x]) && editor.map[y][x].idnum == currId) - return 1; - else if(x<0 || y<0 || x>12 || y>12) return 1; //边界外视为通用autotile,这样好看些 - else - return 0; - } - var checkAround = function(x, y){ // 得到周围四个32*32块(周围每块都包含当前块的1/4,不清楚的话画下图你就明白)的数组索引 - var currId = editor.map[y][x].idnum; - var pointBlock = []; - for(var i=0; i<4; i++){ - var bsum = 0; - var offsetx = i%2, offsety = ~~(i/2); - for(var j=0; j<4; j++){ - var mx = j%2, my = ~~(j/2); - var b = getAutotileAroundId(currId, x+offsetx+mx-1, y+offsety+my-1); - bsum += b*(Math.pow(2, 3-j)); - } - pointBlock.push(bsum); - } - return pointBlock; - } - var addIndexToAutotileInfo = function(x, y){ - var indexArr = []; - var pointBlocks = checkAround(x, y); - for(var i=0; i<4; i++){ - var arr = indexArrs[pointBlocks[i]] - indexArr.push(arr[3-i]); - } - editor.map[y][x].blockIndex = indexArr; - } - var drawAutotile = function(ctx, x, y, info){ // 绘制一个autotile - ctx.clearRect(x*32, y*32, 32, 32); - //修正四个边角的固定搭配 - if(info.blockIndex[0] == 13){ - if(info.blockIndex[1] == 16) info.blockIndex[1] = 14; - if(info.blockIndex[2] == 31) info.blockIndex[2] = 19; - } - if(info.blockIndex[1] == 18){ - if(info.blockIndex[0] == 15) info.blockIndex[0] = 17; - if(info.blockIndex[3] == 36) info.blockIndex[3] = 24; - } - if(info.blockIndex[2] == 43){ - if(info.blockIndex[0] == 25) info.blockIndex[0] = 37; - if(info.blockIndex[3] == 46) info.blockIndex[3] = 44; - } - if(info.blockIndex[3] == 48){ - if(info.blockIndex[1] == 30) info.blockIndex[1] = 42; - if(info.blockIndex[2] == 45) info.blockIndex[2] = 47; - } - for(var i=0; i<4; i++){ - var index = info.blockIndex[i]; - var dx = x*32 + 16*(i%2), dy = y*32 + 16*(~~(i/2)); - drawBlockByIndex(ctx, dx, dy, editor.material.images[info.images][info.id], index); - } - } - */ // 绘制地图 start var eventCtx = document.getElementById('event').getContext("2d"); for (var y = 0; y < 13; y++) diff --git a/docs/personalization.md b/docs/personalization.md index caa80a16..47a807b6 100644 --- a/docs/personalization.md +++ b/docs/personalization.md @@ -299,7 +299,7 @@ enemys.prototype.calDamage = function (monster, hero_hp, hero_atk, hero_def, her // 检查领域、夹击、阻击事件 control.prototype.checkBlock = function () { var x=core.getHeroLoc('x'), y=core.getHeroLoc('y'); - var damage = core.status.checkBlock.damage[13*x+y]; + var damage = core.status.checkBlock.damage[x+core.bigmap.width*y]; if (damage>0) { if (core.hasFlag("shield5")) damage = 0; // 如果存在神圣盾,则将伤害变成0 core.status.hero.hp -= damage; diff --git a/libs/actions.js b/libs/actions.js index 4141b107..d7303b2e 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -429,7 +429,7 @@ actions.prototype.ondown = function (x ,y) { } core.status.downTime = new Date(); - core.clearMap('ui', 0, 0, 416,416); + core.clearMap('ui'); var pos={'x':x,'y':y} core.status.stepPostfix=[]; core.status.stepPostfix.push(pos); @@ -553,9 +553,7 @@ actions.prototype.onclick = function (x, y, stepPostfix) { // 寻路 if (!core.status.lockControl) { - var dx = ~~(core.maps.currentOffsetPos.x/32); - var dy = ~~(core.maps.currentOffsetPos.y/32); - core.setAutomaticRoute(x+dx, y+dy, stepPostfix); + core.setAutomaticRoute(x+parseInt(core.bigmap.offsetX/32), y+parseInt(core.bigmap.offsetY/32), stepPostfix); return; } @@ -925,7 +923,7 @@ actions.prototype.keyUpBook = function (keycode) { ////// 怪物手册属性显示界面时的点击操作 ////// actions.prototype.clickBookDetail = function () { - core.clearMap('data', 0, 0, 416, 416); + core.clearMap('data'); core.status.event.id = 'book'; } @@ -987,7 +985,7 @@ actions.prototype.clickViewMaps = function (x,y) { core.ui.drawMaps(nextId); } else { - core.clearMap('data', 0, 0, 416, 416); + core.clearMap('data'); core.setOpacity('data', 1); core.ui.closePanel(); } @@ -1007,7 +1005,7 @@ actions.prototype.keyDownViewMaps = function (keycode) { ////// 查看地图界面时,放开某个键的操作 ////// actions.prototype.keyUpViewMaps = function (keycode) { if (keycode==27 || keycode==13 || keycode==32 || keycode==67) { - core.clearMap('data', 0, 0, 416, 416); + core.clearMap('data'); core.setOpacity('data', 1); core.ui.closePanel(); } diff --git a/libs/control.js b/libs/control.js index 12fa6d7f..c65ac8c1 100644 --- a/libs/control.js +++ b/libs/control.js @@ -104,7 +104,7 @@ control.prototype.setRequestAnimationFrame = function () { if (core.isPlaying() && timestamp-core.animateFrame.weather.time>30) { if (core.animateFrame.weather.type == 'rain' && core.animateFrame.weather.level > 0) { - core.clearMap('weather', 0, 0, 416, 416); + core.clearMap('weather'); core.canvas.weather.strokeStyle = 'rgba(174,194,224,0.8)'; core.canvas.weather.lineWidth = 1; @@ -130,7 +130,7 @@ control.prototype.setRequestAnimationFrame = function () { } else if (core.animateFrame.weather.type == 'snow' && core.animateFrame.weather.level > 0) { - core.clearMap('weather', 0, 0, 416, 416); + core.clearMap('weather'); core.canvas.weather.fillStyle = "rgba(255, 255, 255, 0.8)"; core.canvas.weather.beginPath(); @@ -378,7 +378,7 @@ control.prototype.clearContinueAutomaticRoute = function () { control.prototype.moveDirectly = function (destX, destY) { var ignoreSteps = core.canMoveDirectly(destX, destY); if (ignoreSteps>=0) { - core.clearMap('hero', 0, 0, 416, 416); + core.clearMap('hero'); var lastDirection = core.status.route[core.status.route.length-1]; if (['left', 'right', 'up', 'down'].indexOf(lastDirection)>=0) core.setHeroLoc('direction', lastDirection); @@ -398,7 +398,7 @@ control.prototype.tryMoveDirectly = function (destX, destY) { if (Math.abs(core.getHeroLoc('x')-destX)+Math.abs(core.getHeroLoc('y')-destY)<=1) return false; var testMove = function (dx, dy, dir) { - if (dx<0 || dx>12 || dy<0 || dy>12) return false; + if (dx<0 || dx>=core.bigmap.width|| dy<0 || dy>core.bigmap.height) return false; if (core.control.moveDirectly(dx, dy)) { if (core.isset(dir)) core.moveHero(dir, function() {}); return true; @@ -542,9 +542,9 @@ control.prototype.setAutomaticRoute = function (destX, destY, stepPostfix) { ////// 自动寻路算法,找寻最优路径 ////// control.prototype.automaticRoute = function (destX, destY) { - var fw = core.floors[core.status.floorId].tileWidth; - var fh = core.floors[core.status.floorId].tileHeight - var tsize = fw * fw; + var fw = core.bigmap.width; + var fh = core.bigmap.height; + var total = fw * fh; var startX = core.getHeroLoc('x'); var startY = core.getHeroLoc('y'); var scan = { @@ -559,17 +559,17 @@ control.prototype.automaticRoute = function (destX, destY) { var ans = [] if (destX == startX && destY == startY) return false; - queue.push(fw * startX + startY); + queue.push(startX + fw * startY); queue.push(-1); - route[fw * startX + startY] = ''; + route[startX + fw * startY] = ''; while (queue.length != 1) { var f = queue.shift(); if (f===-1) {nowDeep+=1;queue.push(-1);continue;} - var deep = ~~(f/tsize); + var deep = parseInt(f/total); if (deep!==nowDeep) {queue.push(f);continue;} - f=f%tsize; - var nowX = parseInt(f / fw), nowY = f % fw; + f=f%total; + var nowX = parseInt(f % fw), nowY = parseInt(f / fw); var nowIsArrow = false, nowId, nowBlock = core.getBlock(nowX,nowY); for (var direction in scan) { if (!core.canMoveHero(nowX, nowY, direction)) @@ -580,7 +580,7 @@ control.prototype.automaticRoute = function (destX, destY) { if (nx<0 || nx>=fw || ny<0 || ny>=fh) continue; - var nid = fw * nx + ny; + var nid = nx + fw * ny; if (core.isset(route[nid])) continue; @@ -609,18 +609,18 @@ control.prototype.automaticRoute = function (destX, destY) { continue; route[nid] = direction; - queue.push(tsize*(nowDeep+deepAdd)+nid); + queue.push(total*(nowDeep+deepAdd)+nid); } - if (core.isset(route[fw * destX + destY])) break; + if (core.isset(route[destX + fw * destY])) break; } - if (!core.isset(route[fw * destX + destY])) { + if (!core.isset(route[destX + fw * destY])) { return false; } var nowX = destX, nowY = destY; while (nowX != startX || nowY != startY) { - var dir = route[fw * nowX + nowY]; + var dir = route[nowX + fw * nowY]; ans.push({'direction': dir, 'x': nowX, 'y': nowY}); nowX -= scan[dir].x; nowY -= scan[dir].y; @@ -672,7 +672,7 @@ control.prototype.setHeroMoveInterval = function (direction, x, y, callback) { core.setHeroLoc('y', y+scan[direction].y, true); core.control.updateFollowers(); core.moveOneStep(); - core.clearMap('hero', 0, 0, 416, 416); + core.clearMap('hero'); core.drawHero(direction); clearInterval(core.interval.heroMoveInterval); core.status.heroMoving = 0; @@ -786,7 +786,7 @@ control.prototype.moveHero = function (direction, callback) { }; direction = core.getHeroLoc('direction'); var nx = core.getHeroLoc('x') + scan[direction].x, ny=core.getHeroLoc('y') + scan[direction].y; - if (nx<0 || nx>12 || ny<0 || ny>12) return; + if (nx<0 || nx>=core.bigmap.width || ny<0 || ny>=core.bigmap.height) return; core.status.heroMoving=-1; core.eventMoveHero([direction], 100, function () { @@ -817,7 +817,7 @@ control.prototype.eventMoveHero = function(steps, time, callback) { time = time || 100; - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 1.0); // 要运行的轨迹:将steps展开 @@ -884,7 +884,7 @@ control.prototype.jumpHero = function (ex, ey, time, callback) { if (!core.isset(ey)) ey=sy; time = time || 500; - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 1.0); core.status.replay.animate=true; @@ -991,9 +991,11 @@ control.prototype.setGameCanvasTranslate = function(canvas,x,y){ c.style.MozTransform='translate('+x+'px,'+y+'px)'; }; -////// 更新视野范围 +////// 更新视野范围 ////// control.prototype.updateViewport = function() { - core.maps.activeCanvas.forEach(function(cn){ core.control.setGameCanvasTranslate(cn,-core.maps.currentOffsetPos.x,-core.maps.currentOffsetPos.y);}); + core.bigmap.canvas.forEach(function(cn){ + core.control.setGameCanvasTranslate(cn,-core.bigmap.offsetX,-core.bigmap.offsetY); + }); } ////// 绘制勇士 ////// @@ -1015,12 +1017,13 @@ control.prototype.drawHero = function (direction, x, y, status, offset) { var offsetX = way.x*offset; var offsetY = way.y*offset; var dx=offsetX==0?0:offsetX/Math.abs(offsetX), dy=offsetY==0?0:offsetY/Math.abs(offsetY); - core.maps.currentOffsetPos.x = ((x - 6) * 32 + offsetX).clamp(0,416); - core.maps.currentOffsetPos.y = ((y - 6) * 32 + offsetY).clamp(0,416); + + core.bigmap.offsetX = core.clamp((x - 6) * 32 + offsetX, 0, 32*core.bigmap.width-416); + core.bigmap.offsetY = core.clamp((y - 6) * 32 + offsetY, 0, 32*core.bigmap.height-416); core.clearAutomaticRouteNode(x+dx, y+dy); - core.canvas.hero.clearRect(x * 32 - core.maps.currentOffsetPos.x - 32, y * 32 - core.maps.currentOffsetPos.y - 32, 96, 96); + core.canvas.hero.clearRect(x * 32 - core.bigmap.offsetX - 32, y * 32 - core.bigmap.offsetY - 32, 96, 96); var heroIconArr = core.material.icons.hero; var drawObjs = []; @@ -1029,8 +1032,8 @@ control.prototype.drawHero = function (direction, x, y, status, offset) { "img": core.material.images.hero, "height": core.material.icons.hero.height, "heroIcon": heroIconArr[direction], - "posx": x * 32 - core.maps.currentOffsetPos.x + offsetX, - "posy": y * 32 - core.maps.currentOffsetPos.y + offsetY, + "posx": x * 32 - core.bigmap.offsetX + offsetX, + "posy": y * 32 - core.bigmap.offsetY + offsetY, "status": status, "index": 0, }); @@ -1045,8 +1048,8 @@ control.prototype.drawHero = function (direction, x, y, status, offset) { "img": core.material.images.images[t.img], "height": core.material.images.images[t.img].height/4, "heroIcon": heroIconArr[t.direction], - "posx": 32*t.x - core.maps.currentOffsetPos.x + (t.stop?0:scan[t.direction].x*offset), - "posy": 32*t.y - core.maps.currentOffsetPos.y + (t.stop?0:scan[t.direction].y*offset), + "posx": 32*t.x - core.bigmap.offsetX + (t.stop?0:scan[t.direction].x*offset), + "posy": 32*t.y - core.bigmap.offsetY + (t.stop?0:scan[t.direction].y*offset), "status": t.stop?"stop":status, "index": index++ }); @@ -1172,27 +1175,27 @@ control.prototype.updateCheckBlock = function() { if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.cls.indexOf('enemy')==0) { var id = block.event.id, enemy = core.material.enemys[id]; if (core.isset(enemy)) { - core.status.checkBlock.map[13*block.x+block.y]=id; + core.status.checkBlock.map[block.x+core.bigmap.width*block.y]=id; } } // 血网 if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.id=='lavaNet' && block.event.trigger=='passNet' && !core.hasItem("shoes")) { - core.status.checkBlock.map[13*block.x+block.y]="lavaNet"; + core.status.checkBlock.map[block.x+core.bigmap.width*block.y]="lavaNet"; } } // Step2: 更新领域、阻击伤害 core.status.checkBlock.damage = []; // 记录(x,y)点的伤害 - for (var x=0;x<13*13;x++) core.status.checkBlock.damage[x]=0; + for (var x=0;x12 || ny<0 || ny>12) continue; + if (nx<0 || nx>=core.bigmap.width || ny<0 || ny>=core.bigmap.height) continue; if (!zoneSquare && Math.abs(dx)+Math.abs(dy)>range) continue; - core.status.checkBlock.damage[13*nx+ny]+=enemy.value; + core.status.checkBlock.damage[nx+ny*core.bigmap.width]+=enemy.value; } } } @@ -1218,8 +1221,8 @@ control.prototype.updateCheckBlock = function() { for (var dy=-1;dy<=1;dy++) { if (dx==0 && dy==0) continue; var nx=x+dx, ny=y+dy; - if (nx<0 || nx>12 || ny<0 || ny>12 || Math.abs(dx)+Math.abs(dy)>1) continue; - core.status.checkBlock.damage[13*nx+ny]+=enemy.value; + if (nx<0 || nx>=core.bigmap.width || ny<0 || ny>=core.bigmap.height || Math.abs(dx)+Math.abs(dy)>1) continue; + core.status.checkBlock.damage[nx+ny*core.bigmap.width]+=enemy.value; } } } @@ -1230,12 +1233,12 @@ control.prototype.updateCheckBlock = function() { // Step3: 更新夹击点坐标,并将夹击伤害加入到damage中 core.status.checkBlock.betweenAttack = []; // 记录(x,y)点是否有夹击 - for (var x=0;x<13;x++) { - for (var y=0;y<13;y++) { + for (var x=0;x0 && x<12) { - var id1=core.status.checkBlock.map[13*(x-1)+y], - id2=core.status.checkBlock.map[13*(x+1)+y]; + if (x>0 && x0 && y<12) { - var id1=core.status.checkBlock.map[13*x+y-1], - id2=core.status.checkBlock.map[13*x+y+1]; + if (y>0 && y1) - core.status.checkBlock.damage[13*x+y] += Math.floor((leftHp+(core.flags.betweenAttackCeil?0:1))/2); + core.status.checkBlock.damage[x+core.bigmap.width*y] += Math.floor((leftHp+(core.flags.betweenAttackCeil?0:1))/2); } } } @@ -1267,7 +1270,7 @@ control.prototype.updateCheckBlock = function() { ////// 检查并执行领域、夹击、阻击事件 ////// control.prototype.checkBlock = function () { var x=core.getHeroLoc('x'), y=core.getHeroLoc('y'); - var damage = core.status.checkBlock.damage[13*x+y]; + var damage = core.status.checkBlock.damage[x+core.bigmap.width*y]; if (damage>0) { core.status.hero.hp -= damage; @@ -1281,8 +1284,8 @@ control.prototype.checkBlock = function () { } for (var direction in scan) { var nx = x+scan[direction].x, ny=y+scan[direction].y; - if (nx<0 || nx>12 || ny<0 || ny>12) continue; - var id=core.status.checkBlock.map[13*nx+ny]; + if (nx<0 || nx>=core.bigmap.width || ny<0 || ny>=core.bigmap.height) continue; + var id=core.status.checkBlock.map[nx+core.bigmap.width*ny]; if (core.isset(id)) { var enemy = core.material.enemys[id]; if (core.isset(enemy) && core.enemys.hasSpecial(enemy.special, 18)) { @@ -1291,10 +1294,10 @@ control.prototype.checkBlock = function () { } } - if (core.status.checkBlock.betweenAttack[13*x+y] && damage>0) { + if (core.status.checkBlock.betweenAttack[x+core.bigmap.width*y] && damage>0) { core.drawTip('受到夹击,生命变成一半'); } - else if (core.status.checkBlock.map[13*x+y]=='lavaNet') { + else if (core.status.checkBlock.map[x+core.bigmap.width*y]=='lavaNet') { core.drawTip('受到血网伤害'+damage+'点'); } // 阻击 @@ -1321,7 +1324,7 @@ control.prototype.checkBlock = function () { var x=t.x, y=t.y, direction = t.direction; var nx = x+scan[direction].x, ny=y+scan[direction].y; - return nx>=0 && nx<=12 && ny>=0 && ny<=12 && core.getBlock(nx, ny, core.status.floorId, false)==null; + return nx>=0 && nx=0 && ny0) @@ -1461,7 +1464,7 @@ control.prototype.setWeather = function (type, level) { // 非雨雪 if (type!='rain' && type!='snow') { - core.clearMap('weather', 0, 0, 416, 416) + core.clearMap('weather') core.animateFrame.weather.type = null; core.animateFrame.weather.level = 0; core.animateFrame.weather.nodes = []; @@ -1480,7 +1483,7 @@ control.prototype.setWeather = function (type, level) { if (level<1) level=1; if (level>10) level=10; level *= 20; - core.clearMap('weather', 0, 0, 416, 416) + core.clearMap('weather') core.animateFrame.weather.type = type; core.animateFrame.weather.level = level; @@ -1563,7 +1566,7 @@ control.prototype.updateFg = function () { if (!core.isset(core.status.thisMap) || !core.isset(core.status.thisMap.blocks)) return; // 更新显伤 var mapBlocks = core.status.thisMap.blocks; - core.clearMap('fg', 0, 0, 416, 416); + core.clearMap('fg'); // 没有怪物手册 if (!core.hasItem('book')) return; core.setFont('fg', "bold 11px Arial"); @@ -1637,9 +1640,9 @@ control.prototype.updateFg = function () { // 如果是领域&夹击 if (core.flags.displayExtraDamage) { core.canvas.fg.textAlign = 'center'; - for (var x=0;x<13;x++) { - for (var y=0;y<13;y++) { - var damage = core.status.checkBlock.damage[13*x+y]; + for (var x=0;x0) { damage = core.formatBigNumber(damage); core.setFillStyle('fg', '#000000'); @@ -2814,16 +2817,6 @@ control.prototype.resize = function(clientWidth, clientHeight) { left: (clientWidth-gameGroupWidth)/2 + unit, } }, - { - className: 'gameCanvas', - rules:{ - // width: canvasWidth + unit, - // height: canvasWidth + unit, - top: canvasTop + unit, - left: 0, - border: '3px '+borderColor+' solid', - } - }, { id: 'gif', rules: { @@ -2857,7 +2850,7 @@ control.prototype.resize = function(clientWidth, clientHeight) { width: (canvasWidth - SPACE*2) + unit, height:(canvasWidth - SPACE*2) + unit, top: canvasTop + unit, - right: SPACE + unit, + right: 0, border: '3px #fff solid' } }, diff --git a/libs/core.js b/libs/core.js index 779ba8a7..6f569e0b 100644 --- a/libs/core.js +++ b/libs/core.js @@ -76,6 +76,13 @@ function core() { styles: [], scale: 1.0, } + this.bigmap = { + canvas: ["bg", "event", "event2", "fg"], + offsetX: 0, // in pixel + offsetY: 0, + width: 13, // map width and height + height: 13 + } this.initStatus = { 'played': false, 'gameOver': false, @@ -1146,6 +1153,10 @@ core.prototype.subarray = function (a, b) { return core.utils.subarray(a, b); } +core.prototype.clamp = function (x, a, b) { + return core.utils.clamp(x, a, b); +} + ////// Base64加密 ////// core.prototype.encodeBase64 = function (str) { return core.utils.encodeBase64(str); diff --git a/libs/events.js b/libs/events.js index cda595ce..215a6a51 100644 --- a/libs/events.js +++ b/libs/events.js @@ -131,9 +131,9 @@ events.prototype.lose = function (reason) { events.prototype.gameOver = function (ending, fromReplay, norank) { // 清空图片和天气 - core.clearMap('animate', 0, 0, 416, 416); + core.clearMap('animate'); core.dom.gif2.innerHTML = ""; - core.clearMap('weather', 0, 0, 416, 416) + core.clearMap('weather') core.animateFrame.weather.type = null; core.animateFrame.weather.level = 0; core.animateFrame.weather.nodes = []; @@ -281,7 +281,7 @@ events.prototype.doAction = function() { core.status.boxAnimateObjs = []; clearInterval(core.status.event.interval); - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 1.0); // 事件处理完毕 @@ -513,7 +513,7 @@ events.prototype.doAction = function() { break; } case "changePos": // 直接更换勇士位置,不切换楼层 - core.clearMap('hero', 0, 0, 416, 416); + core.clearMap('hero'); if (core.isset(data.loc)) { core.setHeroLoc('x', core.calValue(data.loc[0])); core.setHeroLoc('y', core.calValue(data.loc[1])); @@ -527,7 +527,7 @@ events.prototype.doAction = function() { core.canvas.animate.drawImage(core.material.images.images[data.name], core.calValue(data.loc[0]), core.calValue(data.loc[1])); } - else core.clearMap('animate', 0, 0, 416, 416); + else core.clearMap('animate'); this.doAction(); break; case "animateImage": // 淡入淡出图片 @@ -1186,14 +1186,14 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback }) } // 重置画布尺寸 - core.maps.resizeCanvas(floorId); + core.maps.resizeMap(floorId); // 画地图 core.drawMap(floorId, function () { if (core.isset(heroLoc.direction)) core.setHeroLoc('direction', heroLoc.direction); core.setHeroLoc('x', heroLoc.x); core.setHeroLoc('y', heroLoc.y); - core.clearMap('hero', 0, 0, 416, 416); + core.clearMap('hero'); core.drawHero(); var changed = function () { @@ -1247,7 +1247,7 @@ events.prototype.animateImage = function (type, image, loc, time, callback) { core.setOpacity('data', opacityVal); if (opacityVal >=1 || opacityVal<=0) { clearInterval(animate); - core.clearMap('data', 0, 0, 416, 416); + core.clearMap('data'); core.setOpacity('data', 1); core.status.replay.animate=false; if (core.isset(callback)) callback(); @@ -1267,7 +1267,7 @@ events.prototype.moveImage = function (image, from, to, time, callback) { toX = core.calValue(to[0]), toY = core.calValue(to[1]); var step = 0; var drawImage = function () { - core.clearMap('data', 0, 0, 416, 416); + core.clearMap('data'); var nowX = parseInt(fromX + (toX-fromX)*step/64); var nowY = parseInt(fromY + (toY-fromY)*step/64); core.canvas.data.drawImage(image, nowX, nowY); @@ -1279,7 +1279,7 @@ events.prototype.moveImage = function (image, from, to, time, callback) { drawImage(); if (step>=64) { clearInterval(animate); - core.clearMap('data', 0, 0, 416, 416); + core.clearMap('data'); core.status.replay.animate=false; if (core.isset(callback)) callback(); } @@ -1610,7 +1610,7 @@ events.prototype.pushBox = function (data) { var direction = core.getHeroLoc('direction'), nx=data.x+scan[direction].x, ny=data.y+scan[direction].y; - if (nx<0||nx>12||ny<0||ny>12) return; + if (nx<0||nx>=core.bigmap.width||ny<0||ny>=core.bigmap.height) return; var block = core.getBlock(nx, ny, null, false); if (block!=null && !(core.isset(block.block.event) && block.block.event.id=='flower')) diff --git a/libs/maps.js b/libs/maps.js index e004af85..3f0f83bd 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -18,11 +18,11 @@ maps.prototype.loadFloor = function (floorId, map) { if (!core.isset(map)) map=floor.map; var mapIntoBlocks = function(map,maps,floor){ var blocks = []; - var mw = core.floors[floorId].tileWidth; - var mh = core.floors[floorId].tileHeight; + var mw = core.floors[floorId].width || 13; + var mh = core.floors[floorId].height || 13; for (var i = 0; i < mh; i++) { for (var j = 0; j < mw; j++) { - var block = maps.initBlock(j, i, map[i][j]); + var block = maps.initBlock(j, i, (map[i]||[])[j]||0); maps.addInfo(block); maps.addEvent(block,j,i,floor.events[j+","+i]) maps.addChangeFloor(block,j,i,floor.changeFloor[j+","+i]); @@ -160,8 +160,8 @@ maps.prototype.save = function(maps, floorId) { } var thisFloor = maps[floorId]; - var mw = core.floors[floorId].tileWidth; - var mh = core.floors[floorId].tileHeight; + var mw = core.floors[floorId].width || 13; + var mh = core.floors[floorId].height || 13; var blocks = []; for (var x=0;x0) + ||core.status.checkBlock.damage[fromX+core.bigmap.width*fromY]>0) return -1; // BFS var visited=[], queue=[]; - visited[13*fromX+fromY]=0; - queue.push(13*fromX+fromY); + visited[fromX+core.bigmap.width*fromY]=0; + queue.push(fromX+core.bigmap.width*fromY); var directions = [[-1,0],[1,0],[0,1],[0,-1]]; while (queue.length>0) { - var now=queue.shift(), nowX=parseInt(now/13), nowY=now%13; + var now=queue.shift(), nowX=parseInt(now%core.bigmap.width), nowY=parseInt(now/core.bigmap.width); for (var dir in directions) { var nx=nowX+directions[dir][0], ny=nowY+directions[dir][1]; - if (nx<0||nx>=13||ny<0||ny>=13||visited[13*nx+ny]||core.getBlock(nx,ny)!=null||core.status.checkBlock.damage[13*nx+ny]>0) continue; - visited[13*nx+ny]=visited[13*nowX+nowY]+1; - if (nx==destX&&ny==destY) return visited[13*nx+ny]; - queue.push(13*nx+ny); + if (nx<0||nx>=core.bigmap.width||ny<0||ny>=core.bigmap.height||visited[nx+core.bigmap.width*ny]||core.getBlock(nx,ny)!=null||core.status.checkBlock.damage[nx+core.bigmap.width*ny]>0) continue; + visited[nx+core.bigmap.width*ny]=visited[nowX+core.bigmap.width*nowY]+1; + if (nx==destX&&ny==destY) return visited[nx+core.bigmap.width*ny]; + queue.push(nx+core.bigmap.width*ny); } } return -1; @@ -337,17 +335,13 @@ maps.prototype.drawBlock = function (block, animate, dx, dy) { maps.prototype.drawMap = function (mapName, callback) { core.clearMap('all'); core.removeGlobalAnimate(null, null, true); - var mw = core.floors[mapName].tileWidth; - var mh = core.floors[mapName].tileHeight; var drawBg = function(){ var groundId = core.floors[mapName].defaultGround || "ground"; var blockIcon = core.material.icons.terrains[groundId]; var blockImage = core.material.images.terrains; - var dx = core.getHeroLoc('x'); - var dy = core.getHeroLoc('y'); - for (var x = 0; x < mw; x++) { - for (var y = 0; y < mh; y++) { + 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); } } @@ -395,7 +389,7 @@ maps.prototype.drawMap = function (mapName, callback) { } if (main.mode=='editor'){ main.editor.drawMapBg = function(){ - core.clearMap('bg', 0, 0, 416, 416); + core.clearMap('bg'); drawBg(); } } else { @@ -408,7 +402,7 @@ maps.prototype.drawMap = function (mapName, callback) { var mapData = core.status.maps[core.status.floorId]; var mapBlocks = mapData.blocks; - var mapArray = core.maps.getMapArray(mapBlocks,mw,mh); + var mapArray = core.maps.getMapArray(mapBlocks,core.bigmap.width,core.bigmap.height); for (var b = 0; b < mapBlocks.length; b++) { // 事件启用 var block = mapBlocks[b]; @@ -429,9 +423,9 @@ maps.prototype.drawMap = function (mapName, callback) { if (main.mode=='editor'){ main.editor.updateMap = function(){ core.removeGlobalAnimate(null, null, true); - core.clearMap('bg', 0, 0, 416, 416); - core.clearMap('event', 0, 0, 416, 416); - core.clearMap('event2', 0, 0, 416, 416); + core.clearMap('bg'); + core.clearMap('event'); + core.clearMap('event2'); drawBg(); drawEvent(); core.setGlobalAnimate(core.values.animateSpeed); @@ -473,7 +467,7 @@ maps.prototype.drawAutotile = function(ctx, mapArr, block, size, left, top){ ctx.drawImage(autotileImg, sx, sy, 16, 16, dx, dy, size/2, size/2); } var getAutotileAroundId = function(currId, x, y){ - if(x<0 || y<0 || x>12 || y>12) return 1; + if(x<0 || y<0 || x>=core.bigmap.width || y>=core.bigmap.height) return 1; else return mapArr[y][x]==currId ? 1:0; } var checkAround = function(x, y){ // 得到周围四个32*32块(周围每块都包含当前块的1/4,不清楚的话画下图你就明白)的数组索引 @@ -537,8 +531,7 @@ maps.prototype.noPassExists = function (x, y, floorId) { ////// 某个点是否在区域内且不可通行 ////// maps.prototype.noPass = function (x, y) { - var floor = core.floors[core.status.floorId]; - return x<0 || x>=floor.tileWidth || y<0 || y>=floor.tileHeight || this.noPassExists(x,y); + return x<0 || x>=core.bigmap.width || y<0 || y>=core.bigmap.height || this.noPassExists(x,y); } ////// 某个点是否存在NPC ////// @@ -601,7 +594,7 @@ maps.prototype.getBlockId = function (x, y, floorId, needEnable) { maps.prototype.moveBlock = function(x,y,steps,time,keep,callback) { time = time || 500; - core.clearMap('animate', 0, 0, 416, 416); + core.clearMap('animate'); var block = core.getBlock(x,y); if (block==null) {// 不存在 @@ -615,7 +608,7 @@ maps.prototype.moveBlock = function(x,y,steps,time,keep,callback) { // 需要删除该块 core.removeBlock(x,y); - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 1.0); block=block.block; @@ -675,7 +668,7 @@ maps.prototype.moveBlock = function(x,y,steps,time,keep,callback) { core.canvas.animate.drawImage(blockImage, animateCurrent * 32, blockIcon * height, 32, height, nowX, nowY-height+32, 32, height); if (opacityVal<=0) { clearInterval(animate); - core.clearMap('animate', 0, 0, 416, 416); + core.clearMap('animate'); core.setOpacity('animate', 1); // 不消失 if (keep) { @@ -706,7 +699,7 @@ maps.prototype.moveBlock = function(x,y,steps,time,keep,callback) { ////// 显示跳跃某块的动画,达到{"type":"jump"}的效果 ////// maps.prototype.jumpBlock = function(sx,sy,ex,ey,time,keep,callback) { time = time || 500; - core.clearMap('animate', 0, 0, 416, 416); + core.clearMap('animate'); var block = core.getBlock(sx,sy); if (block==null) { if (core.isset(callback)) callback(); @@ -718,7 +711,7 @@ maps.prototype.jumpBlock = function(sx,sy,ex,ey,time,keep,callback) { // 需要删除该块 core.removeBlock(sx,sy); - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 1.0); block=block.block; @@ -781,7 +774,7 @@ maps.prototype.jumpBlock = function(sx,sy,ex,ey,time,keep,callback) { core.canvas.animate.drawImage(blockImage, animateCurrent * 32, blockIcon * height, 32, height, drawX(), drawY()-height+32, 32, height); if (opacityVal<=0) { clearInterval(animate); - core.clearMap('animate', 0, 0, 416, 416); + core.clearMap('animate'); core.setOpacity('animate', 1); if (keep) { core.setBlock(id, ex, ey); @@ -799,7 +792,7 @@ maps.prototype.jumpBlock = function(sx,sy,ex,ey,time,keep,callback) { maps.prototype.animateBlock = function (loc,type,time,callback) { if (type!='hide') type='show'; - core.clearMap('animate', 0, 0, 416, 416); + core.clearMap('animate'); if (typeof loc[0] == 'number' && typeof loc[1] == 'number') loc = [loc]; @@ -840,7 +833,7 @@ maps.prototype.animateBlock = function (loc,type,time,callback) { core.setOpacity('animate', opacityVal); if (opacityVal >=1 || opacityVal<=0) { clearInterval(animate); - core.clearMap('animate', 0, 0, 416, 416); + core.clearMap('animate'); core.setOpacity('animate', 1); core.status.replay.animate=false; if (core.isset(callback)) callback(); @@ -927,7 +920,7 @@ maps.prototype.removeBlockByIds = function (floorId, ids) { maps.prototype.setBlock = function (number, x, y, floorId) { floorId = floorId || core.status.floorId; if (!core.isset(number) || !core.isset(x) || !core.isset(y)) return; - if (x<0 || x>12 || y<0 || y>12) return; + if (x<0 || x>=core.bigmap.width || y<0 || y>=core.bigmap.height) return; var originBlock=core.getBlock(x,y,floorId,false); var block = core.maps.initBlock(x,y,number); @@ -1021,7 +1014,7 @@ maps.prototype.drawAnimate = function (name, x, y, callback) { // 清空animate层 clearInterval(core.interval.animateInterval); - core.clearMap('animate', 0, 0, 416, 416); + core.clearMap('animate'); // 开始绘制 var animate = core.material.animates[name]; @@ -1033,7 +1026,7 @@ maps.prototype.drawAnimate = function (name, x, y, callback) { core.playSound(animate.se); var draw = function (index) { - core.clearMap('animate', 0, 0, 416, 416); + core.clearMap('animate'); var frame = animate.frames[index]; frame.forEach(function (t) { @@ -1046,7 +1039,7 @@ maps.prototype.drawAnimate = function (name, x, y, callback) { var cx = centerX+t.x, cy=centerY+t.y; if (!t.mirror && !t.angle) { - core.canvas.animate.drawImage(image, cx-realWidth/2 - core.maps.currentOffsetPos.x, cy-realHeight/2 - core.maps.currentOffsetPos.y, realWidth, realHeight); + core.canvas.animate.drawImage(image, cx-realWidth/2 - core.bigmap.offsetX, cy-realHeight/2 - core.bigmap.offsetY, realWidth, realHeight); } else { core.saveCanvas('animate'); @@ -1055,7 +1048,7 @@ maps.prototype.drawAnimate = function (name, x, y, callback) { core.canvas.animate.rotate(-t.angle*Math.PI/180); if (t.mirror) core.canvas.animate.scale(-1,1); - core.canvas.animate.drawImage(image, -realWidth/2 - core.maps.currentOffsetPos.x, -realHeight/2 - core.maps.currentOffsetPos.y, realWidth, realHeight); + core.canvas.animate.drawImage(image, -realWidth/2 - core.bigmap.offsetX, -realHeight/2 - core.bigmap.offsetY, realWidth, realHeight); core.loadCanvas('animate'); } }) @@ -1066,7 +1059,7 @@ maps.prototype.drawAnimate = function (name, x, y, callback) { core.interval.animateInterval = setInterval(function (t) { if (index == animate.frames.length) { clearInterval(core.interval.animateInterval); - core.clearMap('animate', 0, 0, 416, 416); + core.clearMap('animate'); core.setAlpha('animate', 1); if (core.isset(callback)) callback(); return; diff --git a/libs/ui.js b/libs/ui.js index 45e4a2c8..0a4fd41d 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -18,12 +18,12 @@ ui.prototype.init = function () { ui.prototype.clearMap = function (map, x, y, width, height) { if (map == 'all') { for (var m in core.canvas) { - core.canvas[m].clearRect(0, 0, 416, 416); + core.canvas[m].clearRect(0, 0, core.bigmap.width*32, core.bigmap.height*32); } core.dom.gif.innerHTML = ""; } else { - core.canvas[map].clearRect(x||0, y||0, width||416, height||416); + core.canvas[map].clearRect(x||0, y||0, width||core.bigmap.width*32, height||core.bigmap.height*32); } } @@ -149,7 +149,7 @@ ui.prototype.setFillStyle = function (map, style) { ui.prototype.closePanel = function () { core.status.boxAnimateObjs = []; clearInterval(core.status.event.interval); - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 1.0); core.unLockControl(); core.status.event.data = null; @@ -380,7 +380,7 @@ ui.prototype.drawTextBox = function(content) { var background = core.canvas.ui.createPattern(core.material.ground, "repeat"); core.status.boxAnimateObjs = []; - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); // var contents = content.split('\n'); // var contents = core.splitLines('ui', content, ); @@ -541,7 +541,7 @@ ui.prototype.drawChoices = function(content, choices) { var background = core.canvas.ui.createPattern(core.material.ground, "repeat"); - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 1); core.setFillStyle('ui', background); @@ -728,7 +728,7 @@ ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) { if (core.status.event.selection<0) core.status.event.selection=0; var background = core.canvas.ui.createPattern(core.material.ground, "repeat"); - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 1); core.setFillStyle('ui', background); core.setFont('ui', "bold 19px Verdana"); @@ -872,7 +872,7 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) { var background = core.canvas.ui.createPattern(core.material.ground, "repeat"); - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); var left=10, right=416-2*left; @@ -891,7 +891,7 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) { core.fillRect('ui', left, top, right, bottom, '#000000'); core.setAlpha('ui', 1); core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2); - core.clearMap('data',0,0,416,416); + core.clearMap('data'); clearInterval(core.interval.tipAnimate); core.setAlpha('data', 1); @@ -1099,9 +1099,9 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) { // 战斗结束 clearInterval(battleInterval); core.status.boxAnimateObjs = []; - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 1.0); - core.clearMap('data', 0, 0, 416, 416); + core.clearMap('data'); if (core.status.event.id=='battle') { core.unLockControl(); core.status.event.id=null; @@ -1121,7 +1121,7 @@ ui.prototype.drawWaiting = function(text) { core.status.event.id = 'waiting'; var background = core.canvas.ui.createPattern(core.material.ground, "repeat"); - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 1); core.setFillStyle('ui', background); @@ -1219,7 +1219,7 @@ ui.prototype.drawCursor = function () { core.status.event.id = 'cursor'; core.lockControl(); - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 1); var width = 4; @@ -1235,10 +1235,10 @@ ui.prototype.drawBook = function (index) { var background = core.canvas.ui.createPattern(core.material.ground, "repeat"); clearInterval(core.interval.tipAnimate); - core.clearMap('data', 0, 0, 416, 416); + core.clearMap('data'); core.setOpacity('data', 1); - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 1); core.setFillStyle('ui', background); core.fillRect('ui', 0, 0, 416, 416); @@ -1400,7 +1400,7 @@ ui.prototype.drawBookDetail = function (index) { core.status.event.id = 'book-detail'; clearInterval(core.interval.tipAnimate); - core.clearMap('data', 0, 0, 416, 416); + core.clearMap('data'); core.setOpacity('data', 1); var left=10, right=416-2*left; @@ -1453,7 +1453,7 @@ ui.prototype.drawFly = function(page) { var floorId = core.status.hero.flyRange[page]; var title = core.status.maps[floorId].title; - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 0.85); core.fillRect('ui', 0, 0, 416, 416, '#000000'); core.setAlpha('ui', 1); @@ -1490,11 +1490,11 @@ ui.prototype.drawMaps = function (index) { clearTimeout(core.interval.tipAnimate); - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 1); this.drawThumbnail(floorId, 'ui', core.status.maps[floorId].blocks, 0, 0, 416); - core.clearMap('data', 0, 0, 416, 416); + core.clearMap('data'); core.setOpacity('data', 0.2); core.canvas.data.textAlign = 'left'; core.setFont('data', '16px Arial'); @@ -1538,7 +1538,7 @@ ui.prototype.drawToolbox = function(index) { core.status.event.data=selectId; - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 0.85); core.fillRect('ui', 0, 0, 416, 416, '#000000'); core.setAlpha('ui', 1); @@ -1660,7 +1660,7 @@ ui.prototype.drawSLPanel = function(index) { core.status.event.data=index; - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); core.setAlpha('ui', 0.85); core.fillRect('ui', 0, 0, 416, 416, '#000000'); core.setAlpha('ui', 1); @@ -1715,8 +1715,8 @@ ui.prototype.drawThumbnail = function(floorId, canvas, blocks, x, y, size, heroL var blockIcon = core.material.icons.terrains[groundId]; var blockImage = core.material.images.terrains; var persize = size/13; - var mw = core.floors[floorId].tileWidth; - var mh = core.floors[floorId].tileHeight; + var mw = core.floors[floorId].width || 13; + var mh = core.floors[floorId].height || 13; for (var i=0;i<13;i++) { for (var j=0;j<13;j++) { core.canvas[canvas].drawImage(blockImage, 0, blockIcon * 32, 32, 32, x + i * persize, y + j * persize, persize, persize); @@ -1792,7 +1792,7 @@ ui.prototype.drawKeyBoard = function () { core.lockControl(); core.status.event.id = 'keyBoard'; - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); var left = 16, top = 48, right = 416 - 2 * left, bottom = 416 - 2 * top; var background = core.canvas.ui.createPattern(core.material.ground, "repeat"); diff --git a/libs/utils.js b/libs/utils.js index 13a9f677..2f2a981b 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -352,6 +352,11 @@ utils.prototype.subarray = function (a, b) { return na; } +utils.prototype.clamp = function (x, a, b) { + var min=Math.min(a, b), max=Math.max(a, b); + return Math.min(Math.max(x, min), max); +} + ////// Base64加密 ////// utils.prototype.encodeBase64 = function (str) { return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) { diff --git a/project/enemys.js b/project/enemys.js index bf6d890b..dc389a6d 100644 --- a/project/enemys.js +++ b/project/enemys.js @@ -1,7 +1,7 @@ enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 = { 'greenSlime': {'name': '绿头怪', 'hp': 100, 'atk': 120, 'def': 0, 'money': 1, 'experience': 1, 'point': 0, 'special': [1,5,7,8]}, - 'redSlime': {'name': '红头怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'point': 0, 'special': 0}, + 'redSlime': {'name': '红头怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'point': 0, 'special': [16,18], 'value': 10}, 'blackSlime': {'name': '青头怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'point': 0, 'special': 0}, 'slimelord': {'name': '怪王', 'hp': 100, 'atk': 120, 'def': 0, 'money': 10, 'experience': 0, 'point': 0, 'special': [1,9]}, 'bat': {'name': '小蝙蝠', 'hp': 100, 'atk': 120, 'def': 0, 'money': 2, 'experience': 0, 'point': 0, 'special': 1}, diff --git a/project/floors/MT0.js b/project/floors/MT0.js index 7e83fff7..020496b8 100644 --- a/project/floors/MT0.js +++ b/project/floors/MT0.js @@ -18,7 +18,7 @@ main.floors.MT0= [ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0], - [ 0, 0, 0, 0, 1, 1, 0, 0, 1, 0,202,202, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0,202,202, 0], + [ 0, 0, 0, 0, 1, 1, 45, 0, 1, 0,202,202, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0,202,202, 0], [ 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [ 0, 0, 0, 0, 0,202, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,202, 0, 0, 0, 0, 0, 0, 0], @@ -37,8 +37,8 @@ main.floors.MT0= [ 0, 0, 0, 0, 0,202, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,202, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ], -"tileWidth":26, -"tileHeight":26, +"width":26, +"height":26, "firstArrive": [], "events": {}, "changeFloor": {}, diff --git a/project/functions.js b/project/functions.js index 9bd9eda5..0ed6ad5e 100644 --- a/project/functions.js +++ b/project/functions.js @@ -453,7 +453,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.lockControl(); core.status.event.id = 'about'; - core.clearMap('ui', 0, 0, 416, 416); + core.clearMap('ui'); var left = 48, top = 36, right = 416 - 2 * left, bottom = 416 - 2 * top; core.setAlpha('ui', 0.85); diff --git a/project/items.js b/project/items.js index 1d877352..b6848936 100644 --- a/project/items.js +++ b/project/items.js @@ -290,7 +290,7 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "bigKey": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});", "bomb": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawTip(core.material.items[itemId].name + '使用成功');\n core.events.afterUseBomb();\n});", "hammer": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawTip(core.material.items[itemId].name + '使用成功');\n core.events.afterUseBomb();\n});", - "centerFly": "core.clearMap('hero', 0, 0, 416, 416);\ncore.setHeroLoc('x', core.status.event.data.x);\ncore.setHeroLoc('y', core.status.event.data.y);\ncore.drawHero();\ncore.drawTip(core.material.items[itemId].name + '使用成功');", + "centerFly": "core.clearMap('hero');\ncore.setHeroLoc('x', core.status.event.data.x);\ncore.setHeroLoc('y', core.status.event.data.y);\ncore.drawHero();\ncore.drawTip(core.material.items[itemId].name + '使用成功');", "upFly": "var loc = {'direction': core.status.hero.loc.direction, 'x': core.status.event.data.x, 'y': core.status.event.data.y};\ncore.changeFloor(core.status.event.data.id, null, loc, null, function (){\n core.drawTip(core.material.items[itemId].name + '使用成功');\n core.replay();\n});", "downFly": "var loc = {'direction': core.status.hero.loc.direction, 'x': core.status.event.data.x, 'y': core.status.event.data.y};\ncore.changeFloor(core.status.event.data.id, null, loc, null, function (){\n core.drawTip(core.material.items[itemId].name + '使用成功');\n core.replay();\n});", "poisonWine": "core.setFlag('poison', false);", diff --git a/styles.css b/styles.css index 218bfe8d..d85e7d5f 100644 --- a/styles.css +++ b/styles.css @@ -170,7 +170,7 @@ -moz-box-sizing: border-box; -webkit-box-sizing: border-box; background: url(project/images/ground.png) repeat; - z-index: 150; + z-index: 135; display: none; } #statusBar .status{ @@ -257,6 +257,7 @@ span#poison, span#weak, span#curse { position: absolute; background: #000000; overflow: hidden; + z-index: 135; } #bg {