Fix Snipe Bug
This commit is contained in:
parent
c3da5c5e1c
commit
d172cbcd86
192
libs/core.js
192
libs/core.js
@ -2773,105 +2773,119 @@ core.prototype.checkBlock = function () {
|
||||
|
||||
////// 阻击事件(动画效果) //////
|
||||
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}
|
||||
};
|
||||
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;
|
||||
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);
|
||||
core.removeGlobalAnimate(x, y);
|
||||
|
||||
var block = core.getBlock(x,y).block;
|
||||
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);
|
||||
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';
|
||||
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";
|
||||
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);
|
||||
})
|
||||
snipe.damage = damage;
|
||||
snipe.color = color;
|
||||
snipe.block = core.clone(block);
|
||||
})
|
||||
|
||||
var time = 500, step = 0;
|
||||
var finishSnipe = function () {
|
||||
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(2, 32*t.nx, 32*t.ny, t.blockIcon, t.blockImage);
|
||||
core.canvas.event.drawImage(t.blockImage, 0, t.blockIcon*32, 32, 32, 32*t.nx, 32*t.ny, 32, 32);
|
||||
});
|
||||
core.syncGlobalAnimate();
|
||||
core.updateStatusBar();
|
||||
return;
|
||||
}
|
||||
|
||||
var animateValue = 2;
|
||||
var animateCurrent = 0;
|
||||
var animateTime = 0;
|
||||
if (core.status.replay.replaying) {
|
||||
finishSnipe();
|
||||
}
|
||||
else {
|
||||
core.waitHeroToStop(function() {
|
||||
|
||||
core.canvas.fg.textAlign = 'left';
|
||||
core.lockControl();
|
||||
|
||||
var animate=window.setInterval(function() {
|
||||
var time = 500, step = 0;
|
||||
|
||||
step++;
|
||||
animateTime += time / 16;
|
||||
if (animateTime >= core.values.animateSpeed * 2 / animateValue) {
|
||||
animateCurrent++;
|
||||
animateTime = 0;
|
||||
if (animateCurrent>=animateValue) animateCurrent=0;
|
||||
}
|
||||
var animateValue = 2;
|
||||
var animateCurrent = 0;
|
||||
var animateTime = 0;
|
||||
|
||||
snipes.forEach(function (snipe) {
|
||||
var x=snipe.x, y=snipe.y, direction = snipe.direction;
|
||||
core.canvas.fg.textAlign = 'left';
|
||||
|
||||
var nowX=32*x+scan[direction].x*2*step, nowY=32*y+scan[direction].y*2*step;
|
||||
var animate=window.setInterval(function() {
|
||||
|
||||
// 清空上一次
|
||||
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);
|
||||
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);
|
||||
finishSnipe();
|
||||
// 不存在自定义事件
|
||||
if (core.status.event.id==null)
|
||||
core.unLockControl();
|
||||
}
|
||||
}, time/16);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
core.replay();
|
||||
}
|
||||
}, time/16);
|
||||
});
|
||||
}
|
||||
|
||||
////// 更改画面色调 //////
|
||||
@ -3665,13 +3679,11 @@ core.prototype.syncSave = function(type) {
|
||||
core.drawText("出错啦!\n无法同步存档到服务器。\n错误原因:HTTP "+xhr.status);
|
||||
}
|
||||
};
|
||||
xhr.ontimeout = function(e) {
|
||||
console.log(e);
|
||||
core.drawText("出错啦!\n无法同步存档到服务器。\n错误原因:"+e);
|
||||
xhr.ontimeout = function() {
|
||||
core.drawText("出错啦!\n无法同步存档到服务器。\n错误原因:Timeout");
|
||||
}
|
||||
xhr.onerror = function(e) {
|
||||
console.log(e);
|
||||
core.drawText("出错啦!\n无法同步存档到服务器。\n错误原因:"+e);
|
||||
xhr.onerror = function() {
|
||||
core.drawText("出错啦!\n无法同步存档到服务器。\n错误原因:XHR Error");
|
||||
}
|
||||
xhr.send(formData);
|
||||
}, function() {
|
||||
@ -3735,11 +3747,11 @@ core.prototype.syncSave = function(type) {
|
||||
core.drawText("出错啦!\n无法从服务器同步存档。\n错误原因:HTTP "+xhr.status);
|
||||
}
|
||||
};
|
||||
xhr.ontimeout = function(e) {
|
||||
core.drawText("出错啦!\n无法从服务器同步存档。\n错误原因:"+e);
|
||||
xhr.ontimeout = function() {
|
||||
core.drawText("出错啦!\n无法同步存档到服务器。\n错误原因:Timeout");
|
||||
}
|
||||
xhr.onerror = function(e) {
|
||||
core.drawText("出错啦!\n无法从服务器同步存档。\n错误原因:"+e);
|
||||
xhr.onerror = function() {
|
||||
core.drawText("出错啦!\n无法同步存档到服务器。\n错误原因:XHR Error");
|
||||
}
|
||||
xhr.send(formData);
|
||||
}, function() {
|
||||
|
||||
@ -150,7 +150,7 @@ events.prototype.gameOver = function () {
|
||||
core.drawConfirmBox("你想下载录像吗?", function () {
|
||||
|
||||
// 检测是否微信浏览器
|
||||
if ()
|
||||
// if ()
|
||||
|
||||
|
||||
}, function () {
|
||||
|
||||
@ -34,6 +34,10 @@ main.floors.sample0 = {
|
||||
],
|
||||
"events": { // 该楼的所有可能事件列表
|
||||
|
||||
"3,9": [
|
||||
"test"
|
||||
],
|
||||
|
||||
"10,9": [ // 守着道具的老人
|
||||
"\t[老人,man]这些是本样板支持的所有的道具。\n\n道具分为三类:items, constants, tools。\nitems 为即捡即用类道具,例如宝石、血瓶、剑盾等。\nconstants 为永久道具,例如怪物手册、楼层传送器、幸运金币等。\ntools 为消耗类道具,例如破墙镐、炸弹、中心对称飞行器等。\n\n后两类道具在工具栏中可以看到并使用。",
|
||||
"\t[老人,man]有关道具效果,定义在items.js中。\n目前大多数道具已有默认行为,如有自定义的需求则需在items.js中修改代码。",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user