This commit is contained in:
tocque committed 2018-09-07 22:34:50 +08:00
1 parent 4564588494
commit eedbd3d457
19 files changed
+1081 -470

No files matched your search

+187
View File
@@ -113,6 +113,10 @@ actions.prototype.keyDown = function(keyCode) {
this.keyDownQuickShop(keyCode);
return;
}
if (core.status.event.id=='equipbox') {
this.keyDownEquipbox(keyCode);
return;
}
if (core.status.event.id=='toolbox') {
this.keyDownToolbox(keyCode);
return;
@@ -226,6 +230,10 @@ actions.prototype.keyUp = function(keyCode, fromReplay) {
this.keyUpToolbox(keyCode);
return;
}
if (core.status.event.id=='equipbox') {
this.keyUpEquipbox(keyCode);
return;
}
if (core.status.event.id=='save' || core.status.event.id=='load' || core.status.event.id=='replayLoad') {
this.keyUpSL(keyCode);
return;
@@ -281,6 +289,10 @@ actions.prototype.keyUp = function(keyCode, fromReplay) {
if (core.status.heroStop)
core.useFly(true);
break;
case 81: // Q
if (core.status.heroStop)
core.openEquipbox(true);
break;
case 88: // X
if (core.status.heroStop)
core.openBook(true);
@@ -585,6 +597,12 @@ actions.prototype.onclick = function (x, y, stepPostfix) {
return;
}
// 装备栏
if (core.status.event.id == 'equipbox') {
this.clickEquipbox(x,y);
return;
}
// 工具栏
if (core.status.event.id == 'toolbox') {
this.clickToolbox(x,y);
@@ -1202,6 +1220,12 @@ actions.prototype.keyUpQuickShop = function (keycode) {
////// 工具栏界面时的点击操作 //////
actions.prototype.clickToolbox = function(x,y) {
// 装备栏
if (x>=10 && x<=12 && y==0 && core.flags.equipment) {
core.ui.closePanel();
core.openEquipbox();
return;
}
// 返回
if (x>=10 && x<=12 && y==12) {
core.ui.closePanel();
@@ -1370,6 +1394,169 @@ actions.prototype.keyUpToolbox = function (keycode) {
}
////// 装备栏界面时的点击操作 //////
actions.prototype.clickEquipbox = function(x,y) {
// 道具栏
if (x>=10 && x<=12 && y==0) {
core.ui.closePanel();
core.openToolbox();
return;
}
// 返回
if (x>=10 && x<=12 && y==12) {
core.ui.closePanel();
return;
}
// 当前页面
var page = parseInt((core.status.event.selection%1000)/12)+1;
// 上一页
if ((x == 3 || x == 4) && y == 12) {
if (page>1) {
core.ui.drawEquipbox(core.status.event.selection-12);
}
return;
}
// 下一页
if ((x == 8 || x == 9) && y == 12) {
var lastPage = Math.ceil(Object.keys(core.status.hero.items.equips).length/12);
if (page<lastPage)
core.ui.drawEquipbox(1000+12*page);
return;
}
var index;
if (y<7) index=parseInt(x/4);
else index=parseInt(12*(page-1)+x/2);
if (y==4) index+=0;
else if (y==6) index+=3;
else if (y==9) index+=1000;
else if (y==11) index+=1006;
else index=-1;
if (index>=0)
this.clickEquipboxIndex(index);
}
////// 选择装备栏界面中某个Index后的操作 //////
actions.prototype.clickEquipboxIndex = function(index) {
if (index<1000) {
if (index>=core.status.hero.equipment.length) return;
if (index==core.status.event.selection && core.status.hero.equipment[index] != "blank") {
core.unloadEquip(index);
}
}
else {
var equips = null;
equips = Object.keys(core.status.hero.items.equips).sort();
if (equips==null) return;
if (index>=equips.length+1000) return;
if (index==core.status.event.selection) {
var equipId = equips[index-1000];
core.loadEquip(equipId);
equips = Object.keys(core.status.hero.items.equips).sort();
if ( equips.length == 0)
index = core.status.hero.equipment.length-1;
}
}
core.ui.drawEquipbox(index);
}
////// 装备栏界面时,按下某个键的操作 //////
actions.prototype.keyDownEquipbox = function (keycode) {
if (!core.isset(core.status.event.data)) return;
var equipCapacity = core.status.hero.equipment.length;
var ownEquipment = Object.keys(core.status.hero.items.equips).sort();
var index=core.status.event.selection;
var page=parseInt(index%1000/12), offset=12*page;
if (keycode==37) { // left
if ((index>0 && index<1000) || index>1000) {
this.clickEquipboxIndex(index-1);
return;
}
if (index==1000 && equipCapacity>0) {
this.clickEquipboxIndex(equipCapacity-1);
return;
}
}
if (keycode==38) { // up
if ((index>2 && index<1000)) {
this.clickEquipboxIndex(index-3);
return;
}
if (index>offset+1005) {
this.clickEquipboxIndex(index-6);
return;
}
if (index>=offset+1000 && index<=offset+1005) {
var swapIndex = Math.floor((index-offset-1000)/2);
if (equipCapacity<3)
this.clickEquipboxIndex(Math.min(swapIndex,equipCapacity-1))
else
this.clickEquipboxIndex(Math.min(swapIndex+3,equipCapacity-1))
return;
}
}
if (keycode==39) { // right
if ((index<equipCapacity-1) || (index>=1000 && index<ownEquipment.length+1000)) {
this.clickEquipboxIndex(index+1);
return;
}
if (index==equipCapacity-1 && ownEquipment.length>0) {
this.clickEquipboxIndex(1000);
return;
}
}
if (keycode==40) { // down
if (index>=offset+1000 && index<=offset+1005 && ownEquipment.length>offset+6) {
this.clickEquipboxIndex(Math.min(1000+ownEquipment.length-1, index+6));
return;
}
else {
var swapIndex = index*2+1;
if (equipCapacity<3) {
if (index<3 && ownEquipment.length>offset) {
this.clickEquipboxIndex(1000+Math.min(ownEquipment.length-1, swapIndex));
return;
}
}
else {
if (index<3) {
this.clickEquipboxIndex(Math.min(equipCapacity-1, index+3));
return;
}
else if (index>=3 && index<1000 && ownEquipment.length>offset) {
this.clickEquipboxIndex(1000+Math.min(ownEquipment.length-1, swapIndex-6));
return;
}
}
}
}
}
////// 装备栏界面时,放开某个键的操作 //////
actions.prototype.keyUpEquipbox = function (keycode) {
if (keycode==84){
core.ui.closePanel();
core.openToolbox();
return;
}
if (keycode==81 || keycode==27 || keycode==88) {
core.ui.closePanel();
return;
}
if (!core.isset(core.status.event.data)) return;
if (keycode==13 || keycode==32 || keycode==67) {
this.clickEquipboxIndex(core.status.event.selection);
return;
}
}
////// 存读档界面时的点击操作 //////
actions.prototype.clickSL = function(x,y) {
+39 -3
View File
@@ -1957,6 +1957,26 @@ control.prototype.replay = function () {
return;
}
}
else if (action.indexOf("unEquip:")==0) {
var equipId = action.substring(8);
setTimeout(function () {
core.ui.closePanel();
core.unloadEquip(equipId, function () {
core.replay();
});
}, 750 / Math.max(1, core.status.replay.speed));
return;
}
else if (action.indexOf("equip:")==0) {
var equipType = action.substring(6);
setTimeout(function () {
core.ui.closePanel();
core.loadEquip(equipType, function () {
core.replay();
});
}, 750 / Math.max(1, core.status.replay.speed));
return;
}
else if (action.indexOf("fly:")==0) {
var floorId=action.substring(4);
var toIndex=core.status.hero.flyRange.indexOf(floorId);
@@ -2128,6 +2148,14 @@ control.prototype.useFly = function (need) {
return;
}
////// 点击装备栏时的打开操作 //////
control.prototype.openEquipbox = function (need) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
if (!core.checkStatus('equipbox', need))
return;
core.ui.drawEquipbox();
}
////// 点击工具栏时的打开操作 //////
control.prototype.openToolbox = function (need) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
@@ -2650,7 +2678,9 @@ control.prototype.clearStatusBar = function() {
core.statusBar[e].innerHTML = "&nbsp;";
});
core.statusBar.image.book.style.opacity = 0.3;
core.statusBar.image.fly.style.opacity = 0.3;
if (!core.flags.equipboxBotton) {
core.statusBar.image.fly.style.opacity = 0.3;
}
}
////// 更新状态栏 //////
@@ -2726,8 +2756,14 @@ control.prototype.updateStatusBar = function () {
core.statusBar.image.book.src = core.statusBar.icons.book.src;
core.statusBar.image.book.style.opacity = core.hasItem('book')?1:0.3;
core.statusBar.image.fly.src = core.statusBar.icons.fly.src;
core.statusBar.image.fly.style.opacity = core.hasItem('fly')?1:0.3;
if (!core.flags.equipboxBotton) {
core.statusBar.image.fly.src = core.statusBar.icons.fly.src;
core.statusBar.image.fly.style.opacity = core.hasItem('fly')?1:0.3;
}
else {
core.statusBar.image.fly.src = core.statusBar.icons.equipbox.src;
core.statusBar.image.fly.style.opacity = 1;
}
core.statusBar.image.toolbox.src = core.statusBar.icons.toolbox.src;
+20
View File
@@ -828,6 +828,11 @@ core.prototype.hasItem = function (itemId) {
return core.items.hasItem(itemId);
}
////// 是否装备某件装备 //////
core.prototype.hasEquipment = function (itemId) {
return core.items.hasEquipment(itemId);
}
////// 设置某个物品的个数 //////
core.prototype.setItem = function (itemId, itemNum) {
core.items.setItem(itemId, itemNum);
@@ -848,6 +853,16 @@ core.prototype.canUseItem = function (itemId) {
return core.items.canUseItem(itemId);
}
////// 换上某件装备 //////
core.prototype.loadEquip = function (equipId, callback) {
core.items.loadEquip(equipId,callback);
}
////// 卸下某件装备 //////
core.prototype.unloadEquip = function (equipType, callback) {
core.items.unloadEquip(equipType,callback);
}
////// 增加某个物品的个数 //////
core.prototype.addItem = function (itemId, itemNum) {
core.items.addItem(itemId, itemNum);
@@ -1067,6 +1082,11 @@ core.prototype.useFly = function (need) {
core.control.useFly(need);
}
////// 点击装备栏时的打开操作 //////
core.prototype.openEquipbox = function (need) {
core.control.openEquipbox(need);
}
////// 点击工具栏时的打开操作 //////
core.prototype.openToolbox = function (need) {
core.control.openToolbox(need);
+4 -3
View File
@@ -1057,9 +1057,10 @@ events.prototype.battle = function (id, x, y, force, callback) {
}
else {
if (core.flags.equipment && core.getFlag('sword', 'sword0')!='sword0') {
core.playSound('zone.mp3');
core.drawAnimate('sword', x, y);
if (core.flags.equipment) {
var equipId = core.status.hero.equipment[0];
if (core.isset(core.material.items[equipId].animate))
core.drawAnimate(core.material.items[equipId].animate, x, y);
}
else {
core.playSound('attack.mp3');
+82
View File
@@ -96,6 +96,12 @@ items.prototype.hasItem = function (itemId) {
return core.itemCount(itemId) > 0;
}
////// 是否装备某件装备 //////
items.prototype.hasEquipment = function (itemId) {
var equiptype = core.material.items[itemId].equiptype;
return core.status.hero.equipment[equiptype] == itemId;
}
////// 设置某个物品的个数 //////
items.prototype.setItem = function (itemId, itemNum) {
var itemCls = core.material.items[itemId].cls;
@@ -140,3 +146,79 @@ items.prototype.addItem = function (itemId, itemNum) {
core.status.hero.items[itemCls][itemId] = 1;
}
////// 换上 //////
items.prototype.loadEquip = function (equipId, callback) {
core.playSound('equip.mp3');
var loadEquip = core.material.items[equipId];
var loadEquipType = loadEquip.equipType;
var unloadEquipId = core.status.hero.equipment[loadEquipType];
var unloadEquip = core.material.items[unloadEquipId];
// 处理能力值改变
if (core.isset(loadEquip.equipEffect.atk))
core.status.hero.atk += loadEquip.equipEffect.atk
if (core.isset(loadEquip.equipEffect.def))
core.status.hero.def += loadEquip.equipEffect.def
if (core.isset(loadEquip.equipEffect.mdef))
core.status.hero.mdef += loadEquip.equipEffect.mdef
if (unloadEquip.cls != "blank") {
if (core.isset(unloadEquip.equipEffect.atk))
core.status.hero.atk -= unloadEquip.equipEffect.atk
if (core.isset(unloadEquip.equipEffect.def))
core.status.hero.def -= unloadEquip.equipEffect.def
if (core.isset(unloadEquip.equipEffect.mdef))
core.status.hero.mdef -= unloadEquip.equipEffect.mdef
}
// 更新装备状态
core.status.hero.equipment[loadEquipType] = equipId;
core.updateStatusBar();
// 记录路线
core.status.route.push("equip:"+equipId);
// 装备更换完毕:删除换上的装备
core.status.hero.items["equips"][equipId]--;
if (core.status.hero.items["equips"][equipId]==0)
delete core.status.hero.items["equips"][equipId];
// 装备更换完毕:增加卸下的装备
if (unloadEquipId != "blank")
core.addItem(unloadEquipId, 1);
if (core.isset(callback)) callback();
}
////// 卸下 //////
items.prototype.unloadEquip = function (equipType, callback) {
core.playSound('equip.mp3');
var unloadEquipId = core.status.hero.equipment[equipType];
var unloadEquip = core.material.items[unloadEquipId];
// 处理能力值改变
if (core.isset(unloadEquip.equipEffect.atk))
core.status.hero.atk -= unloadEquip.equipEffect.atk
if (core.isset(unloadEquip.equipEffect.def))
core.status.hero.def -= unloadEquip.equipEffect.def
if (core.isset(unloadEquip.equipEffect.mdef))
core.status.hero.mdef -= unloadEquip.equipEffect.mdef
// 更新装备状态
core.status.hero.equipment[equipType] = "blank";
core.updateStatusBar();
// 记录路线
core.status.route.push("unEquip:"+equipType);
// 装备更换完毕:增加卸下的装备
core.addItem(unloadEquipId, 1);
if (core.isset(callback)) callback();
}
+148 -1
View File
@@ -1714,10 +1714,157 @@ ui.prototype.drawToolbox = function(index) {
}
}
// 退出
this.drawPagination(page, totalPage);
core.canvas.ui.textAlign = 'center';
// 道具栏
if (core.flags.equipment)
core.fillText('ui', '装备栏', 370, 19,'#DDDDDD', 'bold 15px Verdana');
// core.fillText('ui', '删除道具', 370, 32,'#DDDDDD', 'bold 15px Verdana');
// 退出
core.fillText('ui', '返回游戏', 370, 403,'#DDDDDD', 'bold 15px Verdana');
}
////// 绘制装备界面 //////
ui.prototype.drawEquipbox = function(index) {
var equipEquipment = core.status.hero.equipment;
var ownEquipment = Object.keys(core.status.hero.items.equips).sort();
if (!core.isset(index)) {
if (equipEquipment.length>0) index=0;
else if (ownEquipment.length>0) index=1000;
else index=0;
}
core.status.event.selection=index;
var selectId;
if (index<1000) {
if (index>=equipEquipment.length) index=Math.max(0, equipEquipment.length-1);
selectId = equipEquipment[index];
}
else {
if (index-1000>=ownEquipment.length) index=1000+Math.max(0, ownEquipment.length-1);
selectId = ownEquipment[index-1000];
if (!core.hasItem(selectId)) selectId=null;
}
var page = parseInt((index%1000)/12)+1;
var totalPage = Math.ceil(ownEquipment.length/12);
core.status.event.data=selectId;
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 0.85);
core.fillRect('ui', 0, 0, 416, 416, '#000000');
core.setAlpha('ui', 1);
core.setFillStyle('ui', '#DDDDDD');
core.setStrokeStyle('ui', '#DDDDDD');
core.canvas.ui.lineWidth = 2;
core.canvas.ui.strokeWidth = 2;
var ydelta = 20;
// 画线
core.canvas.ui.beginPath();
core.canvas.ui.moveTo(0, 130-ydelta);
core.canvas.ui.lineTo(416, 130-ydelta);
core.canvas.ui.stroke();
core.canvas.ui.beginPath();
core.canvas.ui.moveTo(416,129-ydelta);
core.canvas.ui.lineTo(416,105-ydelta);
core.canvas.ui.lineTo(416-72,105-ydelta);
core.canvas.ui.lineTo(416-102,129-ydelta);
core.canvas.ui.fill();
core.canvas.ui.beginPath();
core.canvas.ui.moveTo(0, 290-ydelta);
core.canvas.ui.lineTo(416, 290-ydelta);
core.canvas.ui.stroke();
core.canvas.ui.beginPath();
core.canvas.ui.moveTo(416,289-ydelta);
core.canvas.ui.lineTo(416,265-ydelta);
core.canvas.ui.lineTo(416-72,265-ydelta);
core.canvas.ui.lineTo(416-102,289-ydelta);
core.canvas.ui.fill();
// 文字
core.canvas.ui.textAlign = 'right';
core.fillText('ui', "当前装备", 411, 124-ydelta, '#333333', "bold 16px Verdana");
core.fillText('ui', "拥有装备", 411, 284-ydelta);
core.canvas.ui.textAlign = 'left';
// 描述
if (core.isset(selectId)) {
var equip=core.material.items[selectId];
if (equip.cls != "blank") {
core.fillText('ui', equip.name, 10, 32, '#FFD700', "bold 20px Verdana")
var text = equip.text||"该装备暂无描述。";
var lines = core.splitLines('ui', text, 406, '17px Verdana');
core.fillText('ui', lines[0], 10, 62, '#FFFFFF', '17px Verdana');
if (lines.length==1) {
if (index<1000) {
core.fillText('ui', '<继续点击该装备即可卸下>', 10, 89, '#CCCCCC', '14px Verdana');
}
else {
core.fillText('ui', '<继续点击该装备即可换上>', 10, 89, '#CCCCCC', '14px Verdana');
}
}
else {
var leftText = text.substring(lines[0].length);
core.fillText('ui', leftText, 10, 89, '#FFFFFF', '17px Verdana');
}
}
}
core.canvas.ui.textAlign = 'right';
var images = core.material.images.items;
// 当前装备
for (var i = 0 ; i < core.status.hero.equipment.length ; i++) {
var equipId = core.status.hero.equipment[i];
if (!core.isset(equipId)) break;
var icon = core.material.icons.items[equipId];
if (i<3) {
core.fillText('ui', main.equipName[i], 16*(8*i+1)+40, 144+32-ydelta, '#FFFFFF', "bold 16px Verdana");
core.canvas.ui.drawImage(images, 0, icon*32, 32, 32, 16*(8*i+5)+5, 144+5-ydelta, 32, 32)
if (index == i)
core.strokeRect('ui', 16*(8*i+5)+1, 144+1-ydelta, 40, 40, '#FFD700');
}
else {
core.fillText('ui', main.equipName[i], 16*(8*(i-3)+1)+40, 144+64+32-ydelta, '#FFFFFF', "bold 16px Verdana");
core.canvas.ui.drawImage(images, 0, icon*32, 32, 32, 16*(8*(i-3)+5)+5, 144+64+5-ydelta, 32, 32)
if (index == i)
core.strokeRect('ui', 16*(8*(i-3)+5)+1, 144+64+1-ydelta, 40, 40, '#FFD700');
}
}
// 现有装备
for (var i=0;i<12;i++) {
var ownEquip=ownEquipment[12*(page-1)+i];
if (!core.isset(ownEquip)) break;
var icon=core.material.icons.items[ownEquip];
if (i<6) {
core.canvas.ui.drawImage(images, 0, icon*32, 32, 32, 16*(4*i+1)+5, 304+5-ydelta, 32, 32)
if (selectId == ownEquip)
core.strokeRect('ui', 16*(4*i+1)+1, 304+1-ydelta, 40, 40, '#FFD700');
}
else {
core.canvas.ui.drawImage(images, 0, icon*32, 32, 32, 16*(4*(i-6)+1)+5, 304+64+5-ydelta, 32, 32)
if (selectId == ownEquip)
core.strokeRect('ui', 16*(4*(i-6)+1)+1, 304+64+1-ydelta, 40, 40, '#FFD700');
}
}
this.drawPagination(page, totalPage);
// 道具栏
core.canvas.ui.textAlign = 'center';
core.fillText('ui', '道具栏', 370, 19,'#DDDDDD', 'bold 15px Verdana');
// 退出按钮
core.fillText('ui', '返回游戏', 370, 403,'#DDDDDD', 'bold 15px Verdana');
}