Replay Directions

This commit is contained in:
ckcz123 2018-01-16 12:54:34 +08:00
parent c8a2edbfc7
commit bbf250047f
5 changed files with 223 additions and 116 deletions

View File

@ -93,6 +93,7 @@ core.setAutoHeroMove // 设置勇士的自动行走路线
core.autoHeroMove // 让勇士开始自动行走
core.setHeroMoveInterval // 设置行走的效果动画
core.setHeroMoveTriggerInterval // 设置勇士行走过程中对事件的触发检测
core.moveAction // 实际每一步的行走过程
* core.turnHero(direction) // 设置勇士的方向(转向)
core.canMoveHero // 勇士能否前往某方向
core.moveHero // 让勇士开始移动
@ -178,16 +179,21 @@ core.clone // 深拷贝一个对象
core.formatDate // 格式化时间为字符串
core.setTwoDigits // 两位数显示
core.debug // 进入Debug模式攻防血和钥匙都调成很高的数值
core.replay // 开始回放
core.checkStatus // 判断当前能否进入某个事件
core.openBook // 点击怪物手册时的打开操作
core.useFly // 点击楼层传送器时的打开操作
core.openToolbox // 点击工具栏时的打开操作
core.openQuickShop // 点击快捷商店时的打开操作
core.save // 点击保存按钮时的打开操作
core.load // 点击读取按钮时的打开操作
core.openSettings // 点击设置按钮时的打开操作
core.doSL // 实际进行存读档事件
core.syncSave // 存档同步操作
core.saveData // 存档到本地
core.loadData // 从本地读档
core.encodeRoute // 将路线压缩
core.decodeRoute // 将路线解压缩
* core.setStatus // 设置勇士属性
* core.getStatus // 获得勇士属性
core.getLvName // 获得某个等级的名称

View File

@ -79,9 +79,16 @@ function core() {
'mouseOutCheck': 1,
'moveStepBeforeStop': [],
'downTime': null,
'route': [], // 当前路线!
// 勇士状态;中心对称飞行器
// 路线&回放
'route': [],
'replay': {
'replaying': false,
'pausing': false,
'animate': false, // 正在某段动画中
'toReplay': [],
'totalList': []
},
// event事件
'saveIndex': null,
@ -502,6 +509,7 @@ core.prototype.restart = function() {
////// 按下某个键时 //////
core.prototype.onkeyDown = function(e) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
if (!core.isset(core.status.holdingKeys))core.status.holdingKeys=[];
var isArrow={37:true,38:true,39:true,40:true}[e.keyCode]
if(isArrow && !core.status.lockControl){
@ -519,6 +527,7 @@ core.prototype.onkeyDown = function(e) {
////// 放开某个键时 //////
core.prototype.onkeyUp = function(e) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
var isArrow={37:true,38:true,39:true,40:true}[e.keyCode]
if(isArrow && !core.status.lockControl){
for(var ii =0;ii<core.status.holdingKeys.length;ii++){
@ -537,6 +546,7 @@ core.prototype.onkeyUp = function(e) {
////// 按住某个键时 //////
core.prototype.pressKey = function (keyCode) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
if (keyCode === core.status.holdingKeys.slice(-1)[0]) {
core.keyDown(keyCode);
window.setTimeout(function(){core.pressKey(keyCode);},30);
@ -545,6 +555,7 @@ core.prototype.pressKey = function (keyCode) {
////// 根据按下键的code来执行一系列操作 //////
core.prototype.keyDown = function(keyCode) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
if(core.status.automaticRouting || core.status.automaticRouted) {
core.stopAutomaticRoute();
}
@ -644,6 +655,7 @@ core.prototype.keyDown = function(keyCode) {
////// 根据放开键的code来执行一系列操作 //////
core.prototype.keyUp = function(keyCode) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
if (core.status.lockControl) {
core.status.holdingKeys = [];
@ -713,7 +725,7 @@ core.prototype.keyUp = function(keyCode) {
switch (keyCode) {
case 27: // ESC
if (core.status.heroStop)
core.ui.drawSettings(true);
core.openSettings(true);
break;
case 71: // G
if (core.status.heroStop)
@ -744,7 +756,7 @@ core.prototype.keyUp = function(keyCode) {
break;
case 75: // K
if (core.status.heroStop)
core.ui.drawQuickShop(true);
core.openQuickShop(true);
break;
case 32: // SPACE
if (!core.status.lockControl && core.status.heroStop)
@ -801,6 +813,7 @@ core.prototype.keyUp = function(keyCode) {
////// 点击(触摸)事件按下时 //////
core.prototype.ondown = function (x ,y) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
if (!core.status.played || core.status.lockControl) {
core.onclick(x, y, []);
return;
@ -820,6 +833,7 @@ core.prototype.ondown = function (x ,y) {
////// 当在触摸屏上滑动时 //////
core.prototype.onmove = function (x ,y) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
if (core.status.holdingPath==0){return;}
core.status.mouseOutCheck =1;
var pos={'x':x,'y':y};
@ -843,6 +857,7 @@ core.prototype.onmove = function (x ,y) {
////// 当点击(触摸)事件放开时 //////
core.prototype.onup = function () {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
core.status.holdingPath=0;
if(core.status.stepPostfix.length>0){
var stepPostfix = [];
@ -897,6 +912,7 @@ core.prototype.getClickLoc = function (x, y) {
////// 具体点击屏幕上(x,y)点时,执行的操作 //////
core.prototype.onclick = function (x, y, stepPostfix) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
// console.log("Click: (" + x + "," + y + ")");
// 非游戏屏幕内
@ -1018,6 +1034,7 @@ core.prototype.onclick = function (x, y, stepPostfix) {
////// 滑动鼠标滚轮时的操作 //////
core.prototype.onmousewheel = function (direct) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
// 向下滚动是 -1 ,向上是 1
// 楼层飞行器
@ -1341,7 +1358,7 @@ core.prototype.stopAutoHeroMove = function () {
}
////// 设置勇士的自动行走路线 //////
core.prototype.setAutoHeroMove = function (steps, start) {
core.prototype.setAutoHeroMove = function (steps) {
if (steps.length == 0) {
return;
}
@ -1394,6 +1411,8 @@ core.prototype.setHeroMoveInterval = function (direction, x, y, callback) {
core.moveOneStep();
if (core.status.heroStop)
core.drawHero(direction, core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
clearInterval(core.interval.heroMoveInterval);
core.status.heroMoving = false;
if (core.isset(callback)) callback();
}
}, 12.5);
@ -1401,61 +1420,67 @@ core.prototype.setHeroMoveInterval = function (direction, x, y, callback) {
////// 设置勇士行走过程中对事件的触发检测 //////
core.prototype.setHeroMoveTriggerInterval = function () {
var direction, x, y;
core.interval.heroMoveTriggerInterval = window.setInterval(function () {
if (!core.status.heroStop) {
core.moveAction();
}
}, 50);
}
////// 实际每一步的行走过程 //////
core.prototype.moveAction = function (callback) {
var scan = {
'up': {'x': 0, 'y': -1},
'left': {'x': -1, 'y': 0},
'down': {'x': 0, 'y': 1},
'right': {'x': 1, 'y': 0}
};
core.interval.heroMoveTriggerInterval = window.setInterval(function () {
if (!core.status.heroStop) {
direction = core.getHeroLoc('direction');
x = core.getHeroLoc('x');
y = core.getHeroLoc('y');
var noPass = core.noPass(x + scan[direction].x, y + scan[direction].y), canMove = core.canMoveHero();
if (noPass || !canMove) {
core.status.route.push(direction);
if (canMove) // 非箭头:触发
core.trigger(x + scan[direction].x, y + scan[direction].y);
core.drawHero(direction, x, y, 'stop');
if (core.status.autoHeroMove) {
core.status.movedStep++;
if (core.status.destStep == core.status.movedStep) {
core.status.autoHeroMove = false;
core.status.destStep = 0;
core.status.movedStep = 0;
core.status.moveStepBeforeStop=[];
core.stopAutomaticRoute();
}
}
else {
core.status.heroStop = true;
}
return;
var direction = core.getHeroLoc('direction');
var x = core.getHeroLoc('x');
var y = core.getHeroLoc('y');
var noPass = core.noPass(x + scan[direction].x, y + scan[direction].y), canMove = core.canMoveHero();
if (noPass || !canMove) {
core.status.route.push(direction);
if (canMove) // 非箭头:触发
core.trigger(x + scan[direction].x, y + scan[direction].y);
core.drawHero(direction, x, y, 'stop');
if (core.status.autoHeroMove) {
core.status.movedStep++;
if (core.status.destStep == core.status.movedStep) {
core.status.autoHeroMove = false;
core.status.destStep = 0;
core.status.movedStep = 0;
core.status.moveStepBeforeStop=[];
core.stopAutomaticRoute();
}
core.setHeroMoveInterval(direction, x, y, function () {
if (core.status.autoHeroMove) {
core.status.movedStep++;
if (core.status.destStep == core.status.movedStep) {
core.status.autoHeroMove = false;
core.status.destStep = 0;
core.status.movedStep = 0;
core.stopHero();
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
}
}
else if (core.status.heroStop) {
}
else {
core.status.heroStop = true;
}
if (core.isset(callback))
callback();
}
else {
core.setHeroMoveInterval(direction, x, y, function () {
if (core.status.autoHeroMove) {
core.status.movedStep++;
if (core.status.destStep == core.status.movedStep) {
core.status.autoHeroMove = false;
core.status.destStep = 0;
core.status.movedStep = 0;
core.stopHero();
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
}
core.status.route.push(direction);
core.trigger(core.getHeroLoc('x'), core.getHeroLoc('y'));
clearInterval(core.interval.heroMoveInterval);
core.status.heroMoving = false;
core.checkBlock();
});
}
}, 50);
}
else if (core.status.heroStop) {
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
}
core.status.route.push(direction);
core.trigger(core.getHeroLoc('x'), core.getHeroLoc('y'));
core.checkBlock();
if (core.isset(callback)) callback();
});
}
}
////// 设置勇士的方向(转向) //////
@ -1482,8 +1507,6 @@ core.prototype.canMoveHero = function() {
if(nowIsArrow){
var nowArrow = nowId.slice(5).toLowerCase();
if (direction != nowArrow) {
// core.status.heroStop = true;
// core.turnHero(direction);
return false;
}
}
@ -1502,8 +1525,6 @@ core.prototype.canMoveHero = function() {
if(isArrow){
var nextArrow = nextId.slice(5).toLowerCase();
if ( (scan[direction].x + scan[nextArrow].x) == 0 && (scan[direction].y + scan[nextArrow].y) == 0 ) {
// core.status.heroStop = true;
// core.turnHero(direction);
return false;
}
}
@ -1512,9 +1533,17 @@ core.prototype.canMoveHero = function() {
}
////// 让勇士开始移动 //////
core.prototype.moveHero = function (direction) {
core.setHeroLoc('direction', direction);
core.status.heroStop = false;
core.prototype.moveHero = function (direction, callback) {
if (core.isset(direction))
core.setHeroLoc('direction', direction);
if (!core.isset(callback)) { // 如果不存在回调函数则使用heroMoveTrigger
core.status.heroStop = false;
}
else { // 否则只向某个方向移动一步然后调用callback
core.moveAction(function () {
callback();
})
}
}
/////// 使用事件让勇士移动。这个函数将不会触发任何事件 //////
@ -1551,11 +1580,14 @@ core.prototype.eventMoveHero = function(steps, time, callback) {
'right': {'x': 1, 'y': 0}
};
core.status.replay.animate=true;
var animate=window.setInterval(function() {
var x=core.getHeroLoc('x'), y=core.getHeroLoc('y');
if (moveSteps.length==0) {
clearInterval(animate);
core.drawHero(core.getHeroLoc('direction'), x, y, 'stop');
core.status.replay.animate=false;
if (core.isset(callback)) callback();
}
else {
@ -1598,8 +1630,10 @@ core.prototype.waitHeroToStop = function(callback) {
core.stopAutomaticRoute();
core.clearContinueAutomaticRoute();
if (core.isset(callback)) {
core.status.replay.animate=true;
core.lockControl();
setTimeout(function(){
core.status.replay.animate=false;
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
callback();
}, 30);
@ -1695,7 +1729,6 @@ core.prototype.openDoor = function (id, x, y, needKey, callback) {
core.drawTip("你没有" + core.material.items[key].name);
else core.drawTip("无法开启此门");
core.clearContinueAutomaticRoute();
if (core.isset(callback)) callback();
return;
}
}
@ -1708,12 +1741,14 @@ core.prototype.openDoor = function (id, x, y, needKey, callback) {
speed=100;
}
var door = core.material.icons.animates[doorId];
core.status.replay.animate=true;
core.interval.openDoorAnimate = window.setInterval(function () {
state++;
if (state == 4) {
clearInterval(core.interval.openDoorAnimate);
core.interval.openDoorAnimate=null;
core.removeBlock(x, y);
core.status.replay.animate=false;
core.events.afterOpenDoor(id,x,y,callback);
return;
}
@ -1738,7 +1773,7 @@ core.prototype.battle = function (id, x, y, force, callback) {
core.clearContinueAutomaticRoute();
return;
}
if (core.flags.battleAnimate) {
if (core.flags.battleAnimate&&!core.status.replay.replaying) {
core.waitHeroToStop(function() {
core.ui.drawBattleAnimate(id, function() {
core.afterBattle(id, x, y, callback);
@ -1822,6 +1857,7 @@ core.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback)
core.stopHero();
core.stopAutomaticRoute();
core.clearContinueAutomaticRoute();
core.status.replay.animate=true;
core.dom.floorNameLabel.innerHTML = core.status.maps[floorId].title;
if (!core.isset(stair) && !core.isset(heroLoc))
heroLoc = core.status.hero.loc;
@ -1896,6 +1932,7 @@ core.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback)
var changed = function () {
core.unLockControl();
core.status.replay.animate=false;
core.events.afterChangeFloor(floorId);
if (core.isset(callback)) callback();
}
@ -2254,6 +2291,7 @@ core.prototype.getBlock = function (x, y, floorId, needEnable) {
////// 显示移动某块的动画,达到{“type”:”move”}的效果 //////
core.prototype.moveBlock = function(x,y,steps,time,immediateHide,callback) {
time = time || 500;
core.status.replay.animate=true;
clearInterval(core.interval.tipAnimate);
core.saveCanvas('data');
@ -2331,6 +2369,7 @@ core.prototype.moveBlock = function(x,y,steps,time,immediateHide,callback) {
core.loadCanvas('data');
core.clearMap('data', 0, 0, 416, 416);
core.setOpacity('data', 1);
core.status.replay.animate=false;
if (core.isset(callback)) callback();
}
}
@ -2354,6 +2393,7 @@ core.prototype.moveBlock = function(x,y,steps,time,immediateHide,callback) {
////// 显示/隐藏某个块时的动画效果 //////
core.prototype.animateBlock = function (x,y,type,time,callback) {
if (type!='hide') type='show';
core.status.replay.animate=true;
clearInterval(core.interval.tipAnimate);
core.saveCanvas('data');
@ -2389,6 +2429,7 @@ core.prototype.animateBlock = function (x,y,type,time,callback) {
core.loadCanvas('data');
core.clearMap('data', 0, 0, 416, 416);
core.setOpacity('data', 1);
core.status.replay.animate=false;
if (core.isset(callback)) callback();
}
}, time/10);
@ -2811,11 +2852,9 @@ core.prototype.snipe = function (snipes) {
// 不存在自定义事件
if (core.status.event.id==null)
core.unLockControl();
core.replay();
}
}, time/16);
});
}
@ -2850,6 +2889,7 @@ core.prototype.setFg = function(color, time, callback) {
}
var step=0;
core.status.replay.animate=true;
var changeAnimate = setInterval(function() {
step++;
@ -2868,6 +2908,7 @@ core.prototype.setFg = function(color, time, callback) {
if (step>=25) {
clearInterval(changeAnimate);
core.status.curtainColor = color;
core.status.replay.animate=false;
if (core.isset(callback)) callback();
}
}, time/25);
@ -3104,6 +3145,13 @@ core.prototype.drawTip = function (text, itemIcon) {
////// 地图中间绘制一段文字 //////
core.prototype.drawText = function (contents, callback) {
if (core.isset(contents)) {
// 合并
if (core.isset(core.status.event)&&core.status.event.id=='action') {
core.insertAction(contents,null,null,callback);
return;
}
if (typeof contents == 'string') {
contents = [{'content': contents}];
}
@ -3308,6 +3356,47 @@ core.prototype.debug = function() {
core.drawTip("作弊成功");
}
core.prototype.testReplay = function(list) {
core.status.replay.replaying=true;
core.status.replay.toReplay=core.clone(list);
core.replay();
}
////// 回放 //////
core.prototype.replay = function () {
if (!core.status.replay.replaying) return; // 没有回放
if (core.status.replay.pausing) return; // 暂停状态
if (core.status.replay.animate) return; // 正在某段动画中
if (core.status.replay.toReplay.length==0) { // 回放完毕
core.status.replay.replaying=false;
core.insertAction("录像回放完毕!");
return;
}
var action=core.status.replay.toReplay.shift();
if (action=='up' || action=='down' || action=='left' || action=='right')
core.moveHero(action, function () {
core.replay();
});
else if (action.indexOf("item:")==0) {
}
else if (action.indexOf("fly:")==0) {
}
else if (action.indexOf("shop:")==0) {
}
else { // 其他情况:回放失败
core.status.replay.replaying=false;
core.insertAction("录像出错,回放失败。");
return;
}
}
////// 判断当前能否进入某个事件 //////
core.prototype.checkStatus = function (name, need, item) {
if (need && core.status.event.id == name) {
@ -3333,6 +3422,7 @@ core.prototype.checkStatus = function (name, need, item) {
////// 点击怪物手册时的打开操作 //////
core.prototype.openBook = function (need) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
if (!core.checkStatus('book', need, true))
return;
core.useItem('book');
@ -3340,6 +3430,7 @@ core.prototype.openBook = function (need) {
////// 点击楼层传送器时的打开操作 //////
core.prototype.useFly = function (need) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
if (!core.checkStatus('fly', need, true))
return;
if (core.flags.flyNearStair && !core.nearStair()) {
@ -3362,13 +3453,23 @@ core.prototype.useFly = function (need) {
////// 点击工具栏时的打开操作 //////
core.prototype.openToolbox = function (need) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
if (!core.checkStatus('toolbox', need))
return;
core.ui.drawToolbox();
}
////// 点击快捷商店按钮时的打开操作 //////
core.prototype.openQuickShop = function (need) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
if (!core.checkStatus('selectShop', need))
return;
core.ui.drawQuickShop();
}
////// 点击保存按钮时的打开操作 //////
core.prototype.save = function(need) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
if (!core.checkStatus('save', need))
return;
core.ui.drawSLPanel(core.status.saveIndex);
@ -3376,6 +3477,7 @@ core.prototype.save = function(need) {
////// 点击读取按钮时的打开操作 //////
core.prototype.load = function (need) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
// 游戏开始前读档
if (!core.isPlaying()) {
@ -3391,6 +3493,14 @@ core.prototype.load = function (need) {
core.ui.drawSLPanel(core.status.saveIndex);
}
////// 点击设置按钮时的操作 //////
core.prototype.openSettings = function (need) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
if (!core.checkStatus('settings', need))
return;
core.ui.drawSettings();
}
////// 自动存档 //////
core.prototype.autosave = function () {
core.saveData("autoSave");
@ -3720,8 +3830,8 @@ core.prototype.hasFlag = function(flag) {
}
////// 往当前事件列表之前插入一系列事件 //////
core.prototype.insertAction = function (list) {
core.events.insertAction(list);
core.prototype.insertAction = function (list, x, y, callback) {
core.events.insertAction(list, x, y, callback);
}
////// 锁定状态栏,常常用于事件处理 //////

View File

@ -18,9 +18,10 @@ events.prototype.init = function () {
},
'openDoor': function (data, core, callback) {
core.autosave();
core.openDoor(data.event.id, data.x, data.y, true);
if (core.isset(callback))
callback();
core.openDoor(data.event.id, data.x, data.y, true, function () {
if (core.isset(callback)) callback();
core.replay();
});
},
'changeFloor': function (data, core, callback) {
var heroLoc = {};
@ -29,7 +30,10 @@ events.prototype.init = function () {
if (core.isset(data.event.data.direction))
heroLoc.direction = data.event.data.direction;
core.changeFloor(data.event.data.floorId, data.event.data.stair,
heroLoc, data.event.data.time, callback);
heroLoc, data.event.data.time, function () {
if (core.isset(callback)) callback();
core.replay();
});
},
'passNet': function (data, core, callback) {
core.events.passNet(data);
@ -149,12 +153,13 @@ events.prototype.afterChangeFloor = function (floorId) {
////// 开始执行一系列自定义事件 //////
events.prototype.doEvents = function (list, x, y, callback) {
if (!core.isset(list)) return;
if (!(list instanceof Array)) {
list = [list];
}
// 停止勇士
core.waitHeroToStop(function() {
if (!core.isset(list)) return;
if (!(list instanceof Array)) {
list = [list];
}
core.lockControl();
core.status.event = {'id': 'action', 'data': {
'list': core.clone(list), 'x': x, 'y': y, 'callback': callback
@ -175,6 +180,7 @@ events.prototype.doAction = function() {
if (core.isset(core.status.event.data.callback))
core.status.event.data.callback();
core.ui.closePanel();
core.replay();
return;
}
@ -188,13 +194,20 @@ events.prototype.doAction = function() {
// 如果是文字:显示
if (typeof data == "string") {
core.status.event.data.type='text';
core.ui.drawTextBox(data);
// 如果是正在回放中,不显示
if (core.status.replay.replaying)
core.events.doAction();
else
core.ui.drawTextBox(data);
return;
}
core.status.event.data.type=data.type;
switch (data.type) {
case "text": // 文字/对话
core.ui.drawTextBox(data.data);
if (core.status.replay.isreplaying)
core.events.doAction();
else
core.ui.drawTextBox(data.data);
break;
case "tip":
core.drawTip(core.replaceText(data.text));
@ -411,12 +424,15 @@ events.prototype.doAction = function() {
}
////// 往当前事件列表之前添加一个或多个事件 //////
events.prototype.insertAction = function (action) {
events.prototype.insertAction = function (action, x, y, callback) {
if (core.status.event.id == null) {
this.doEvents(action);
this.doEvents(action, x, y, callback);
}
else {
core.unshift(core.status.event.data.list, action)
if (core.isset(x)) core.status.event.data.x=x;
if (core.isset(y)) core.status.event.data.y=y;
if (core.isset(callback)) core.status.event.data.callback=callback;
}
}
@ -795,12 +811,10 @@ events.prototype.keyDownAction = function (keycode) {
if (choices.length>0) {
if (keycode==38) {
core.status.event.selection--;
if (core.status.event.selection<0) core.status.event.selection=0;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
if (keycode==40) {
core.status.event.selection++;
if (core.status.event.selection>=choices.length) core.status.event.selection=choices.length-1;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
}
@ -972,16 +986,12 @@ events.prototype.clickShop = function(x,y) {
////// 商店界面时,按下某个键的操作 //////
events.prototype.keyDownShop = function (keycode) {
var shop = core.status.event.data.shop;
var choices = shop.choices;
if (keycode==38) {
core.status.event.selection--;
if (core.status.event.selection<0) core.status.event.selection=0;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
if (keycode==40) {
core.status.event.selection++;
if (core.status.event.selection>choices.length) core.status.event.selection=choices.length;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
}
@ -1030,15 +1040,12 @@ events.prototype.clickQuickShop = function(x, y) {
////// 快捷商店界面时,按下某个键的操作 //////
events.prototype.keyDownQuickShop = function (keycode) {
var shopList = core.status.shops, keys = Object.keys(shopList);
if (keycode==38) {
core.status.event.selection--;
if (core.status.event.selection<0) core.status.event.selection=0;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
if (keycode==40) {
core.status.event.selection++;
if (core.status.event.selection>keys.length) core.status.event.selection=keys.length;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
}
@ -1330,7 +1337,7 @@ events.prototype.clickSwitchs = function (x,y) {
break;
case 5:
core.status.event.selection=0;
core.ui.drawSettings(false);
core.ui.drawSettings();
break;
}
}
@ -1338,17 +1345,12 @@ events.prototype.clickSwitchs = function (x,y) {
////// 系统设置界面时,按下某个键的操作 //////
events.prototype.keyDownSwitchs = function (keycode) {
var choices = [
"背景音乐", "背景音效", "战斗动画", "怪物显伤", "领域显伤", "返回主菜单"
];
if (keycode==38) {
core.status.event.selection--;
if (core.status.event.selection<0) core.status.event.selection=0;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
if (keycode==40) {
core.status.event.selection++;
if (core.status.event.selection>=choices.length) core.status.event.selection=choices.length-1;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
}
@ -1357,7 +1359,7 @@ events.prototype.keyDownSwitchs = function (keycode) {
events.prototype.keyUpSwitchs = function (keycode) {
if (keycode==27 || keycode==88) {
core.status.event.selection=0;
core.ui.drawSettings(false);
core.ui.drawSettings();
return;
}
var choices = [
@ -1400,7 +1402,7 @@ events.prototype.clickSettings = function (x,y) {
core.restart();
}, function () {
core.status.event.selection=3;
core.ui.drawSettings(false);
core.ui.drawSettings();
});
break;
case 4:
@ -1419,17 +1421,12 @@ events.prototype.clickSettings = function (x,y) {
////// 系统菜单栏界面时,按下某个键的操作 //////
events.prototype.keyDownSettings = function (keycode) {
var choices = [
"系统设置", "快捷商店", "同步存档", "重新开始", "操作帮助", "关于本塔", "返回游戏"
];
if (keycode==38) {
core.status.event.selection--;
if (core.status.event.selection<0) core.status.event.selection=0;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
if (keycode==40) {
core.status.event.selection++;
if (core.status.event.selection>=choices.length) core.status.event.selection=choices.length-1;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
}
@ -1477,7 +1474,7 @@ events.prototype.clickSyncSave = function (x,y) {
break;
case 3:
core.status.event.selection=2;
core.ui.drawSettings(false);
core.ui.drawSettings();
break;
}
@ -1487,17 +1484,12 @@ events.prototype.clickSyncSave = function (x,y) {
////// 同步存档界面时,按下某个键的操作 //////
events.prototype.keyDownSyncSave = function (keycode) {
var choices = [
"同步存档到服务器", "从服务器加载存档", "清空本地存档", "返回主菜单"
];
if (keycode==38) {
core.status.event.selection--;
if (core.status.event.selection<0) core.status.event.selection=0;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
if (keycode==40) {
core.status.event.selection++;
if (core.status.event.selection>=choices.length) core.status.event.selection=choices.length-1;
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
}
}
@ -1506,7 +1498,7 @@ events.prototype.keyDownSyncSave = function (keycode) {
events.prototype.keyUpSyncSave = function (keycode) {
if (keycode==27 || keycode==88) {
core.status.event.selection=2;
core.ui.drawSettings(false);
core.ui.drawSettings();
return;
}
var choices = [

View File

@ -257,6 +257,8 @@ ui.prototype.drawChoices = function(content, choices) {
if (choices.length>0) {
if (!core.isset(core.status.event.selection)) core.status.event.selection=0;
if (core.status.event.selection<0) core.status.event.selection=0;
if (core.status.event.selection>=choices.length) core.status.event.selection=choices.length-1;
var len = core.canvas.ui.measureText(core.replaceText(choices[core.status.event.selection].text || choices[core.status.event.selection])).width;
core.strokeRect('ui', 208-len/2-5, choice_top + 32 * core.status.event.selection - 20, len+10, 28, "#FFD700", 2);
}
@ -271,7 +273,8 @@ ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) {
core.status.event.data = {'yes': yesCallback, 'no': noCallback};
core.status.event.ui = text;
if (!core.isset(core.status.event.selection)) core.status.event.selection=1;
if (!core.isset(core.status.event.selection) || core.status.event.selection>1) core.status.event.selection=1;
if (core.status.event.selection<0) core.status.event.selection=0;
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
core.clearMap('ui', 0, 0, 416, 416);
@ -325,13 +328,11 @@ ui.prototype.drawSwitchs = function() {
"返回主菜单"
];
this.drawChoices(null, choices);
}
////// 绘制系统菜单栏 //////
ui.prototype.drawSettings = function (need) {
if (!core.checkStatus('settings', need))
return;
ui.prototype.drawSettings = function () {
core.status.event.id = 'settings';
this.drawChoices(null, [
"系统设置", "快捷商店", "同步存档", "重新开始", "操作帮助", "关于本塔", "返回游戏"
@ -339,9 +340,7 @@ ui.prototype.drawSettings = function (need) {
}
////// 绘制快捷商店选择栏 //////
ui.prototype.drawQuickShop = function (need) {
if (core.isset(need) && !core.checkStatus('selectShop', need))
return;
ui.prototype.drawQuickShop = function () {
core.status.event.id = 'selectShop';

View File

@ -338,7 +338,7 @@ main.statusBar.image.toolbox.onclick = function () {
////// 点击状态栏中的快捷商店时 //////
main.statusBar.image.shop.onclick = function () {
if (main.core.isPlaying())
main.core.ui.drawQuickShop(true);
main.core.openQuickShop(true);
}
////// 点击状态栏中的存档按钮时 //////
@ -356,7 +356,7 @@ main.statusBar.image.load.onclick = function () {
////// 点击状态栏中的系统菜单时 //////
main.statusBar.image.settings.onclick = function () {
if (main.core.isPlaying())
main.core.ui.drawSettings(true);
main.core.openSettings(true);
}
////// 点击“开始游戏”时 //////