openDoor animates

This commit is contained in:
oc 2018-10-29 01:15:30 +08:00
parent 4e79ba1015
commit 6bcba464f7
6 changed files with 35 additions and 33 deletions

View File

@ -162,11 +162,13 @@ core.nextY(n)
core.openDoor(id, x, y, needKey, callback) [异步]
尝试开门操作。id为目标点的IDx和y为坐标needKey表示是否需要使用钥匙callback为开门完毕后的回调函数。
id可为null代表使用地图上的值。
例如core.openDoor('yellowDoor', 10, 3, false, function() {console.log("1")})
core.battle(id, x, y, force, callback) [异步]
执行战斗事件。id为怪物的idx和y为坐标force为bool值表示是否是强制战斗callback为战斗完毕后的回调函数。
id可为null代表使用地图上的值。
例如core.battle('greenSlime', null, null, true)

View File

@ -126,7 +126,7 @@ animate为该装备的攻击动画仅对type为0时有效。具体可参见[
``` text
yellowDoor, blueDoor, redDoor, greenDoor, specialDoor, steelDoor,
yellowWall, blueWall, whiteWall, lava, star
yellowWall, blueWall, whiteWall
```
## 怪物

View File

@ -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("你打不过此怪物!");

View File

@ -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,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -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部分 //////////////////////////