全键盘操作
This commit is contained in:
parent
458c6a6498
commit
f88a160064
235
libs/core.js
235
libs/core.js
@ -77,15 +77,17 @@ function core() {
|
||||
'moveStepBeforeStop': [],
|
||||
|
||||
// 勇士状态;中心对称飞行器
|
||||
'usingCenterFly':false,
|
||||
|
||||
// event事件
|
||||
'savePage': null,
|
||||
'saveIndex': null,
|
||||
'shops': {},
|
||||
'event': {
|
||||
'id': null,
|
||||
'data': null
|
||||
'data': null,
|
||||
'selection': null,
|
||||
'ui': null,
|
||||
},
|
||||
'usingCenterFly':false,
|
||||
'openingDoor': null,
|
||||
|
||||
// 动画
|
||||
@ -300,7 +302,7 @@ core.prototype.clearStatus = function() {
|
||||
core.resize(main.dom.body.clientWidth, main.dom.body.clientHeight);
|
||||
}
|
||||
|
||||
core.prototype.resetStatus = function(hero, hard, floorId, flags, maps) {
|
||||
core.prototype.resetStatus = function(hero, hard, floorId, maps) {
|
||||
|
||||
// 停止各个Timeout和Interval
|
||||
for (var i in core.interval) {
|
||||
@ -318,19 +320,16 @@ core.prototype.resetStatus = function(hero, hard, floorId, flags, maps) {
|
||||
// 初始化人物属性
|
||||
core.status.hero = core.clone(hero);
|
||||
core.status.hard = hard;
|
||||
if (core.isset(flags))
|
||||
core.flags = core.clone(flags);
|
||||
// 保存页面
|
||||
core.status.savePage = core.getLocalStorage('savePage', 0);
|
||||
// 保存的Index
|
||||
core.status.saveIndex = core.getLocalStorage('saveIndex', 1);
|
||||
|
||||
core.resize(main.dom.body.clientWidth, main.dom.body.clientHeight);
|
||||
|
||||
}
|
||||
|
||||
core.prototype.startGame = function (hard, callback) {
|
||||
console.log('开始游戏');
|
||||
|
||||
core.resetStatus(core.firstData.hero, hard, core.firstData.floorId, core.flags, core.initStatus.maps);
|
||||
core.resetStatus(core.firstData.hero, hard, core.firstData.floorId, core.initStatus.maps);
|
||||
|
||||
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() {
|
||||
core.setHeroMoveTriggerInterval();
|
||||
@ -353,7 +352,7 @@ core.prototype.restart = function() {
|
||||
core.prototype.onkeyDown = function(e) {
|
||||
if (!core.isset(core.status.holdingKeys))core.status.holdingKeys=[];
|
||||
var isArrow={37:true,38:true,39:true,40:true}[e.keyCode]
|
||||
if(isArrow){
|
||||
if(isArrow && !core.status.lockControl){
|
||||
for(var ii =0;ii<core.status.holdingKeys.length;ii++){
|
||||
if (core.status.holdingKeys[ii]===e.keyCode){
|
||||
return;
|
||||
@ -368,7 +367,7 @@ core.prototype.onkeyDown = function(e) {
|
||||
|
||||
core.prototype.onkeyUp = function(e) {
|
||||
var isArrow={37:true,38:true,39:true,40:true}[e.keyCode]
|
||||
if(isArrow){
|
||||
if(isArrow && !core.status.lockControl){
|
||||
for(var ii =0;ii<core.status.holdingKeys.length;ii++){
|
||||
if (core.status.holdingKeys[ii]===e.keyCode){
|
||||
core.status.holdingKeys= core.status.holdingKeys.slice(0,ii).concat(core.status.holdingKeys.slice(ii+1));
|
||||
@ -391,28 +390,66 @@ core.prototype.pressKey = function (keyCode) {
|
||||
}
|
||||
|
||||
core.prototype.keyDown = function(keyCode) {
|
||||
if(!core.status.played) {
|
||||
return;
|
||||
}
|
||||
if(core.status.automaticRouting || core.status.automaticRouted) {
|
||||
core.stopAutomaticRoute();
|
||||
}
|
||||
if (core.status.lockControl) {
|
||||
// Ctrl跳过对话
|
||||
if (keyCode==17) {
|
||||
core.events.keyDownCtrl();
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id == 'action') {
|
||||
core.events.keyDownAction(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id == 'book') {
|
||||
if (keyCode==37) core.ui.drawEnemyBook(core.status.event.data - 1);
|
||||
else if (keyCode==39) core.ui.drawEnemyBook(core.status.event.data + 1);
|
||||
core.events.keyDownBook(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id == 'fly') {
|
||||
if (keyCode==38) core.ui.drawFly(core.status.event.data+1);
|
||||
else if (keyCode==40) core.ui.drawFly(core.status.event.data-1);
|
||||
core.events.keyDownFly(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='shop') {
|
||||
core.events.keyDownShop(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='selectShop') {
|
||||
core.events.keyDownQuickShop(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='toolbox') {
|
||||
core.events.keyDownToolbox(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='save' || core.status.event.id=='load') {
|
||||
core.events.keyDownSL(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='switchs') {
|
||||
core.events.keyDownSwitchs(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='settings') {
|
||||
core.events.keyDownSettings(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='syncSave') {
|
||||
core.events.keyDownSyncSave(keyCode);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
if (core.status.event.id == 'save' || core.status.event.id == 'load') {
|
||||
if (keyCode==37) core.ui.drawSLPanel(core.status.event.data-1);
|
||||
else if (keyCode==39) core.ui.drawSLPanel(core.status.event.data+1);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
return;
|
||||
}
|
||||
if(!core.status.played) {
|
||||
return;
|
||||
}
|
||||
switch(keyCode) {
|
||||
@ -428,7 +465,7 @@ core.prototype.keyDown = function(keyCode) {
|
||||
case 40:
|
||||
core.moveHero('down');
|
||||
break;
|
||||
case 51: // 快捷键3:飞
|
||||
case 13: case 32: case 51: // 快捷键3:飞
|
||||
// 因为加入了两次的检测机制,从keydown转移到keyup,同时保证位置信息正确,但以下情况会触发作图的bug:
|
||||
// 在鼠标的路线移动中使用飞,绿块会滞后一格,显示的位置不对,同时也不会倍以下的代码清除
|
||||
if (core.status.heroStop && core.hasItem('centerFly')) {
|
||||
@ -436,18 +473,18 @@ core.prototype.keyDown = function(keyCode) {
|
||||
if (core.canUseItem('centerFly')) {
|
||||
core.useItem('centerFly');
|
||||
core.clearMap('ui', core.getHeroLoc('x')*32,core.getHeroLoc('y')*32,32,32);
|
||||
|
||||
}
|
||||
else {
|
||||
core.drawTip('当前不能使用中心对称飞行器');
|
||||
core.clearMap('ui', (12-core.getHeroLoc('x'))*32,(12-core.getHeroLoc('y'))*32,32,32);
|
||||
}
|
||||
core.status.usingCenterFly = false;
|
||||
} else {
|
||||
} else if (keyCode==51) {
|
||||
core.status.usingCenterFly = true;
|
||||
var fillstyle = 'rgba(255,0,0,0.5)';
|
||||
if (core.canUseItem('centerFly')) fillstyle = 'rgba(0,255,0,0.5)';
|
||||
core.fillRect('ui',(12-core.getHeroLoc('x'))*32,(12-core.getHeroLoc('y'))*32,32,32,fillstyle);
|
||||
core.drawTip("请确认当前中心对称飞行器的位置");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -459,48 +496,70 @@ core.prototype.keyDown = function(keyCode) {
|
||||
}
|
||||
|
||||
core.prototype.keyUp = function(keyCode) {
|
||||
if(!core.status.played)
|
||||
return;
|
||||
|
||||
if (core.status.lockControl) {
|
||||
if (core.status.event.id == 'book' && (keyCode==27 || keyCode==88))
|
||||
core.ui.closePanel(true);
|
||||
if (core.status.event.id == 'fly' && (keyCode==71 || keyCode==27))
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'fly' && keyCode==13) {
|
||||
var index=core.status.hero.flyRange.indexOf(core.status.floorId);
|
||||
var stair=core.status.event.data<index?"upFloor":"downFloor";
|
||||
var floorId=core.status.event.data;
|
||||
core.ui.closePanel();
|
||||
core.changeFloor(core.status.hero.flyRange[floorId], stair);
|
||||
}
|
||||
if (core.status.event.id == 'save' && (keyCode==83 || keyCode==27))
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'load' && (keyCode==68 || keyCode==27))
|
||||
core.ui.closePanel();
|
||||
if ((core.status.event.id == 'settings' || core.status.event.id == 'selectShop') && keyCode==27)
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'selectShop' && keyCode==75)
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'shop' && keyCode==27) {
|
||||
core.status.boxAnimateObjs = [];
|
||||
core.setBoxAnimate();
|
||||
if (core.status.event.data.fromList)
|
||||
core.ui.drawQuickShop();
|
||||
else core.ui.closePanel();
|
||||
}
|
||||
if (core.status.event.id == 'toolbox' && (keyCode==84 || keyCode==27))
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'about' && (keyCode==13 || keyCode==32))
|
||||
core.ui.closePanel();
|
||||
if (core.status.event.id == 'text' && (keyCode==13 || keyCode==32))
|
||||
core.drawText();
|
||||
if (core.status.event.id == 'action' && core.isset(core.status.event.data.current)
|
||||
&& core.status.event.data.type=='text' && (keyCode==13 || keyCode==32))
|
||||
core.events.doAction();
|
||||
core.status.holdingKeys = [];
|
||||
|
||||
|
||||
|
||||
// 全键盘操作部分
|
||||
if (core.status.event.id == 'text' && (keyCode==13 || keyCode==32)) {
|
||||
core.drawText();
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='confirmBox') {
|
||||
core.events.keyUpConfirmBox(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id == 'action') {
|
||||
core.events.keyUpAction(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='about' && (keyCode==13 || keyCode==32)) {
|
||||
core.events.clickAbout();
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='book') {
|
||||
core.events.keyUpBook(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='fly') {
|
||||
core.events.keyUpFly(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='shop') {
|
||||
core.events.keyUpShop(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='selectShop') {
|
||||
core.events.keyUpQuickShop(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='toolbox') {
|
||||
core.events.keyUpToolbox(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='save' || core.status.event.id=='load') {
|
||||
core.events.keyUpSL(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='switchs') {
|
||||
core.events.keyUpSwitchs(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='settings') {
|
||||
core.events.keyUpSettings(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='syncSave') {
|
||||
core.events.keyUpSyncSave(keyCode);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(!core.status.played)
|
||||
return;
|
||||
|
||||
switch (keyCode) {
|
||||
case 27: // ESC
|
||||
@ -680,7 +739,6 @@ core.prototype.onclick = function (x, y, stepPostfix) {
|
||||
if (core.canUseItem('centerFly')) {
|
||||
core.useItem('centerFly');
|
||||
core.clearMap('ui', core.getHeroLoc('x')*32,core.getHeroLoc('y')*32,32,32);
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@ -747,19 +805,13 @@ core.prototype.onclick = function (x, y, stepPostfix) {
|
||||
|
||||
// 选项
|
||||
if (core.status.event.id == 'confirmBox') {
|
||||
if ((x == 4 || x == 5) && y == 7 && core.isset(core.status.event.data.yes))
|
||||
core.status.event.data.yes();
|
||||
if ((x == 7 || x == 8) && y == 7 && core.isset(core.status.event.data.no))
|
||||
core.status.event.data.no();
|
||||
core.events.clickConfirmBox(x,y);
|
||||
return;
|
||||
}
|
||||
|
||||
// 关于
|
||||
if (core.status.event.id == 'about') {
|
||||
if (core.isPlaying())
|
||||
core.ui.closePanel(false);
|
||||
else
|
||||
core.showStartAnimate();
|
||||
core.events.clickAbout(x,y);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -776,26 +828,8 @@ core.prototype.onclick = function (x, y, stepPostfix) {
|
||||
|
||||
// 同步存档
|
||||
if (core.status.event.id == 'syncSave') {
|
||||
if (x>=4 && x<=8) {
|
||||
if (y==5) {
|
||||
core.syncSave("save");
|
||||
}
|
||||
if (y==6) {
|
||||
core.syncSave("load");
|
||||
}
|
||||
}
|
||||
if (x>=5 && x<=7) {
|
||||
if (y==7) {
|
||||
core.ui.drawConfirmBox("你确定要清空所有本地存档吗?", function() {
|
||||
localStorage.clear();
|
||||
core.drawText("\t[操作成功]你的本地所有存档已被清空。");
|
||||
}, function() {
|
||||
core.ui.drawSettings(false);
|
||||
})
|
||||
}
|
||||
if (y==8)
|
||||
core.ui.drawSettings(false);
|
||||
}
|
||||
core.events.clickSyncSave(x,y);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
@ -819,8 +853,8 @@ core.prototype.onmousewheel = function (direct) {
|
||||
|
||||
// 存读档
|
||||
if (core.status.lockControl && (core.status.event.id == 'save' || core.status.event.id == 'load')) {
|
||||
if (direct==1) core.ui.drawSLPanel(core.status.event.data - 1);
|
||||
if (direct==-1) core.ui.drawSLPanel(core.status.event.data + 1);
|
||||
if (direct==1) core.ui.drawSLPanel(core.status.event.data - 6);
|
||||
if (direct==-1) core.ui.drawSLPanel(core.status.event.data + 6);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2900,7 +2934,7 @@ core.prototype.openToolbox = function (need) {
|
||||
core.prototype.save = function(need) {
|
||||
if (!core.checkStatus('save', need))
|
||||
return;
|
||||
core.ui.drawSLPanel(core.status.savePage);
|
||||
core.ui.drawSLPanel(core.status.saveIndex);
|
||||
}
|
||||
|
||||
core.prototype.load = function (need) {
|
||||
@ -2910,22 +2944,22 @@ core.prototype.load = function (need) {
|
||||
core.status.event = {'id': 'load', 'data': null};
|
||||
core.status.lockControl = true;
|
||||
core.dom.startPanel.style.display = 'none';
|
||||
var page = core.getLocalStorage('savePage', 0);
|
||||
core.ui.drawSLPanel(page);
|
||||
core.ui.drawSLPanel(core.getLocalStorage('saveIndex', 1));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!core.checkStatus('load', need))
|
||||
return;
|
||||
core.ui.drawSLPanel(core.status.savePage);
|
||||
core.ui.drawSLPanel(core.status.saveIndex);
|
||||
}
|
||||
|
||||
core.prototype.doSL = function (id, type) {
|
||||
core.status.saveIndex=id;
|
||||
if (type=='save') {
|
||||
if (core.saveData("save"+id)) {
|
||||
core.ui.closePanel();
|
||||
core.drawTip('存档成功!');
|
||||
core.setLocalStorage('savePage', core.status.savePage);
|
||||
core.setLocalStorage('saveIndex', core.status.saveIndex);
|
||||
}
|
||||
else {
|
||||
core.drawTip('存储空间不足,请覆盖已有的存档或在菜单栏中进行清理');
|
||||
@ -2944,7 +2978,8 @@ core.prototype.doSL = function (id, type) {
|
||||
}
|
||||
core.ui.closePanel();
|
||||
core.loadData(data, function() {
|
||||
core.setLocalStorage('savePage', core.status.savePage);
|
||||
core.status.saveIndex=id;
|
||||
core.setLocalStorage('saveIndex', core.status.saveIndex);
|
||||
core.drawTip("读档成功");
|
||||
});
|
||||
return;
|
||||
@ -2953,6 +2988,7 @@ core.prototype.doSL = function (id, type) {
|
||||
|
||||
core.prototype.syncSave = function(type) {
|
||||
if (type=='save') {
|
||||
core.status.event.selection=1;
|
||||
core.ui.drawConfirmBox("你确定要将本地存档同步到服务器吗?", function(){
|
||||
// console.log("同步存档...");
|
||||
core.ui.drawWaiting("正在同步,请稍后...");
|
||||
@ -2999,11 +3035,12 @@ core.prototype.syncSave = function(type) {
|
||||
}
|
||||
xhr.send(formData);
|
||||
}, function() {
|
||||
core.status.event.selection=0;
|
||||
core.ui.drawSyncSave();
|
||||
})
|
||||
}
|
||||
else if (type=='load') {
|
||||
|
||||
core.status.event.selection=1;
|
||||
core.ui.drawConfirmBox("你确定要从服务器加载存档吗?\n该操作将覆盖所有本地存档且不可逆!", function(){
|
||||
var id = prompt("请输入存档编号:");
|
||||
if (id==null || id=="") {
|
||||
@ -3070,6 +3107,7 @@ core.prototype.syncSave = function(type) {
|
||||
}
|
||||
xhr.send(formData);
|
||||
}, function() {
|
||||
core.status.event.selection=1;
|
||||
core.ui.drawSyncSave();
|
||||
})
|
||||
}
|
||||
@ -3083,7 +3121,6 @@ core.prototype.saveData = function(dataId) {
|
||||
'hard': core.status.hard,
|
||||
'maps': core.maps.save(core.status.maps),
|
||||
'shops': {},
|
||||
'flags': core.flags,
|
||||
'version': core.firstData.version,
|
||||
"time": new Date().getTime()
|
||||
};
|
||||
@ -3101,7 +3138,7 @@ core.prototype.saveData = function(dataId) {
|
||||
|
||||
core.prototype.loadData = function (data, callback) {
|
||||
|
||||
core.resetStatus(data.hero, data.hard, data.floorId, data.flags, core.maps.load(data.maps));
|
||||
core.resetStatus(data.hero, data.hard, data.floorId, core.maps.load(data.maps));
|
||||
|
||||
// load shop times
|
||||
for (var shop in core.status.shops) {
|
||||
|
||||
@ -78,7 +78,7 @@ data.prototype.init = function() {
|
||||
{"text": "攻击+5", "need": "30", "effect": "status:atk+=5"},
|
||||
{"text": "防御+5", "need": "30", "effect": "status:def+=5"},
|
||||
]
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
// 各种数值;一些数值可以在这里设置
|
||||
|
||||
584
libs/events.js
584
libs/events.js
@ -66,7 +66,23 @@ events.prototype.startGame = function (hard) {
|
||||
|
||||
core.hideStartAnimate(function() {
|
||||
core.drawText(core.clone(core.firstData.startText), function() {
|
||||
core.status.event.selection = core.flags.battleAnimate?0:1;
|
||||
core.ui.drawConfirmBox("你想开启战斗动画吗?\n之后可以在菜单栏中开启或关闭。\n(强烈建议新手开启此项)", function() {
|
||||
console.log("1234");
|
||||
core.flags.battleAnimate=true;
|
||||
core.startGame(hard);
|
||||
core.events.setInitData(hard);
|
||||
}, function() {
|
||||
core.flags.battleAnimate=false;
|
||||
core.startGame(hard);
|
||||
core.events.setInitData(hard);
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
////// 简单难度设置初始福利 //////
|
||||
events.prototype.setInitData = function (hard) {
|
||||
if (hard=='Easy') { // 简单难度
|
||||
core.setFlag('hard', 1); // 可以用flag:hard来获得当前难度
|
||||
// 可以在此设置一些初始福利,比如设置初始生命值可以调用:
|
||||
@ -78,8 +94,6 @@ events.prototype.startGame = function (hard) {
|
||||
if (hard=='Hard') { // 困难难度
|
||||
core.setFlag('hard', 3); // 可以用flag:hard来获得当前难度
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
////// 游戏结束事件 //////
|
||||
@ -166,6 +180,7 @@ events.prototype.doAction = function() {
|
||||
case "tip":
|
||||
core.drawTip(core.replaceText(data.text));
|
||||
core.events.doAction();
|
||||
break;
|
||||
case "show": // 显示
|
||||
if (core.isset(data.time) && data.time>0 && (!core.isset(data.floorId) || data.floorId==core.status.floorId)) {
|
||||
core.animateBlock(data.loc[0],data.loc[1],'show', data.time, function () {
|
||||
@ -361,7 +376,7 @@ events.prototype.doAction = function() {
|
||||
break;
|
||||
default:
|
||||
core.status.event.data.type='text';
|
||||
core.ui.drawTextBox("\t[警告,]出错啦!\n"+data.type+" 事件不被支持...");
|
||||
core.ui.drawTextBox("\t[警告]出错啦!\n"+data.type+" 事件不被支持...");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -383,9 +398,14 @@ events.prototype.openShop = function(shopId, needVisited) {
|
||||
}
|
||||
shop.visited = true;
|
||||
|
||||
var selection = core.status.event.selection;
|
||||
core.ui.closePanel();
|
||||
core.lockControl();
|
||||
core.status.event = {'id': 'shop', 'data': {'id': shopId, 'shop': shop}};
|
||||
// core.status.event = {'id': 'shop', 'data': {'id': shopId, 'shop': shop}};
|
||||
core.status.event.id = 'shop';
|
||||
core.status.event.data = {'id': shopId, 'shop': shop};
|
||||
core.status.event.selection = selection;
|
||||
|
||||
// 拼词
|
||||
var content = "\t["+shop.name+","+shop.icon+"]";
|
||||
var times = shop.times, need=eval(shop.need);
|
||||
@ -402,9 +422,9 @@ events.prototype.openShop = function(shopId, needVisited) {
|
||||
var text = choice.text;
|
||||
if (core.isset(choice.need))
|
||||
text += "("+eval(choice.need)+use+")"
|
||||
choices.push({"text": text});
|
||||
choices.push(text);
|
||||
}
|
||||
choices.push({"text": "离开"});
|
||||
choices.push("离开");
|
||||
core.ui.drawChoices(content, choices);
|
||||
}
|
||||
|
||||
@ -462,6 +482,7 @@ events.prototype.useItem = function(itemId) {
|
||||
var fillstyle = 'rgba(255,0,0,0.5)';
|
||||
if (core.canUseItem('centerFly')) fillstyle = 'rgba(0,255,0,0.5)';
|
||||
core.fillRect('ui',(12-core.getHeroLoc('x'))*32,(12-core.getHeroLoc('y'))*32,32,32,fillstyle);
|
||||
core.drawTip("请确认当前中心对称飞行器的位置");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -602,6 +623,46 @@ events.prototype.afterLoadData = function(data) {
|
||||
/*********** 界面上的点击事件 ***************/
|
||||
/******************************************/
|
||||
|
||||
events.prototype.keyDownCtrl = function () {
|
||||
if (core.status.event.id=='text') {
|
||||
core.drawText();
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='action' && core.status.event.data.type=='text') {
|
||||
this.doAction();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.keyUpConfirmBox = function (keycode) {
|
||||
if (keycode==37) {
|
||||
core.status.event.selection=0;
|
||||
core.ui.drawConfirmBox(core.status.event.ui, core.status.event.data.yes, core.status.event.data.no);
|
||||
}
|
||||
|
||||
if (keycode==39) {
|
||||
core.status.event.selection=1;
|
||||
core.ui.drawConfirmBox(core.status.event.ui, core.status.event.data.yes, core.status.event.data.no);
|
||||
}
|
||||
|
||||
if (keycode==13 || keycode==32) {
|
||||
if (core.status.event.selection==0 && core.isset(core.status.event.data.yes)) {
|
||||
core.status.event.selection=null;
|
||||
core.status.event.data.yes();
|
||||
}
|
||||
if (core.status.event.selection==1 && core.isset(core.status.event.data.no)) {
|
||||
core.status.event.selection=null;
|
||||
core.status.event.data.no();
|
||||
}
|
||||
}
|
||||
}
|
||||
events.prototype.clickConfirmBox = function (x,y) {
|
||||
if ((x == 4 || x == 5) && y == 7 && core.isset(core.status.event.data.yes))
|
||||
core.status.event.data.yes();
|
||||
if ((x == 7 || x == 8) && y == 7 && core.isset(core.status.event.data.no))
|
||||
core.status.event.data.no();
|
||||
}
|
||||
|
||||
// 正在处理事件时的点击操作...
|
||||
events.prototype.clickAction = function (x,y) {
|
||||
|
||||
@ -625,6 +686,42 @@ events.prototype.clickAction = function (x,y) {
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.keyDownAction = function (keycode) {
|
||||
if (core.status.event.data.type=='choices') {
|
||||
var data = core.status.event.data.current;
|
||||
var choices = data.choices;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.keyUpAction = function (keycode) {
|
||||
if (core.status.event.data.type=='text' && (keycode==13 || keycode==32)) {
|
||||
this.doAction();
|
||||
return;
|
||||
}
|
||||
if (core.status.event.data.type=='choices') {
|
||||
var data = core.status.event.data.current;
|
||||
var choices = data.choices;
|
||||
if (choices.length>0) {
|
||||
if (keycode==13 || keycode==32) {
|
||||
this.insertAction(choices[core.status.event.selection].action);
|
||||
this.doAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 怪物手册
|
||||
events.prototype.clickBook = function(x,y) {
|
||||
// 上一页
|
||||
@ -642,6 +739,12 @@ events.prototype.clickBook = function(x,y) {
|
||||
return;
|
||||
}
|
||||
|
||||
events.prototype.keyDownBook = function (keycode) {
|
||||
if (keycode==37 || keycode==38) core.ui.drawEnemyBook(core.status.event.data - 1);
|
||||
else if (keycode==39 || keycode==40) core.ui.drawEnemyBook(core.status.event.data + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
// 飞行器
|
||||
events.prototype.clickFly = function(x,y) {
|
||||
if ((x==10 || x==11) && y==9) core.ui.drawFly(core.status.event.data-1);
|
||||
@ -657,6 +760,27 @@ events.prototype.clickFly = function(x,y) {
|
||||
return;
|
||||
}
|
||||
|
||||
events.prototype.keyDownFly = function (keycode) {
|
||||
if (keycode==37 || keycode==38) core.ui.drawFly(core.status.event.data+1);
|
||||
else if (keycode==39 || keycode==40) core.ui.drawFly(core.status.event.data-1);
|
||||
return;
|
||||
}
|
||||
|
||||
events.prototype.keyUpFly = function (keycode) {
|
||||
if (keycode==71 || keycode==27)
|
||||
core.ui.closePanel();
|
||||
if (keycode==13 || keycode==32)
|
||||
this.clickFly(5,5);
|
||||
return;
|
||||
}
|
||||
|
||||
events.prototype.keyUpBook = function (keycode) {
|
||||
if (keycode==27 || keycode==88) {
|
||||
core.ui.closePanel(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 商店
|
||||
events.prototype.clickShop = function(x,y) {
|
||||
var shop = core.status.event.data.shop;
|
||||
@ -709,14 +833,47 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.keyUpShop = function (keycode) {
|
||||
if (keycode==27) {
|
||||
if (core.status.event.data.fromList) {
|
||||
core.status.boxAnimateObjs = [];
|
||||
core.setBoxAnimate();
|
||||
core.ui.drawQuickShop();
|
||||
}
|
||||
else
|
||||
core.ui.closePanel();
|
||||
return;
|
||||
}
|
||||
var shop = core.status.event.data.shop;
|
||||
var choices = shop.choices;
|
||||
if (keycode==13 || keycode==32) {
|
||||
var topIndex = 6 - parseInt(choices.length / 2);
|
||||
this.clickShop(6, topIndex+core.status.event.selection);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 快捷商店
|
||||
events.prototype.clickQuickShop = function(x, y) {
|
||||
if (x >= 5 && x <= 7) {
|
||||
var shopList = core.status.shops, keys = Object.keys(shopList);
|
||||
var topIndex = 6 - parseInt((keys.length + 1) / 2);
|
||||
var exitIndex = 6 + parseInt((keys.length + 1) / 2);
|
||||
|
||||
if (y >= topIndex && y - topIndex < keys.length) {
|
||||
if (x >= 5 && x <= 7) {
|
||||
var topIndex = 6 - parseInt(keys.length / 2);
|
||||
if (y>=topIndex && y<topIndex+keys.length) {
|
||||
var reason = core.events.canUseQuickShop(y-topIndex);
|
||||
if (core.isset(reason)) {
|
||||
core.drawText(reason);
|
||||
@ -726,42 +883,146 @@ events.prototype.clickQuickShop = function(x, y) {
|
||||
if (core.status.event.id=='shop')
|
||||
core.status.event.data.fromList = true;
|
||||
}
|
||||
if (y == exitIndex) {
|
||||
// 离开
|
||||
else if (y==topIndex+keys.length)
|
||||
core.ui.closePanel();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.keyUpQuickShop = function (keycode) {
|
||||
if (keycode==27 || keycode==75) {
|
||||
core.ui.closePanel();
|
||||
return;
|
||||
}
|
||||
var shopList = core.status.shops, keys = Object.keys(shopList);
|
||||
if (keycode==13 || keycode==32) {
|
||||
var topIndex = 6 - parseInt(keys.length / 2);
|
||||
this.clickQuickShop(6, topIndex+core.status.event.selection);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 工具栏
|
||||
events.prototype.clickToolbox = function(x,y) {
|
||||
|
||||
// 返回
|
||||
if (x>=10 && x<=12 && y==12) {
|
||||
core.ui.closePanel(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var items = null;
|
||||
|
||||
if (y>=4 && y<=7 && x!=12)
|
||||
items = Object.keys(core.status.hero.items.tools).sort();
|
||||
|
||||
if (y>=9 && y<=12 && x!=12)
|
||||
items = Object.keys(core.status.hero.items.constants).sort();
|
||||
|
||||
if (items==null) return;
|
||||
var index=0;
|
||||
if (y==4||y==5||y==9||y==10) index=parseInt(x/2);
|
||||
else index=6+parseInt(x/2);
|
||||
if (y>=9) index+=100;
|
||||
this.clickToolboxIndex(index);
|
||||
}
|
||||
|
||||
if (index>=items.length) return;
|
||||
itemId=items[index];
|
||||
|
||||
events.prototype.clickToolboxIndex = function(index) {
|
||||
var items = null;
|
||||
var ii=index;
|
||||
if (ii<100)
|
||||
items = Object.keys(core.status.hero.items.tools).sort();
|
||||
else {
|
||||
ii-=100;
|
||||
items = Object.keys(core.status.hero.items.constants).sort();
|
||||
}
|
||||
if (items==null) return;
|
||||
if (ii>=items.length) return;
|
||||
var itemId=items[ii];
|
||||
if (itemId==core.status.event.data) {
|
||||
core.events.useItem(itemId);
|
||||
}
|
||||
else {
|
||||
core.ui.drawToolbox(itemId);
|
||||
core.ui.drawToolbox(index);
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.keyDownToolbox = function (keycode) {
|
||||
if (!core.isset(core.status.event.data)) return;
|
||||
|
||||
var tools = Object.keys(core.status.hero.items.tools).sort();
|
||||
var constants = Object.keys(core.status.hero.items.constants).sort();
|
||||
var index=core.status.event.selection;
|
||||
|
||||
if (keycode==37) { // left
|
||||
if ((index>0 && index<100) || index>100) {
|
||||
this.clickToolboxIndex(index-1);
|
||||
return;
|
||||
}
|
||||
if (index==100 && tools.length>0) {
|
||||
this.clickToolboxIndex(tools.length-1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (keycode==38) { // up
|
||||
if ((index>5 && index<100) || index>105) {
|
||||
this.clickToolboxIndex(index-6);
|
||||
return;
|
||||
}
|
||||
if (index>=100 && index<=105) {
|
||||
if (tools.length>6) {
|
||||
this.clickToolboxIndex(Math.min(tools.length-1, index-100+6));
|
||||
}
|
||||
else if (tools.length>0) {
|
||||
this.clickToolboxIndex(Math.min(tools.length-1, index-100));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (keycode==39) { // right
|
||||
if ((index<tools.length-1) || (index>=100 && index<constants.length+100)) {
|
||||
this.clickToolboxIndex(index+1);
|
||||
return;
|
||||
}
|
||||
if (index==tools.length-1 && constants.length>0) {
|
||||
this.clickToolboxIndex(100);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (keycode==40) { // down
|
||||
if (index<=5) {
|
||||
if (tools.length>6) {
|
||||
this.clickToolboxIndex(Math.min(tools.length-1, index+6));
|
||||
}
|
||||
else if (constants.length>0) {
|
||||
this.clickToolboxIndex(100+Math.min(constants.length-1, index));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (index>5 && index<100 && constants.length>0) {
|
||||
this.clickToolboxIndex(100+Math.min(constants.length-1, index-6));
|
||||
return;
|
||||
}
|
||||
if (index>=100 && index<=105 && constants.length>6) {
|
||||
this.clickToolboxIndex(Math.min(100+constants.length-1, index+6));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.keyUpToolbox = function (keycode) {
|
||||
if (keycode==84 || keycode==27) {
|
||||
core.ui.closePanel();
|
||||
return;
|
||||
}
|
||||
if (!core.isset(core.status.event.data)) return;
|
||||
|
||||
if (keycode==13 || keycode==32) {
|
||||
this.clickToolboxIndex(core.status.event.selection);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -769,11 +1030,11 @@ events.prototype.clickToolbox = function(x,y) {
|
||||
events.prototype.clickSL = function(x,y) {
|
||||
// 上一页
|
||||
if ((x == 3 || x == 4) && y == 12) {
|
||||
core.ui.drawSLPanel(core.status.event.data - 1);
|
||||
core.ui.drawSLPanel(core.status.event.data - 6);
|
||||
}
|
||||
// 下一页
|
||||
if ((x == 8 || x == 9) && y == 12) {
|
||||
core.ui.drawSLPanel(core.status.event.data + 1);
|
||||
core.ui.drawSLPanel(core.status.event.data + 6);
|
||||
}
|
||||
// 返回
|
||||
if (x>=10 && x<=12 && y==12) {
|
||||
@ -784,7 +1045,8 @@ events.prototype.clickSL = function(x,y) {
|
||||
return;
|
||||
}
|
||||
|
||||
var index=6*core.status.event.data+1;
|
||||
var page=parseInt((core.status.event.data-1)/6);
|
||||
var index=6*page+1;
|
||||
if (y>=1 && y<=4) {
|
||||
if (x>=1 && x<=3) core.doSL(index, core.status.event.id);
|
||||
if (x>=5 && x<=7) core.doSL(index+1, core.status.event.id);
|
||||
@ -797,78 +1059,264 @@ events.prototype.clickSL = function(x,y) {
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.keyDownSL = function(keycode) {
|
||||
if (keycode==37) { // left
|
||||
core.ui.drawSLPanel(core.status.event.data - 1);
|
||||
return;
|
||||
}
|
||||
if (keycode==38) { // up
|
||||
if ((core.status.event.data-1)%6>=3)
|
||||
core.ui.drawSLPanel(core.status.event.data - 3);
|
||||
return;
|
||||
}
|
||||
if (keycode==39) { // right
|
||||
core.ui.drawSLPanel(core.status.event.data + 1);
|
||||
return;
|
||||
}
|
||||
if (keycode==40) { // down
|
||||
if ((core.status.event.data-1)%6<3)
|
||||
core.ui.drawSLPanel(core.status.event.data + 3);
|
||||
return;
|
||||
}
|
||||
if (keycode==33) { // PAGEUP
|
||||
core.ui.drawSLPanel(core.status.event.data - 6);
|
||||
return;
|
||||
}
|
||||
if (keycode==34) { // PAGEDOWN
|
||||
core.ui.drawSLPanel(core.status.event.data + 6);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.keyUpSL = function (keycode) {
|
||||
if (keycode==27 || (core.status.event.id == 'save' && keycode==83) || (core.status.event.id == 'load' && keycode==68)) {
|
||||
core.ui.closePanel();
|
||||
return;
|
||||
}
|
||||
if (keycode==13 || keycode==32) {
|
||||
core.doSL(core.status.event.data, core.status.event.id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.clickSwitchs = function (x,y) {
|
||||
if (x<5 || x>7) return;
|
||||
if (y==4) {
|
||||
var choices = [
|
||||
"背景音乐", "战斗动画", "怪物显伤", "领域显伤", "返回主菜单"
|
||||
];
|
||||
var topIndex = 6 - parseInt((choices.length - 1) / 2);
|
||||
if (y>=topIndex && y<topIndex+choices.length) {
|
||||
var selection = y-topIndex;
|
||||
switch (selection) {
|
||||
case 0:
|
||||
if (core.musicStatus.isIOS) {
|
||||
core.drawTip("iOS设备不支持播放音乐");
|
||||
return;
|
||||
}
|
||||
core.changeSoundStatus();
|
||||
core.ui.drawSwitchs();
|
||||
}
|
||||
if (y==5) {
|
||||
break;
|
||||
case 1:
|
||||
core.flags.battleAnimate=!core.flags.battleAnimate;
|
||||
core.ui.drawSwitchs();
|
||||
}
|
||||
if (y==6) {
|
||||
break;
|
||||
case 2:
|
||||
core.flags.displayEnemyDamage=!core.flags.displayEnemyDamage;
|
||||
core.updateFg();
|
||||
core.ui.drawSwitchs();
|
||||
}
|
||||
if (y==7) {
|
||||
break;
|
||||
case 3:
|
||||
core.flags.displayExtraDamage=!core.flags.displayExtraDamage;
|
||||
core.updateFg();
|
||||
core.ui.drawSwitchs();
|
||||
}
|
||||
if (y==8) {
|
||||
break;
|
||||
case 4:
|
||||
core.status.event.selection=0;
|
||||
core.ui.drawSettings(false);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.keyUpSwitchs = function (keycode) {
|
||||
if (keycode==27) {
|
||||
core.status.event.selection=0;
|
||||
core.ui.drawSettings(false);
|
||||
return;
|
||||
}
|
||||
var choices = [
|
||||
"背景音乐", "战斗动画", "怪物显伤", "领域显伤", "返回主菜单"
|
||||
];
|
||||
if (keycode==13 || keycode==32) {
|
||||
var topIndex = 6 - parseInt((choices.length - 1) / 2);
|
||||
this.clickSwitchs(6, topIndex+core.status.event.selection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 菜单栏
|
||||
events.prototype.clickSettings = function (x,y) {
|
||||
if (x<5 || x>7) return;
|
||||
if (y == 3) {
|
||||
var choices = [
|
||||
"系统设置", "快捷商店", "同步存档", "重新开始", "关于本塔", "返回游戏"
|
||||
];
|
||||
var topIndex = 6 - parseInt((choices.length - 1) / 2);
|
||||
if (y>=topIndex && y<topIndex+choices.length) {
|
||||
var selection = y-topIndex;
|
||||
|
||||
switch (selection) {
|
||||
case 0:
|
||||
core.status.event.selection=0;
|
||||
core.ui.drawSwitchs();
|
||||
}
|
||||
if (y==4) {
|
||||
/*
|
||||
core.flags.battleAnimate=!core.flags.battleAnimate;
|
||||
core.setLocalStorage('battleAnimate', core.flags.battleAnimate);
|
||||
core.ui.drawSettings(false);
|
||||
*/
|
||||
this.decreaseHard();
|
||||
}
|
||||
if (y == 5) core.ui.drawQuickShop();
|
||||
// if (y == 5) this.decreaseHard();
|
||||
if (y == 6) {
|
||||
break;
|
||||
case 1:
|
||||
core.status.event.selection=0;
|
||||
core.ui.drawQuickShop();
|
||||
break;
|
||||
case 2:
|
||||
core.status.event.selection=0;
|
||||
core.ui.drawSyncSave();
|
||||
}
|
||||
/*
|
||||
if (y == 6) {
|
||||
core.ui.drawConfirmBox("你确定要清空所有本地存档吗?", function() {
|
||||
localStorage.clear();
|
||||
core.drawText("\t[操作成功]你的本地所有存档已被清空。");
|
||||
}, function() {
|
||||
core.ui.drawSettings(false);
|
||||
})
|
||||
}
|
||||
*/
|
||||
if (y == 7) {
|
||||
break;
|
||||
case 3:
|
||||
core.status.event.selection=1;
|
||||
core.ui.drawConfirmBox("你确定要重新开始吗?", function () {
|
||||
core.ui.closePanel();
|
||||
core.restart();
|
||||
}, function () {
|
||||
core.status.event.selection=3;
|
||||
core.ui.drawSettings(false);
|
||||
});
|
||||
}
|
||||
if (y==8) {
|
||||
break;
|
||||
case 4:
|
||||
core.ui.drawAbout();
|
||||
// core.debug();
|
||||
break;
|
||||
case 5:
|
||||
core.ui.closePanel();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
if (y == 9) core.ui.closePanel();
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.keyUpSettings = function (keycode) {
|
||||
if (keycode==27) {
|
||||
core.ui.closePanel();
|
||||
return;
|
||||
}
|
||||
var choices = [
|
||||
"系统设置", "快捷商店", "同步存档", "重新开始", "关于本塔", "返回游戏"
|
||||
];
|
||||
if (keycode==13 || keycode==32) {
|
||||
var topIndex = 6 - parseInt((choices.length - 1) / 2);
|
||||
this.clickSettings(6, topIndex+core.status.event.selection);
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.clickSyncSave = function (x,y) {
|
||||
if (x<5 || x>7) return;
|
||||
var choices = [
|
||||
"同步存档到服务器", "从服务器加载存档", "清空本地存档", "返回主菜单"
|
||||
];
|
||||
var topIndex = 6 - parseInt((choices.length - 1) / 2);
|
||||
if (y>=topIndex && y<topIndex+choices.length) {
|
||||
var selection = y-topIndex;
|
||||
switch (selection) {
|
||||
case 0:
|
||||
core.syncSave("save");
|
||||
break;
|
||||
case 1:
|
||||
core.syncSave("load");
|
||||
break;
|
||||
case 2:
|
||||
core.status.event.selection=1;
|
||||
core.ui.drawConfirmBox("你确定要清空所有本地存档吗?", function() {
|
||||
localStorage.clear();
|
||||
core.drawText("\t[操作成功]你的本地所有存档已被清空。");
|
||||
}, function() {
|
||||
core.status.event.selection=2;
|
||||
core.ui.drawSyncSave(false);
|
||||
})
|
||||
break;
|
||||
case 3:
|
||||
core.status.event.selection=2;
|
||||
core.ui.drawSettings(false);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.keyUpSyncSave = function (keycode) {
|
||||
if (keycode==27) {
|
||||
core.status.event.selection=2;
|
||||
core.ui.drawSettings(false);
|
||||
return;
|
||||
}
|
||||
var choices = [
|
||||
"同步存档到服务器", "从服务器加载存档", "清空本地存档", "返回主菜单"
|
||||
];
|
||||
if (keycode==13 || keycode==32) {
|
||||
var topIndex = 6 - parseInt((choices.length - 1) / 2);
|
||||
this.clickSyncSave(6, topIndex+core.status.event.selection);
|
||||
}
|
||||
}
|
||||
|
||||
events.prototype.clickAbout = function () {
|
||||
if (core.isPlaying())
|
||||
core.ui.closePanel(false);
|
||||
else
|
||||
core.showStartAnimate();
|
||||
}
|
||||
|
||||
/*********** 点击事件 END ***************/
|
||||
|
||||
169
libs/ui.js
169
libs/ui.js
@ -26,6 +26,8 @@ ui.prototype.closePanel = function (clearData) {
|
||||
core.unLockControl();
|
||||
core.status.event.data = null;
|
||||
core.status.event.id = null;
|
||||
core.status.event.selection = null;
|
||||
core.status.event.ui = null;
|
||||
}
|
||||
|
||||
|
||||
@ -144,6 +146,8 @@ ui.prototype.drawChoices = function(content, choices) {
|
||||
core.setAlpha('ui', 1);
|
||||
core.setFillStyle('ui', background);
|
||||
|
||||
core.status.event.ui = {"text": content, "choices": choices};
|
||||
|
||||
// Step 1: 计算长宽高
|
||||
var length = choices.length;
|
||||
var left=85, width = 416-2*left; // 宽度
|
||||
@ -258,10 +262,15 @@ ui.prototype.drawChoices = function(content, choices) {
|
||||
// 选项
|
||||
core.canvas.ui.textAlign = "center";
|
||||
for (var i = 0; i < choices.length; i++) {
|
||||
core.fillText('ui', core.replaceText(choices[i].text), 208, choice_top + 32 * i, "#FFFFFF", "bold 17px Verdana");
|
||||
core.fillText('ui', core.replaceText(choices[i].text || choices[i]), 208, choice_top + 32 * i, "#FFFFFF", "bold 17px Verdana");
|
||||
}
|
||||
|
||||
if (choices.length>0) {
|
||||
if (!core.isset(core.status.event.selection)) core.status.event.selection=0;
|
||||
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);
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -271,8 +280,13 @@ ui.prototype.drawChoices = function(content, choices) {
|
||||
* @param noCallback
|
||||
*/
|
||||
ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) {
|
||||
core.lockControl();
|
||||
|
||||
core.status.event.id = 'confirmBox';
|
||||
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;
|
||||
|
||||
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
|
||||
core.clearMap('ui', 0, 0, 416, 416);
|
||||
@ -291,7 +305,9 @@ ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) {
|
||||
var top = 140 - (lines-1)*30;
|
||||
var right = 416 - 2 * left, bottom = 416 - 140 - top;
|
||||
|
||||
if (core.isPlaying())
|
||||
core.fillRect('ui', left, top, right, bottom, background);
|
||||
if (core.isPlaying())
|
||||
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
|
||||
core.canvas.ui.textAlign = "center";
|
||||
for (var i in contents) {
|
||||
@ -300,6 +316,15 @@ ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) {
|
||||
|
||||
core.fillText('ui', "确定", 208 - 38, top + bottom - 35, "#FFFFFF", "bold 17px Verdana");
|
||||
core.fillText('ui', "取消", 208 + 38, top + bottom - 35);
|
||||
|
||||
var len=core.canvas.ui.measureText("确定").width;
|
||||
if (core.status.event.selection==0) {
|
||||
core.strokeRect('ui', 208-38-len/2-5, top+bottom-35-20, len+10, 28, "#FFD700", 2);
|
||||
}
|
||||
if (core.status.event.selection==1) {
|
||||
core.strokeRect('ui', 208+38-len/2-5, top+bottom-35-20, len+10, 28, "#FFD700", 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////// 绘制开关界面 //////
|
||||
@ -308,22 +333,15 @@ ui.prototype.drawSwitchs = function() {
|
||||
|
||||
core.status.event.id = 'switchs';
|
||||
|
||||
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
|
||||
core.clearMap('ui', 0, 0, 416, 416);
|
||||
core.setAlpha('ui', 1);
|
||||
core.setFillStyle('ui', background);
|
||||
var left = 97, top = 64 + 32, right = 416 - 2 * left, bottom = 416 - 2 * top;
|
||||
core.fillRect('ui', left, top, right, bottom, background);
|
||||
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
|
||||
var choices = [
|
||||
"背景音乐:"+(core.musicStatus.soundStatus ? "[ON]" : "[OFF]"),
|
||||
"战斗动画: " + (core.flags.battleAnimate ? "[ON]" : "[OFF]"),
|
||||
"怪物显伤: " + (core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"),
|
||||
"领域显伤: " + (core.flags.displayExtraDamage ? "[ON]" : "[OFF]"),
|
||||
"返回主菜单"
|
||||
];
|
||||
this.drawChoices(null, choices);
|
||||
|
||||
core.canvas.ui.textAlign = "center";
|
||||
core.fillText('ui', "背景音乐: " + (core.musicStatus.soundStatus ? "[ON]" : "[OFF]"), 208, top + 56, "#FFFFFF", "bold 17px Verdana");
|
||||
// core.fillText('ui', "背景音效" + (core.musicStatus.soundStatus ? "[ON]" : "[OFF]"), 208, top + 88, "#FFFFFF", "bold 17px Verdana")
|
||||
core.fillText('ui', "战斗动画: " + (core.flags.battleAnimate ? "[ON]" : "[OFF]"), 208, top + 88, "#FFFFFF", "bold 17px Verdana")
|
||||
core.fillText('ui', "怪物显伤: " + (core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"), 208, top + 120, "#FFFFFF", "bold 17px Verdana")
|
||||
core.fillText('ui', "领域显伤: " + (core.flags.displayExtraDamage ? "[ON]" : "[OFF]"), 208, top + 152, "#FFFFFF", "bold 17px Verdana")
|
||||
|
||||
core.fillText('ui', "返回上级菜单", 208, top + 184, "#FFFFFF", "bold 17px Verdana");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -334,57 +352,28 @@ ui.prototype.drawSettings = function (need) {
|
||||
if (!core.checkStatus('settings', need))
|
||||
return;
|
||||
|
||||
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
|
||||
core.clearMap('ui', 0, 0, 416, 416);
|
||||
core.setAlpha('ui', 1);
|
||||
core.setFillStyle('ui', background);
|
||||
var left = 97, top = 64, right = 416 - 2 * left, bottom = 416 - 2 * top;
|
||||
core.fillRect('ui', left, top, right, bottom, background);
|
||||
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
|
||||
|
||||
core.canvas.ui.textAlign = "center";
|
||||
core.fillText('ui', "系统设置", 208, top + 56, "#FFFFFF", "bold 17px Verdana");
|
||||
core.fillText('ui', "降低难度", 208, top + 88, "#FFFFFF", "bold 17px Verdana")
|
||||
core.fillText('ui', "快捷商店", 208, top + 120, "#FFFFFF", "bold 17px Verdana");
|
||||
core.fillText('ui', "同步存档", 208, top + 152, "#FFFFFF", "bold 17px Verdana");
|
||||
// core.fillText('ui', "清空存档", 208, top + 152, "#FFFFFF", "bold 17px Verdana");
|
||||
core.fillText('ui', "重新开始", 208, top + 184, "#FFFFFF", "bold 17px Verdana");
|
||||
core.fillText('ui', "关于本塔", 208, top + 216, "#FFFFFF", "bold 17px Verdana");
|
||||
core.fillText('ui', "返回游戏", 208, top + 248, "#FFFFFF", "bold 17px Verdana");
|
||||
|
||||
this.drawChoices(null, [
|
||||
"系统设置", "快捷商店", "同步存档", "重新开始", "关于本塔", "返回游戏"
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制“选择商店”窗口
|
||||
* @param need
|
||||
*/
|
||||
ui.prototype.drawQuickShop = function (need) {
|
||||
|
||||
if (core.isset(need) && !core.checkStatus('selectShop', need))
|
||||
return;
|
||||
|
||||
core.status.event.id = 'selectShop';
|
||||
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
|
||||
core.clearMap('ui', 0, 0, 416, 416);
|
||||
core.setAlpha('ui', 1);
|
||||
core.setFillStyle('ui', background);
|
||||
|
||||
var shopList = core.status.shops, keys = Object.keys(shopList);
|
||||
var len = keys.length + 1;
|
||||
if (len % 2 == 0) len++;
|
||||
|
||||
var left = 97, top = 208 - 32 - 16 * len, right = 416 - 2 * left, bottom = 416 - 2 * top;
|
||||
core.fillRect('ui', left, top, right, bottom, background);
|
||||
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
|
||||
|
||||
core.canvas.ui.textAlign = "center";
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
core.fillText('ui', shopList[keys[i]].textInList, 208, top + 56 + 32 * i, "#FFFFFF", "bold 17px Verdana");
|
||||
var choices = [];
|
||||
for (var i=0;i<keys.length;i++) {
|
||||
choices.push(shopList[keys[i]].textInList);
|
||||
}
|
||||
|
||||
core.fillText('ui', "返回游戏", 208, top + bottom - 40, "#FFFFFF", "bold 17px Verdana");
|
||||
choices.push("返回游戏");
|
||||
this.drawChoices(null, choices);
|
||||
}
|
||||
|
||||
|
||||
ui.prototype.drawBattleAnimate = function(monsterId, callback) {
|
||||
|
||||
// UI层
|
||||
@ -702,20 +691,11 @@ ui.prototype.drawWaiting = function(text) {
|
||||
ui.prototype.drawSyncSave = function () {
|
||||
|
||||
core.status.event.id = 'syncSave';
|
||||
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
|
||||
core.clearMap('ui', 0, 0, 416, 416);
|
||||
core.setAlpha('ui', 1);
|
||||
core.setFillStyle('ui', background);
|
||||
|
||||
var left = 97, top = 208 - 32 - 16 * 3, right = 416 - 2 * left, bottom = 416 - 2 * top + 32;
|
||||
core.fillRect('ui', left, top, right, bottom, background);
|
||||
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
|
||||
this.drawChoices(null, [
|
||||
"同步存档到服务器", "从服务器加载存档", "清空本地存档", "返回主菜单"
|
||||
]);
|
||||
|
||||
core.canvas.ui.textAlign = "center";
|
||||
core.fillText('ui', "同步存档到服务器", 208, top + 56, "#FFFFFF", "bold 17px Verdana");
|
||||
core.fillText('ui', "从服务器加载存档", 208, top + 56 + 32, "#FFFFFF", "bold 17px Verdana");
|
||||
core.fillText('ui', "清空本地存档", 208, top + 56 + 64, "#FFFFFF", "bold 17px Verdana");
|
||||
core.fillText('ui', "返回游戏", 208, top + bottom - 40);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -879,14 +859,26 @@ ui.prototype.drawFly = function(page) {
|
||||
this.drawThumbnail('ui', core.status.maps[floorId].blocks, 20, 100, 273);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制工具栏
|
||||
* @param selectId
|
||||
*/
|
||||
ui.prototype.drawToolbox = function(selectId) {
|
||||
ui.prototype.drawToolbox = function(index) {
|
||||
|
||||
if (!core.hasItem(selectId))
|
||||
selectId=null;
|
||||
var tools = Object.keys(core.status.hero.items.tools).sort();
|
||||
var constants = Object.keys(core.status.hero.items.constants).sort();
|
||||
|
||||
if (!core.isset(index)) {
|
||||
if (tools.length>0) index=0;
|
||||
else if (constants.length>0) index=100;
|
||||
else index=0;
|
||||
}
|
||||
|
||||
core.status.event.selection=index;
|
||||
|
||||
var selectId;
|
||||
if (index<100)
|
||||
selectId = tools[index];
|
||||
else
|
||||
selectId = constants[index-100];
|
||||
|
||||
if (!core.hasItem(selectId)) selectId=null;
|
||||
core.status.event.data=selectId;
|
||||
|
||||
core.clearMap('ui', 0, 0, 416, 416);
|
||||
@ -937,7 +929,7 @@ ui.prototype.drawToolbox = function(selectId) {
|
||||
core.canvas.ui.textAlign = 'right';
|
||||
var images = core.material.images.items;
|
||||
// 消耗道具
|
||||
var tools = Object.keys(core.status.hero.items.tools).sort();
|
||||
|
||||
for (var i=0;i<tools.length;i++) {
|
||||
var tool=tools[i];
|
||||
var icon=core.material.icons.items[tool];
|
||||
@ -959,7 +951,7 @@ ui.prototype.drawToolbox = function(selectId) {
|
||||
}
|
||||
|
||||
// 永久道具
|
||||
var constants = Object.keys(core.status.hero.items.constants).sort();
|
||||
|
||||
for (var i=0;i<constants.length;i++) {
|
||||
var constant=constants[i];
|
||||
var icon=core.material.icons.items[constant];
|
||||
@ -981,16 +973,18 @@ ui.prototype.drawToolbox = function(selectId) {
|
||||
core.fillText('ui', '返回游戏', 370, 403,'#DDDDDD', 'bold 15px Verdana');
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制存档、读档
|
||||
* @param page
|
||||
*/
|
||||
ui.prototype.drawSLPanel = function(page) {
|
||||
|
||||
if (page<0) page=0;
|
||||
if (page>=30) page=29;
|
||||
core.status.event.data = page;
|
||||
core.status.savePage = page;
|
||||
ui.prototype.drawSLPanel = function(index) {
|
||||
if (!core.isset(index)) index=1;
|
||||
if (index<=0) index=1;
|
||||
if (index>180) index=180;
|
||||
|
||||
core.status.event.data=index;
|
||||
|
||||
var page=parseInt((index-1)/6);
|
||||
|
||||
// core.status.event.data = page;
|
||||
// core.status.savePage = page;
|
||||
|
||||
core.clearMap('ui', 0, 0, 416, 416);
|
||||
core.setAlpha('ui', 0.85);
|
||||
@ -1007,7 +1001,7 @@ ui.prototype.drawSLPanel = function(page) {
|
||||
|
||||
if (i<3) {
|
||||
core.fillText('ui', name+id, (2*i+1)*u, 35, '#FFFFFF', "bold 17px Verdana");
|
||||
core.strokeRect('ui', (2*i+1)*u-size/2, 50, size, size, '#FFFFFF', 2);
|
||||
core.strokeRect('ui', (2*i+1)*u-size/2, 50, size, size, id==index?'#FFD700':'#FFFFFF', id==index?6:2);
|
||||
if (core.isset(data) && core.isset(data.floorId)) {
|
||||
this.drawThumbnail('ui', core.maps.load(data.maps, data.floorId).blocks, (2*i+1)*u-size/2, 50, size, data.hero.loc);
|
||||
core.fillText('ui', core.formatDate(new Date(data.time)), (2*i+1)*u, 65+size, '#FFFFFF', '10px Verdana');
|
||||
@ -1019,7 +1013,7 @@ ui.prototype.drawSLPanel = function(page) {
|
||||
}
|
||||
else {
|
||||
core.fillText('ui', name+id, (2*i-5)*u, 230, '#FFFFFF', "bold 17px Verdana");
|
||||
core.strokeRect('ui', (2*i-5)*u-size/2, 245, size, size, '#FFFFFF', 2);
|
||||
core.strokeRect('ui', (2*i-5)*u-size/2, 245, size, size, id==index?'#FFD700':'#FFFFFF', id==index?6:2);
|
||||
if (core.isset(data) && core.isset(data.floorId)) {
|
||||
this.drawThumbnail('ui', core.maps.load(data.maps, data.floorId).blocks, (2*i-5)*u-size/2, 245, size, data.hero.loc);
|
||||
core.fillText('ui', core.formatDate(new Date(data.time)), (2*i-5)*u, 260+size, '#FFFFFF', '10px Verdana');
|
||||
@ -1031,7 +1025,6 @@ ui.prototype.drawSLPanel = function(page) {
|
||||
}
|
||||
}
|
||||
this.drawPagination(page+1, 30);
|
||||
|
||||
}
|
||||
|
||||
ui.prototype.drawThumbnail = function(canvas, blocks, x, y, size, heroLoc) {
|
||||
|
||||
4
main.js
4
main.js
@ -193,14 +193,14 @@ window.onresize = function () {
|
||||
|
||||
main.dom.body.onkeydown = function(e) {
|
||||
try {
|
||||
if (main.core.isPlaying())
|
||||
if (main.core.isPlaying() || main.core.status.lockControl)
|
||||
main.core.onkeyDown(e);
|
||||
} catch (ee) {}
|
||||
}
|
||||
|
||||
main.dom.body.onkeyup = function(e) {
|
||||
try {
|
||||
if (main.core.isPlaying())
|
||||
if (main.core.isPlaying() || main.core.status.lockControl)
|
||||
main.core.onkeyUp(e);
|
||||
} catch (ee) {}
|
||||
}
|
||||
|
||||
47
快捷键说明.txt
Normal file
47
快捷键说明.txt
Normal file
@ -0,0 +1,47 @@
|
||||
快捷键说明:
|
||||
|
||||
=== 全局 ===
|
||||
[↑][↓][←][→] 移动勇士
|
||||
[X] 打开/关闭怪物手册
|
||||
[G] 打开/关闭楼层传送器
|
||||
[S] 打开/关闭存档页面
|
||||
[D] 打开/关闭读档页面
|
||||
[K] 打开/关闭快捷商店选择列表
|
||||
[T] 打开/关闭工具栏
|
||||
[ESC] 打开/关闭系统菜单
|
||||
[SPACE] 轻按(仅在轻按开关打开时有效)
|
||||
[1] 快捷使用破墙镐
|
||||
[2] 快捷使用炸弹/圣锤(先检测有没有炸弹,没有再检测圣锤)
|
||||
[3] 快捷使用中心对称飞行器
|
||||
|
||||
=== 文本显示界面 ===
|
||||
[SPACE]/[ENTER] 继续
|
||||
|
||||
=== 选项列表 ===
|
||||
[↑][↓] 移动当前选择项
|
||||
[ESC] 返回
|
||||
[SPACE]/[ENTER] 确认该选项
|
||||
|
||||
=== 怪物手册页面 ===
|
||||
[↑][↓][←][→] 翻页
|
||||
[ESC]/[X] 关闭怪物手册
|
||||
|
||||
=== 楼传器页面 ===
|
||||
[↑][↓][←][→] 更改楼层
|
||||
[SPACE]/[ENTER] 确认传送
|
||||
[ESC]/[G] 关闭楼传器
|
||||
|
||||
=== 道具栏页面 ===
|
||||
[↑][↓][←][→] 更改当前道具
|
||||
[SPACE]/[ENTER] 确认使用道具
|
||||
[ESC]/[T] 关闭道具栏
|
||||
|
||||
=== 存读档页面 ===
|
||||
[↑][↓][←][→] 更改当前存读档位置
|
||||
[PAGEUP][PAGEDOWN] 存读档翻页
|
||||
[SPACE]/[ENTER] 确认存读档
|
||||
[ESC]/[S]/[D] 关闭存读档界面
|
||||
|
||||
=== 正在使用中心对称飞行器时 ===
|
||||
[3]/[SPACE]/[ENTER] 确认飞行
|
||||
其他键 取消飞行
|
||||
Loading…
Reference in New Issue
Block a user