diff --git a/docs/api.md b/docs/api.md index fa703397..72335c95 100644 --- a/docs/api.md +++ b/docs/api.md @@ -162,11 +162,13 @@ core.nextY(n) core.openDoor(id, x, y, needKey, callback) [异步] 尝试开门操作。id为目标点的ID,x和y为坐标,needKey表示是否需要使用钥匙,callback为开门完毕后的回调函数。 +id可为null代表使用地图上的值。 例如:core.openDoor('yellowDoor', 10, 3, false, function() {console.log("1")}) core.battle(id, x, y, force, callback) [异步] 执行战斗事件。id为怪物的id,x和y为坐标,force为bool值表示是否是强制战斗,callback为战斗完毕后的回调函数。 +id可为null代表使用地图上的值。 例如:core.battle('greenSlime', null, null, true) diff --git a/docs/element.md b/docs/element.md index 63e7ed59..bd743bef 100644 --- a/docs/element.md +++ b/docs/element.md @@ -126,7 +126,7 @@ animate为该装备的攻击动画,仅对type为0时有效。具体可参见[ ``` text yellowDoor, blueDoor, redDoor, greenDoor, specialDoor, steelDoor, -yellowWall, blueWall, whiteWall, lava, star +yellowWall, blueWall, whiteWall ``` ## 怪物 diff --git a/libs/events.js b/libs/events.js index 2ef77f0b..08837a96 100644 --- a/libs/events.js +++ b/libs/events.js @@ -684,18 +684,15 @@ events.prototype.doAction = function() { y = core.calValue(data.loc[1]); } var floorId=data.floorId || core.status.floorId; - var block=core.getBlock(x, y, floorId); - if (block!=null) { - if (floorId==core.status.floorId) - core.openDoor(block.block.event.id, block.block.x, block.block.y, false, function() { - core.events.doAction(); - }) - else { - core.removeBlock(block.block.x,block.block.y,floorId); - this.doAction(); - } - break; + if (floorId==core.status.floorId) + core.openDoor(null, x, y, false, function() { + core.events.doAction(); + }) + else { + core.removeBlock(x, y, floorId); + this.doAction(); } + break; this.doAction(); break; } @@ -1067,8 +1064,11 @@ events.prototype.openDoor = function (id, x, y, needKey, callback) { if (core.interval.openDoorAnimate!=null) return; + if (!core.isset(id)) id = core.getBlockId(x, y); + // 是否存在门 - if (!core.terrainExists(x, y, id) && id!='lava' && id!='star') { + if (!core.terrainExists(x, y, id) || !(id.endsWith("Door") || id.endsWith("Wall")) + || !core.isset(core.material.icons.animates[id])) { if (core.isset(callback)) callback(); return; } @@ -1078,24 +1078,13 @@ events.prototype.openDoor = function (id, x, y, needKey, callback) { } core.stopAutomaticRoute(); - var speed=30; - var doorId = id; - if (doorId.length<4 || doorId.substring(doorId.length-4)!="Door") { - doorId=doorId+"Door"; - speed=70; - } - // 不存在门 - if (!core.isset(core.material.icons.animates[doorId])) { - if (core.isset(callback)) callback(); - return; - } + var speed = id.endsWith("Wall")?70:30; - var key = id.replace("Door", "Key"); - if (needKey && (key=="specialKey" || core.isset(core.material.items[key]))) { + if (needKey && id.endsWith("Door")) { var key = id.replace("Door", "Key"); if (!core.hasItem(key)) { if (key != "specialKey") - core.drawTip("你没有" + core.material.items[key].name); + core.drawTip("你没有" + ((core.material.items[key]||{}).name||"钥匙")); else core.drawTip("无法开启此门"); core.clearContinueAutomaticRoute(); return; @@ -1107,7 +1096,7 @@ events.prototype.openDoor = function (id, x, y, needKey, callback) { // open core.playSound("door.mp3"); var state = 0; - var door = core.material.icons.animates[doorId]; + var door = core.material.icons.animates[id]; core.status.replay.animate=true; core.removeGlobalAnimate(x,y); core.interval.openDoorAnimate = window.setInterval(function () { @@ -1134,6 +1123,12 @@ events.prototype.battle = function (id, x, y, force, callback) { core.stopHero(); core.stopAutomaticRoute(); + if (!core.isset(id)) id = core.getBlockId(x, y); + if (!core.isset(id)) { + if (core.isset(callback)) callback(); + return; + } + // 非强制战斗 if (!core.enemys.canBattle(id, x, y) && !force && !core.isset(core.status.event.id)) { core.drawTip("你打不过此怪物!"); diff --git a/project/icons.js b/project/icons.js index 314c671a..bcb69d6a 100644 --- a/project/icons.js +++ b/project/icons.js @@ -64,11 +64,11 @@ icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = 'greenDoor': 7, 'specialDoor': 8, 'steelDoor': 9, - 'yellowWallDoor': 10, - 'whiteWallDoor': 11, - 'blueWallDoor': 12, - 'lavaDoor': 13, - 'starDoor': 14, + 'yellowWall': 10, + 'whiteWall': 11, + 'blueWall': 12, + 'crystalUp': 13, + 'crystalBottom': 14, 'starPortal': 15, 'fire': 16, 'portal': 17, diff --git a/project/images/animates.png b/project/images/animates.png index f6245285..3a901cb8 100644 Binary files a/project/images/animates.png and b/project/images/animates.png differ diff --git a/project/maps.js b/project/maps.js index 5823d190..e015b2f5 100644 --- a/project/maps.js +++ b/project/maps.js @@ -99,6 +99,11 @@ maps_90f36752_8815_4be8_b32b_d7fad1d0542e = '93':{'cls': 'animates', 'id': 'downPortal', 'noPass': false}, // 下箭头 '94':{'cls': 'animates', 'id': 'rightPortal', 'noPass': false}, // 右箭头 + // 101~120 其他的animates + '101':{'cls': 'animates', 'id': 'crystalUp'}, + '102':{'cls': 'animates', 'id': 'crystalBottom'}, + '103':{'cls': 'animates', 'id': 'fire'}, + '104':{'cls': 'animates', 'id': 'switch'}, ////////////////////////// NPC部分 //////////////////////////