fix:败移追猎小调整
This commit is contained in:
parent
c41dde17a3
commit
b209a114f4
@ -3090,7 +3090,7 @@ events.prototype.moveEnemyOnPoint = function (fromX, fromY, toX, toY, floorId, n
|
|||||||
}
|
}
|
||||||
|
|
||||||
////// 将两个点的怪物属性交换 //////
|
////// 将两个点的怪物属性交换 //////
|
||||||
events.prototype.switchEnemyOnPoint = function (fromX, fromY, toX, toY, floorId, norefresh) {
|
events.prototype.exchangeEnemyOnPoint = function (fromX, fromY, toX, toY, floorId, norefresh) {
|
||||||
floorId = floorId || core.status.floorId;
|
floorId = floorId || core.status.floorId;
|
||||||
const spos = fromX + "," + fromY,
|
const spos = fromX + "," + fromY,
|
||||||
aimpos = toX + "," + toY;
|
aimpos = toX + "," + toY;
|
||||||
|
|||||||
42
libs/maps.js
42
libs/maps.js
@ -2730,54 +2730,22 @@ maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, call
|
|||||||
}
|
}
|
||||||
_run();
|
_run();
|
||||||
}
|
}
|
||||||
//core.setEnemyOnPoint(5,2,null,'hp',1000,'=') core.exchangeBlock(5, 2, 5, 3, 'down', 100, null)
|
|
||||||
maps.prototype.exchangeBlock = function (x1, y1, x2, y2, dir, time, callback) {
|
maps.prototype.exchangeBlock = function (x1, y1, x2, y2, dir, time, callback) {
|
||||||
console.log([x1, y1, x2, y2, dir, time, callback])
|
|
||||||
let [block1, block2] = [this.getBlock(x1, y1), this.getBlock(x2, y2)];
|
|
||||||
let [blockInfo1, blockInfo2] = [this.getBlockInfo(block1), this.getBlockInfo(block2)];
|
|
||||||
const [pos1, pos2] = [`${x1},${y1}`, `${x2},${y2}`];
|
|
||||||
let fromInfo, toInfo, enemyOnFloor;
|
|
||||||
const floorId = core.status.floorId;
|
const floorId = core.status.floorId;
|
||||||
if (flags.enemyOnPoint && flags.enemyOnPoint.hasOwnProperty(floorId)) {
|
|
||||||
enemyOnFloor = flags.enemyOnPoint[floorId];
|
|
||||||
if (enemyOnFloor.hasOwnProperty(pos1)) fromInfo = core.clone(enemyOnFloor[pos1]);
|
|
||||||
if (enemyOnFloor.hasOwnProperty(pos2)) toInfo = core.clone(enemyOnFloor[pos2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
let callbackCount = 0;
|
let callbackCount = 0;
|
||||||
function myCallback() {
|
function myCallback() {
|
||||||
callbackCount++;
|
callbackCount++;
|
||||||
if (callbackCount === 2) {
|
if (callbackCount === 2) {
|
||||||
// 删除旧位置信息
|
core.exchangeEnemyOnPoint(x1, y1, x2, y2, floorId);
|
||||||
if (fromInfo) delete enemyOnFloor[pos1];
|
|
||||||
if (toInfo) delete enemyOnFloor[pos2];
|
|
||||||
|
|
||||||
// 设置新位置信息
|
|
||||||
if (fromInfo) enemyOnFloor[pos2] = fromInfo;
|
|
||||||
if (toInfo) enemyOnFloor[pos1] = toInfo;
|
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (dir) {
|
const reverseDir = { 'up': 'down', 'down': 'up', 'left': 'right', 'right': 'left' };
|
||||||
case 'left':
|
this.moveBlock(x1, y1, [dir], time, true, myCallback, true);
|
||||||
this.moveBlock(x1, y1, ['left'], time, true, myCallback, true);
|
this.moveBlock(x2, y2, [reverseDir[dir]], time, true, myCallback, true);
|
||||||
this.moveBlock(x2, y2, ['right'], time, true, myCallback, true);
|
|
||||||
break;
|
|
||||||
case 'right':
|
|
||||||
this.moveBlock(x1, y1, ['right'], time, true, myCallback, true);
|
|
||||||
this.moveBlock(x2, y2, ['left'], time, true, myCallback, true);
|
|
||||||
break;
|
|
||||||
case 'up':
|
|
||||||
this.moveBlock(x1, y1, ['up'], time, true, myCallback, true);
|
|
||||||
this.moveBlock(x2, y2, ['down'], time, true, myCallback, true);
|
|
||||||
break;
|
|
||||||
case 'down':
|
|
||||||
this.moveBlock(x1, y1, ['down'], time, true, myCallback, true);
|
|
||||||
this.moveBlock(x2, y2, ['up'], time, true, myCallback, true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
maps.prototype._moveBlock_updateSpeed = function (moveInfo) {
|
maps.prototype._moveBlock_updateSpeed = function (moveInfo) {
|
||||||
|
|||||||
@ -443,7 +443,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
{ "type": "setBlock", "number": enemyId, "loc": [[aimx, aimy]], "time": 50 },
|
{ "type": "setBlock", "number": enemyId, "loc": [[aimx, aimy]], "time": 50 },
|
||||||
{ "type": "setBlock", "number": aimId, "loc": [[x, y]], "time": 50 },
|
{ "type": "setBlock", "number": aimId, "loc": [[x, y]], "time": 50 },
|
||||||
{
|
{
|
||||||
"type": "function", "function": `function () { core.switchEnemyOnPoint(${x},${y},${aimx},${aimy}) }`
|
"type": "function", "function": `function () { core.exchangeEnemyOnPoint(${x},${y},${aimx},${aimy}) }`
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
core.insertAction(doFailMove);
|
core.insertAction(doFailMove);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user