diff --git a/libs/core.js b/libs/core.js index f10ea08a..e91d0d08 100644 --- a/libs/core.js +++ b/libs/core.js @@ -886,7 +886,8 @@ core.prototype.onmousewheel = function (direct) { /////////// 寻路代码相关 /////////// core.prototype.clearAutomaticRouteNode = function (x, y) { - core.canvas.ui.clearRect(x * 32 + 5, y * 32 + 5, 27, 27); + if (core.status.event.id==null) + core.canvas.ui.clearRect(x * 32 + 5, y * 32 + 5, 27, 27); } core.prototype.stopAutomaticRoute = function () { @@ -2272,6 +2273,15 @@ core.prototype.setGlobalAnimate = function (speed) { }, speed / 2); } +core.prototype.syncGlobalAnimate = function () { + core.status.twoAnimateObjs.forEach(function (t) { + t.status=0; + }) + core.status.fourAnimateObjs.forEach(function (t) { + t.status=0; + }) +} + core.prototype.setBoxAnimate = function () { clearInterval(core.interval.boxAnimate); if (core.status.boxAnimateObjs.length > 0) { @@ -2328,6 +2338,7 @@ core.prototype.updateCheckBlock = function() { if (core.isset(enemy.zoneSquare)) zoneSquare=enemy.zoneSquare; for (var dx=-range;dx<=range;dx++) { for (var dy=-range;dy<=range;dy++) { + if (dx==0 && dy==0) continue; var nx=x+dx, ny=y+dy; if (nx<0 || nx>12 || ny<0 || ny>12) continue; if (!zoneSquare && Math.abs(dx)+Math.abs(dy)>range) continue; @@ -2339,6 +2350,7 @@ core.prototype.updateCheckBlock = function() { if (core.enemys.hasSpecial(enemy.special, 18)) { for (var dx=-1;dx<=1;dx++) { 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; @@ -2404,9 +2416,15 @@ core.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 (core.isset(id)) { + var enemy = core.enemys.getEnemys(id); + if (core.isset(enemy) && core.enemys.hasSpecial(enemy.special, 18)) { + snipe.push({'direction': direction, 'x': nx, 'y': ny}); + } + } } - if (core.status.checkBlock.betweenAttack[13*x+y]) { core.drawTip('受到夹击,生命变成一半'); } @@ -2423,10 +2441,122 @@ core.prototype.checkBlock = function () { core.events.lose('zone'); return; } + snipe = snipe.filter(function (t) { + 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; + }); core.updateStatusBar(); + if (snipe.length>0) + core.snipe(snipe); } } +core.prototype.snipe = function (snipes) { + core.waitHeroToStop(function() { + core.lockControl(); + + var scan = { + 'up': {'x': 0, 'y': -1}, + 'left': {'x': -1, 'y': 0}, + 'down': {'x': 0, 'y': 1}, + 'right': {'x': 1, 'y': 0} + }; + + snipes.forEach(function (snipe) { + var x=snipe.x, y=snipe.y, direction = snipe.direction; + snipe.nx = x+scan[snipe.direction].x; + snipe.ny = y+scan[snipe.direction].y; + + core.removeGlobalAnimate(x, y); + + var block = core.getBlock(x,y).block; + + snipe.blockIcon = core.material.icons[block.event.cls][block.event.id]; + snipe.blockImage = core.material.images[block.event.cls]; + var damage = core.enemys.getDamage(block.event.id); + + var color = "#000000"; + if (damage <= 0) color = '#00FF00'; + else if (damage < core.status.hero.hp / 3) color = '#FFFFFF'; + else if (damage < core.status.hero.hp * 2 / 3) color = '#FFFF00'; + else if (damage < core.status.hero.hp) color = '#FF7F00'; + else color = '#FF0000'; + + if (damage >= 999999999) damage = "???"; + else if (damage > 100000) damage = (damage / 10000).toFixed(1) + "w"; + + snipe.damage = damage; + snipe.color = color; + snipe.block = core.clone(block); + }) + + var time = 500, step = 0; + + var animateValue = 2; + var animateCurrent = 0; + var animateTime = 0; + + core.canvas.fg.textAlign = 'left'; + + var animate=window.setInterval(function() { + + step++; + animateTime += time / 16; + if (animateTime >= core.values.animateSpeed * 2 / animateValue) { + animateCurrent++; + animateTime = 0; + if (animateCurrent>=animateValue) animateCurrent=0; + } + + snipes.forEach(function (snipe) { + var x=snipe.x, y=snipe.y, direction = snipe.direction; + + var nowX=32*x+scan[direction].x*2*step, nowY=32*y+scan[direction].y*2*step; + + // 清空上一次 + core.clearMap('event', nowX-2*scan[direction].x, nowY-2*scan[direction].y, 32, 32); + core.clearMap('fg', nowX-2*scan[direction].x, nowY-2*scan[direction].y, 32, 32); + + core.canvas.event.drawImage(snipe.blockImage, animateCurrent*32, snipe.blockIcon*32, 32, 32, nowX, nowY, 32, 32); + + if (core.hasItem('book')) { + // drawFG + core.setFillStyle('fg', '#000000'); + core.canvas.fg.fillText(snipe.damage, nowX + 2, nowY + 30); + core.canvas.fg.fillText(snipe.damage, nowX, nowY + 30); + core.canvas.fg.fillText(snipe.damage, nowX + 2, nowY + 32); + core.canvas.fg.fillText(snipe.damage, nowX, nowY + 32); + + core.setFillStyle('fg', snipe.color); + core.canvas.fg.fillText(snipe.damage, nowX + 1, nowY + 31); + } + + }) + + if (step==16) { // 移动完毕 + clearInterval(animate); + snipes.forEach(function (t) { + core.removeBlock(t.x, t.y); + var nBlock = core.clone(t.block); + nBlock.x = t.nx; nBlock.y = t.ny; + core.status.thisMap.blocks.push(nBlock); + core.addGlobalAnimate(animateValue, 32*t.nx, 32*t.ny, t.blockIcon, t.blockImage); + }); + core.syncGlobalAnimate(); + core.updateStatusBar(); + // 不存在自定义事件 + if (core.status.event.id==null) + core.unLockControl(); + } + }, time/16); + + + + }); +} + core.prototype.setFg = function(color, time, callback) { time = time || 750; @@ -3402,9 +3532,14 @@ core.prototype.checkLvUp = function () { core.status.hero.lv++; var effect = core.firstData.levelUp[core.status.hero.lv-1].effect; if (typeof effect == "string") { - effect.split(";").forEach(function (t) { - core.doEffect(t); - }); + if (effect.indexOf("function")==0) { + eval("("+effect+")()"); + } + else { + effect.split(";").forEach(function (t) { + core.doEffect(t); + }); + } } else if (effect instanceof Function) { effect(); diff --git a/libs/data.js b/libs/data.js index 6c490d77..adb77995 100644 --- a/libs/data.js +++ b/libs/data.js @@ -145,7 +145,7 @@ data.prototype.init = function() { "enableMDef": true, // 是否在状态栏及战斗界面显示魔防(护盾) "enableMoney": true, // 是否在状态栏、怪物手册及战斗界面显示金币 "enableExperience": true, // 是否在状态栏、怪物手册及战斗界面显示经验 - "enableLevelUp": false, // 是否允许等级提升(进阶);如果上面enableExperience为false,则此项恒视为false + "enableLevelUp": true, // 是否允许等级提升(进阶);如果上面enableExperience为false,则此项恒视为false "enableDebuff": true, // 是否涉及毒衰咒;如果此项为false则不会在状态栏中显示毒衰咒的debuff ////// 上述的几个开关将直接影响状态栏的显示效果 ////// /****** 道具相关 ******/ diff --git a/libs/events.js b/libs/events.js index 26d62ac6..051996a0 100644 --- a/libs/events.js +++ b/libs/events.js @@ -352,8 +352,14 @@ events.prototype.doAction = function() { core.events.lose(data.reason); break; case "function": - if (core.isset(data["function"])) - data["function"](); + var func = data["function"]; + if (core.isset(func)) { + if ((typeof func == "string") && func.indexOf("function")==0) { + eval('('+func+')()'); + } + else if (func instanceof Function) + func(); + } this.doAction(); break; case "update": @@ -528,6 +534,12 @@ events.prototype.afterBattle = function(enemyId,x,y,callback) { return; } + // 阻击:不处理任何事件 + if (core.enemys.hasSpecial(special, 18)) { + if (core.isset(callback)) callback(); + return; + } + // 检查处理后的事件。 var event = core.floors[core.status.floorId].afterBattle[x+","+y]; if (core.isset(event)) { @@ -536,8 +548,8 @@ events.prototype.afterBattle = function(enemyId,x,y,callback) { //继续行走 else { core.continueAutomaticRoute(); - if (core.isset(callback)) callback(); } + if (core.isset(callback)) callback(); } /****** 开完门 ******/ diff --git a/libs/floors/test.js b/libs/floors/test.js index 4a1fce20..d85b7a2b 100644 --- a/libs/floors/test.js +++ b/libs/floors/test.js @@ -12,14 +12,14 @@ main.floors.test = { [ 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, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 1, 0, 237, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 220, 246,0, 246, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 219, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0,237, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 45, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ], @@ -27,7 +27,10 @@ main.floors.test = { ], "events": { // 该楼的所有可能事件列表 - + "6,4": [ + "test", + {"type": 'hide'} + ] }, "changeFloor": { // 楼层转换事件;该事件不能和上面的events有冲突(同位置点),否则会被覆盖 diff --git a/更新说明.txt b/更新说明.txt index 6e9cc527..cdc48c46 100644 --- a/更新说明.txt +++ b/更新说明.txt @@ -1,11 +1,11 @@ 全键盘操作 √ -进阶 √ +经验升级(进阶) √ +支持阻击 √ +九宫格领域、大范围领域 √ Ctrl快速跳过对话 √ 增加负伤 √ 支持不同层使用不同的地面素材 √ 支持多个Autotile同时存在 √ 直接内嵌了诸多默认的terrains素材 √ 自动定位到上次存/读档位置 √ -设置储存 √ -修改setFg的实现方法 √ -大范围领域伤害 \ No newline at end of file +修改setFg的实现方法 √ \ No newline at end of file