replay animate speed & step replay

This commit is contained in:
oc 2019-04-28 19:23:27 +08:00
parent e61d738f36
commit ccee812af7
6 changed files with 48 additions and 31 deletions

View File

@ -162,19 +162,21 @@ actions.prototype._sys_onkeyUp_replay = function (e) {
core.triggerReplay();
else if (e.keyCode == 65) // A
core.rewindReplay();
else if (e.keyCode == 83)
else if (e.keyCode == 83) // S
core.saveReplay();
else if (e.keyCode == 67)
else if (e.keyCode == 67) // C
core.bookReplay();
else if (e.keyCode == 33 || e.keyCode == 34)
else if (e.keyCode == 33 || e.keyCode == 34) // PgUp/PgDn
core.viewMapReplay();
else if (e.keyCode >= 49 && e.keyCode <= 51)
else if (e.keyCode == 78) // N
core.stepReplay();
else if (e.keyCode >= 49 && e.keyCode <= 51) // 1-3
core.setReplaySpeed(e.keyCode - 48);
else if (e.keyCode == 52)
else if (e.keyCode == 52) // 4
core.setReplaySpeed(6);
else if (e.keyCode == 53)
else if (e.keyCode == 53) // 5
core.setReplaySpeed(12);
else if (e.keyCode == 54)
else if (e.keyCode == 54) // 6
core.setReplaySpeed(24);
return true;
}

View File

@ -1056,7 +1056,7 @@ control.prototype.chooseReplayFile = function () {
control.prototype.startReplay = function (list) {
if (!core.isPlaying()) return;
core.status.replay.replaying=true;
core.status.replay.pausing=false;
core.status.replay.pausing=true;
core.status.replay.speed=1.0;
core.status.replay.toReplay = core.clone(list);
core.status.replay.totalList = core.status.route.concat(list);
@ -1092,16 +1092,24 @@ control.prototype.resumeReplay = function () {
core.replay();
}
////// 单步播放 //////
control.prototype.stepReplay = function () {
if (!core.isPlaying() || !core.isReplaying()) return;
if (!core.status.replay.pausing) return core.drawTip("请先暂停录像");
if (core.isMoving() || core.status.replay.animate || core.status.event.id)
return core.drawTip("请等待当前事件的处理结束");
core.replay(true);
}
////// 加速播放 //////
control.prototype.speedUpReplay = function () {
if (!core.isPlaying() || !core.isReplaying()) return;
if (core.status.replay.speed==12) core.status.replay.speed=24;
else if (core.status.replay.speed==6) core.status.replay.speed=12;
else if (core.status.replay.speed==3) core.status.replay.speed=6;
else if (core.status.replay.speed==2.5) core.status.replay.speed=3;
else if (core.status.replay.speed==2) core.status.replay.speed=2.5;
else if (core.status.replay.speed<2) {
core.status.replay.speed = parseInt(10*core.status.replay.speed + 2)/10;
var speeds = [0.2, 0.5, 1, 2, 3, 6, 12, 24];
for (var i = speeds.length - 2; i >= 0; i--) {
if (speeds[i] <= core.status.replay.speed) {
core.status.replay.speed = speeds[i+1];
break;
}
}
core.drawTip("x"+core.status.replay.speed+"倍");
}
@ -1109,15 +1117,13 @@ control.prototype.speedUpReplay = function () {
////// 减速播放 //////
control.prototype.speedDownReplay = function () {
if (!core.isPlaying() || !core.isReplaying()) return;
if (core.status.replay.speed==24) core.status.replay.speed=12;
else if (core.status.replay.speed==12) core.status.replay.speed=6;
else if (core.status.replay.speed==6) core.status.replay.speed=3;
else if (core.status.replay.speed==3) core.status.replay.speed=2.5;
else if (core.status.replay.speed==2.5) core.status.replay.speed=2;
else {
core.status.replay.speed = parseInt(10*core.status.replay.speed - 2)/10;
var speeds = [0.2, 0.5, 1, 2, 3, 6, 12, 24];
for (var i = 1; i <= speeds.length; i++) {
if (speeds[i] >= core.status.replay.speed) {
core.status.replay.speed = speeds[i-1];
break;
}
}
if (core.status.replay.speed<0.2) core.status.replay.speed=0.2;
core.drawTip("x"+core.status.replay.speed+"倍");
}
@ -1218,9 +1224,10 @@ control.prototype.isReplaying = function () {
}
////// 回放 //////
control.prototype.replay = function () {
control.prototype.replay = function (force) {
if (!core.isPlaying() || !core.isReplaying()
|| core.status.replay.pausing || core.status.replay.animate || core.status.event.id) return;
|| core.status.replay.animate || core.status.event.id) return;
if (core.status.replay.pausing && !force) return;
if (core.status.replay.toReplay.length==0)
return this._replay_finished();
this._replay_save();
@ -1412,9 +1419,9 @@ control.prototype._replayAction_shop = function (action) {
return true;
}
var choices = shop.choices;
var topIndex = core.__HALF_SIZE__ - parseInt(choices.length / 2);
core.status.event.selection = parseInt(selections.shift());
core.events.openShop(shopId, false);
var topIndex = core.__HALF_SIZE__ - parseInt(choices.length / 2) + (core.status.event.ui.offset || 0);
var shopInterval = setInterval(function () {
if (!core.actions._clickShop(core.__HALF_SIZE__, topIndex+core.status.event.selection)) {
clearInterval(shopInterval);
@ -2065,6 +2072,7 @@ control.prototype.setCurtain = function(color, time, callback) {
}
control.prototype._setCurtain_animate = function (nowColor, color, time, callback) {
time /= Math.max(core.status.replay.speed, 1)
var per_time = 10, step = parseInt(time / per_time);
var animate = setInterval(function() {
nowColor = [

View File

@ -432,7 +432,7 @@ events.prototype._openDoor_animate = function (id, x, y, callback) {
}
core.clearMap('event', 32 * x, 32 * y, 32, 32);
core.drawImage('event', core.material.images.animates, 32 * state, 32 * door, 32, 32, 32 * x, 32 * y, 32, 32);
}, speed / core.status.replay.speed);
}, speed / Math.max(core.status.replay.speed, 1));
}
////// 开一个门后触发的事件 //////
@ -1884,7 +1884,7 @@ events.prototype.closeDoor = function (x, y, id, callback) {
}
core.clearMap('event', 32 * x, 32 * y, 32, 32);
core.drawImage('event', core.material.images.animates, 32 * (4-state), 32 * door, 32, 32, 32 * x, 32 * y, 32, 32);
}, speed / core.status.replay.speed);
}, speed / Math.max(core.status.replay.speed, 1));
core.animateFrame.asyncId[animate] = true;
}
@ -1958,7 +1958,8 @@ events.prototype.moveImage = function (code, to, opacityVal, time, callback) {
var opacity = parseFloat(canvas.style.opacity), toOpacity = getOrDefault(opacityVal, opacity);
this._moveImage_moving(name, {
fromX: fromX, fromY: fromY, toX: toX, toY: toY, opacity: opacity, toOpacity: toOpacity, time: time
fromX: fromX, fromY: fromY, toX: toX, toY: toY, opacity: opacity, toOpacity: toOpacity,
time: time / Math.max(core.status.replay.speed, 1)
}, callback)
}
@ -2016,6 +2017,7 @@ events.prototype.setVolume = function (value, time, callback) {
return;
}
var currVolume = core.musicStatus.volume;
time /= Math.max(core.status.replay.speed, 1);
var per_time = 10, step = 0, steps = parseInt(time / per_time);
var fade = setInterval(function () {
step++;
@ -2037,6 +2039,7 @@ events.prototype.vibrate = function (time, callback) {
}
if (!time || time < 1000) time = 1000;
// --- 将time调整为500的倍数上整不然会出错
time /= Math.max(core.status.replay.speed, 1)
time = Math.ceil(time / 500) * 500;
var shakeInfo = {duration: time * 3 / 50, speed: 5, power: 5, direction: 1, shake: 0};
var animate = setInterval(function () {

View File

@ -35,7 +35,7 @@ items.prototype._resetItems = function () {
if (core.flags.bombFourDirections)
core.material.items.bomb.text = "可以炸掉勇士四周的怪物";
if (core.flags.snowFourDirections)
core.material.items.bomb.text = "可以将四周的熔岩变成平地";
core.material.items.snow.text = "可以将四周的熔岩变成平地";
if (core.flags.equipment) {
core.material.items.sword1.cls = 'equips';
core.material.items.sword2.cls = 'equips';

View File

@ -238,7 +238,8 @@ maps.prototype.saveMap = function (floorId) {
if (!floorId) {
var map = {};
for (var id in maps) {
map[id] = this.saveMap(id);
var obj = this.saveMap(id);
if (Object.keys(obj).length > 0) map[id] = obj;
}
return map;
}
@ -1688,6 +1689,7 @@ maps.prototype.jumpBlock = function (sx, sy, ex, ey, time, keep, callback) {
maps.prototype.__generateJumpInfo = function (sx, sy, ex, ey, time) {
var dx = ex - sx, dy = ey - sy, distance = Math.round(Math.sqrt(dx * dx + dy * dy));
var jump_peak = 6 + distance, jump_count = jump_peak * 2;
time /= Math.max(core.status.replay.speed, 1)
return {
x: sx, y: sy, ex: ex, ey: ey, px: 32 * sx, py: 32 * sy, opacity: 1,
jump_peak: jump_peak, jump_count: jump_count,
@ -1751,6 +1753,7 @@ maps.prototype.animateBlock = function (loc, type, time, callback) {
return;
}
this._animateBlock_drawList(list, isHide ? 1 : 0);
time /= Math.max(core.status.replay.speed, 1)
this._animateBlock_doAnimate(loc, list, isHide, 10 / time, callback);
}

View File

@ -971,6 +971,7 @@ ui.prototype.drawScrollText = function (content, time, lineHeight, callback) {
ui.prototype._drawScrollText_animate = function (ctx, time, callback) {
// 开始绘制到UI上
time /= Math.max(core.status.replay.speed, 1)
var per_pixel = 1, height = ctx.canvas.height, per_time = time * per_pixel / (this.PIXEL+height);
var currH = this.PIXEL;
core.drawImage('ui', ctx.canvas, 0, currH);