From 42e0d2239e798a6499429cfa71cc24bc95a6619b Mon Sep 17 00:00:00 2001 From: tocque <364004564@qq.com> Date: Sat, 15 Sep 2018 12:23:25 +0800 Subject: [PATCH] still have some problems --- _server/comment.js | 27 ++++---- libs/actions.js | 70 -------------------- libs/control.js | 3 +- libs/events.js | 5 +- libs/items.js | 46 ++++++------- libs/ui.js | 135 +++++++++++++++++--------------------- project/data.js | 4 +- project/floors/sample0.js | 2 +- project/items.js | 85 +++++++++++------------- 9 files changed, 138 insertions(+), 239 deletions(-) diff --git a/_server/comment.js b/_server/comment.js index 8429ca1b..f2aeffdd 100644 --- a/_server/comment.js +++ b/_server/comment.js @@ -37,16 +37,15 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_string": true, "_data": "道具在道具栏中显示的描述" }, - "equiptype": { - "_leaf": true, - "_type": "textarea", - "_string": true, - "_data": "装备的类别,与equipName按顺序对应" - }, - "equipEffect": { + "equip": { "_leaf": false, "_type": "object", "_data": { + "type": { + "_leaf": true, + "_type": "textarea", + "_data": "装备的类别,与equipName按顺序对应" + }, "atk": { "_leaf": true, "_type": "textarea", @@ -62,14 +61,14 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_type": "textarea", "_data": "装备增加的魔防数值" }, + "animate": { + "_leaf": true, + "_type": "textarea", + "_string": true, + "_data": "装备的攻击动画,仅对type为0的装备有效" + } } - }, - "animate": { - "_leaf": false, - "_type": "textarea", - "_string": true, - "_data": "装备的攻击动画,仅对equiptype为0的装备有效" - } + }, } }, "itemEffect": { diff --git a/libs/actions.js b/libs/actions.js index e4497744..0f77f972 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -1547,76 +1547,6 @@ actions.prototype.keyDownEquipbox = function (keycode) { this.clickEquipboxIndex(index); return; } - /*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 offset=12*(core.status.event.data.page-1); - - 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=1000 && index0) { - 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; - } - } - } - }*/ } ////// 装备栏界面时,放开某个键的操作 ////// diff --git a/libs/control.js b/libs/control.js index 9dbd2935..b2f26073 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1953,7 +1953,6 @@ control.prototype.replay = function () { core.status.event.data = {"toolsPage":1, "constantsPage":Math.floor(index/12)+1, "selectId":null} index = index%12+12; } - else return; core.ui.drawToolbox(index); setTimeout(function () { core.ui.closePanel(); @@ -1966,7 +1965,7 @@ control.prototype.replay = function () { } else if (action.indexOf("unEquip:")==0) { var unloadEquipId = action.substring(8); - var equipType = core.material.items[unloadEquipId].equipType; + var equipType = core.material.items[unloadEquipId].equip.type; core.ui.drawEquipbox(equipType); setTimeout(function () { core.ui.closePanel(); diff --git a/libs/events.js b/libs/events.js index 8ce50c87..e65f7e3f 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1059,8 +1059,9 @@ events.prototype.battle = function (id, x, y, force, callback) { 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); + if (core.isset(equipId)) + if (core.isset(core.material.items[equipId].equip.animate)) + core.drawAnimate(core.material.items[equipId].equip.animate, x, y); } else { core.playSound('attack.mp3'); diff --git a/libs/items.js b/libs/items.js index 66fb6f0c..4b477361 100644 --- a/libs/items.js +++ b/libs/items.js @@ -98,7 +98,7 @@ items.prototype.hasItem = function (itemId) { ////// 是否装备某件装备 ////// items.prototype.hasEquip = function (equipId) { - var equiptype = core.material.items[equipId].equiptype; + var equiptype = core.material.items[equipId].equip.type; return core.status.hero.equipment[equiptype] == equipId; } @@ -153,9 +153,9 @@ items.prototype.loadEquip = function (equipId, callback) { core.playSound('equip.mp3'); var loadEquip = core.material.items[equipId]; - var loadEquipType = loadEquip.equipType; + var loadEquipType = loadEquip.equip.type; var unloadEquipId = core.status.hero.equipment[loadEquipType]; - + // 比较能力值 var result = core.compareEquipment(equipId,unloadEquipId); @@ -165,7 +165,6 @@ items.prototype.loadEquip = function (equipId, callback) { // 更新装备状态 core.status.hero.equipment[loadEquipType] = equipId; - core.updateStatusBar(); // 记录路线 @@ -177,7 +176,7 @@ items.prototype.loadEquip = function (equipId, callback) { delete core.status.hero.items["equips"][equipId]; // 装备更换完毕:增加卸下的装备 - if (unloadEquipId != "blank") + if (core.isset(unloadEquipId)) core.addItem(unloadEquipId, 1); if (core.isset(callback)) callback(); @@ -192,15 +191,12 @@ items.prototype.unloadEquip = function (equipType, callback) { 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.atk -= unloadEquip.equip.atk || 0; + core.status.hero.def -= unloadEquip.equip.def || 0; + core.status.hero.mdef -= unloadEquip.equip.mdef || 0; // 更新装备状态 - core.status.hero.equipment[equipType] = "blank"; + core.status.hero.equipment[equipType] = null; core.updateStatusBar(); @@ -214,20 +210,18 @@ items.prototype.unloadEquip = function (equipType, callback) { } items.prototype.compareEquipment = function (compareEquipId, beComparedEquipId) { - var compareEquip = core.material.items[compareEquipId]; - var beComparedEquip = core.material.items[beComparedEquipId]; var compareAtk = 0, compareDef = 0, compareMdef = 0; - if (core.isset(compareEquip.equipEffect.atk)) - compareAtk += compareEquip.equipEffect.atk; - if (core.isset(compareEquip.equipEffect.def)) - compareDef += compareEquip.equipEffect.def; - if (core.isset(compareEquip.equipEffect.mdef)) - compareMdef += compareEquip.equipEffect.mdef; - if (core.isset(beComparedEquip.equipEffect.atk)) - compareAtk -= beComparedEquip.equipEffect.atk; - if (core.isset(beComparedEquip.equipEffect.def)) - compareDef -= beComparedEquip.equipEffect.def; - if (core.isset(beComparedEquip.equipEffect.mdef)) - compareMdef -= beComparedEquip.equipEffect.mdef; + if (core.isset(compareEquipId)) { + var compareEquip = core.material.items[compareEquipId]; + compareAtk += compareEquip.equip.atk || 0; + compareDef += compareEquip.equip.def || 0; + compareMdef += compareEquip.equip.mdef || 0; + } + if (core.isset(beComparedEquipId)) { + var beComparedEquip = core.material.items[beComparedEquipId]; + compareAtk -= beComparedEquip.equip.atk || 0; + compareDef -= beComparedEquip.equip.def || 0; + compareMdef -= beComparedEquip.equip.mdef || 0; + } return {"atk":compareAtk,"def":compareDef,"mdef":compareMdef}; } \ No newline at end of file diff --git a/libs/ui.js b/libs/ui.js index b99f2bd9..02b47646 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1745,7 +1745,7 @@ ui.prototype.drawEquipbox = function(index) { selectId = equipEquipment[index]; } else { - if (index-12>=ownEquipment.length) index=12+Math.max(0, ownEquipment.length-1); + if (index+12*(page-2)>=ownEquipment.length) index=12+Math.max(0, ownEquipment.length%12-1); selectId = ownEquipment[index-12]; if (!core.hasItem(selectId)) selectId=null; } @@ -1792,75 +1792,65 @@ ui.prototype.drawEquipbox = function(index) { core.canvas.ui.textAlign = 'left'; + console.log(equipEquipment[0]); // 描述 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") + core.fillText('ui', equip.name, 10, 32, '#FFD700', "bold 20px Verdana") - var text = equip.text||"该装备暂无描述。"; - var lines = core.splitLines('ui', text, 406, '17px 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) { - var compare; - if (index<12) compare = core.compareEquipment("blank", selectId); - else { - compare = core.compareEquipment(selectId, equipEquipment[equip.equipType]); - } - // 绘制 - var drawList; //= [['攻击',atk],['防御',def],['魔防',mdef]];var draw; - var drawPointer = 0; - var color; - /*for (var printer = 0; printer0) - color = '#00FF00' - else color = '#FF0000' - draw = drawList[printer][0]+' '+core.status.hero[drawList[printer][1]]+'->'+(core.status.hero[drawList[printer][1]]+compare[drawList[printer][1]])+' '; - drawPointer += draw.length; - core.fillText('ui', draw, 10+drawPointer, 89, color, '14px Verdana'); - }*/ - if (compare.atk!=0) { - if (compare.atk>0) color = '#00FF00'; - else color = '#FF0000'; - drawList = '攻击 '+core.status.hero.atk+'->'; - core.fillText('ui', drawList, 10+drawPointer, 89, '#CCCCCC', 'bold 14px Verdana'); - drawPointer += core.canvas.ui.measureText(drawList).width; - - drawList = (core.status.hero.atk+compare.atk)+' '; - core.fillText('ui', drawList, 10+drawPointer, 89, color, 'bold 14px Verdana'); - drawPointer += core.canvas.ui.measureText(drawList).width; - } - if (compare.def!=0) { - if (compare.def>0) color = '#00FF00'; - else color = '#FF0000'; - drawList = '防御 '+core.status.hero.atk+'->'; - core.fillText('ui', drawList, 10+drawPointer, 89, '#CCCCCC', 'bold 14px Verdana'); - drawPointer += core.canvas.ui.measureText(drawList).width; - - drawList = (core.status.hero.atk+compare.def)+' '; - core.fillText('ui', drawList, 10+drawPointer, 89, color, 'bold 14px Verdana'); - drawPointer += core.canvas.ui.measureText(drawList).width; - } - if (compare.mdef!=0) { - if (compare.mdef>0) color = '#00FF00'; - else color = '#FF0000'; - drawList = '魔防 '+core.status.hero.atk+'->'; - core.fillText('ui', drawList, 10+drawPointer, 89, '#CCCCCC', 'bold 14px Verdana'); - drawPointer += core.canvas.ui.measureText(drawList).width; - - drawList = (core.status.hero.atk+compare.mdef)+' '; - core.fillText('ui', drawList, 10+drawPointer, 89, color, 'bold 14px Verdana'); - drawPointer += core.canvas.ui.measureText(drawList).width; - } - } + core.fillText('ui', lines[0], 10, 62, '#FFFFFF', '17px Verdana'); + + // 比较属性 + if (lines.length==1) { + var compare; + if (index<12) compare = core.compareEquipment(null, selectId); else { - var leftText = text.substring(lines[0].length); - core.fillText('ui', leftText, 10, 89, '#FFFFFF', '17px Verdana'); + compare = core.compareEquipment(selectId, equipEquipment[equip.equip.type]); } + // 绘制 + var drawList; //= [['攻击',atk],['防御',def],['魔防',mdef]]; + var drawPointer = 0; + var color; + if (compare.atk!=0) { + if (compare.atk>0) color = '#00FF00'; + else color = '#FF0000'; + drawList = '攻击 '+core.status.hero.atk+'->'; + core.fillText('ui', drawList, 10+drawPointer, 89, '#CCCCCC', 'bold 14px Verdana'); + drawPointer += core.canvas.ui.measureText(drawList).width; + + drawList = (core.status.hero.atk+compare.atk)+' '; + core.fillText('ui', drawList, 10+drawPointer, 89, color, 'bold 14px Verdana'); + drawPointer += core.canvas.ui.measureText(drawList).width; + } + if (compare.def!=0) { + if (compare.def>0) color = '#00FF00'; + else color = '#FF0000'; + drawList = '防御 '+core.status.hero.atk+'->'; + core.fillText('ui', drawList, 10+drawPointer, 89, '#CCCCCC', 'bold 14px Verdana'); + drawPointer += core.canvas.ui.measureText(drawList).width; + + drawList = (core.status.hero.atk+compare.def)+' '; + core.fillText('ui', drawList, 10+drawPointer, 89, color, 'bold 14px Verdana'); + drawPointer += core.canvas.ui.measureText(drawList).width; + } + if (compare.mdef!=0) { + if (compare.mdef>0) color = '#00FF00'; + else color = '#FF0000'; + drawList = '魔防 '+core.status.hero.atk+'->'; + core.fillText('ui', drawList, 10+drawPointer, 89, '#CCCCCC', 'bold 14px Verdana'); + drawPointer += core.canvas.ui.measureText(drawList).width; + + drawList = (core.status.hero.atk+compare.mdef)+' '; + core.fillText('ui', drawList, 10+drawPointer, 89, color, 'bold 14px Verdana'); + drawPointer += core.canvas.ui.measureText(drawList).width; + } + } + else { + var leftText = text.substring(lines[0].length); + core.fillText('ui', leftText, 10, 89, '#FFFFFF', '17px Verdana'); } } @@ -1870,20 +1860,13 @@ ui.prototype.drawEquipbox = function(index) { // 当前装备 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'); + if (core.isset(equipId)) { + var icon = core.material.icons.items[equipId]; + core.canvas.ui.drawImage(images, 0, icon*32, 32, 32, 16*(8*(i%3)+5)+5, 144+Math.floor(i/3)*64+5-ydelta, 32, 32); } + core.fillText('ui', main.equipName[i], 16*(8*(i%3)+1)+40, 144+Math.floor(i/3)*64+32-ydelta, '#FFFFFF', "bold 16px Verdana"); + if (index == i) + core.strokeRect('ui', 16*(8*(i%3)+5)+1, 144+Math.floor(i/3)*64+1-ydelta, 40, 40, '#FFD700'); } // 现有装备 diff --git a/project/data.js b/project/data.js index 2bea651c..42dafb53 100644 --- a/project/data.js +++ b/project/data.js @@ -73,8 +73,8 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "money": 100, "experience": 0, "equipment": [ - "blank", - "blank" + null, + null ], "items": { "keys": { diff --git a/project/floors/sample0.js b/project/floors/sample0.js index cec16491..7a02319b 100644 --- a/project/floors/sample0.js +++ b/project/floors/sample0.js @@ -203,7 +203,7 @@ main.floors.sample0= "在 data.js 的系统Flag中设置是否启用装备栏按钮。\n如果启用则装备栏按钮会替代楼传按钮。" ], "12,5": [ - "装备的种类由全塔属性中的equipName决定,equiptype的值就是该类型在equipName中的顺序,例如默认情况下equiptype为0代表武器,同时只有euqiptype为0的装备的攻击动画生效" + "装备的种类由全塔属性中的equipName决定,type的值就是该类型在equipName中的位次,例如默认情况下equiptype为0代表武器,同时只有type为0的装备的animate属性生效" ] }, "afterOpenDoor": { diff --git a/project/items.js b/project/items.js index 45bf805b..08fa5407 100644 --- a/project/items.js +++ b/project/items.js @@ -49,94 +49,94 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "cls": "item", "name": "铁剑", "text": "一把很普通的铁剑", - "equipType": 0, - "equipEffect": { - "atk": 10 - }, - "animate": "sword" + "equip":{ + "type": 0, + "atk": 10, + "animate": "sword" + } }, "sword2": { "cls": "items", "name": "银剑", "text": "一把很普通的银剑", - "equipType": 0, - "equipEffect": { - "atk": 20 - }, - "animate": "sword" + "equip":{ + "type": 0, + "atk": 20, + "animate": "sword" + } }, "sword3": { "cls": "items", "name": "骑士剑", "text": "一把很普通的骑士剑", - "equipType": 0, - "equipEffect": { - "atk": 40 - }, - "animate": "sword" + "equip":{ + "type": 0, + "atk": 40, + "animate": "sword" + } }, "sword4": { "cls": "items", "name": "圣剑", "text": "一把很普通的圣剑", - "equipType": 0, - "equipEffect": { - "atk": 80 - }, - "animate": "sword" + "equip":{ + "type": 0, + "atk": 80, + "animate": "sword" + } }, "sword5": { "cls": "items", "name": "神圣剑", "text": "一把很普通的神圣剑", - "equipType": 0, - "equipEffect": { - "atk": 100 - }, - "animate": "sword" + "equip":{ + "type": 0, + "atk": 100, + "animate": "sword" + } }, "shield1": { "cls": "items", "name": "铁盾", "text": "一个很普通的铁盾", - "equipType": 1, - "equipEffect": { + "equip":{ + "type": 1, "def": 10 - }, + } }, "shield2": { "cls": "items", "name": "银盾", "text": "一个很普通的银盾", - "equipType": 1, - "equipEffect": { + "equip":{ + "type": 1, "def": 20 - }, + } }, "shield3": { "cls": "items", "name": "骑士盾", "text": "一个很普通的骑士盾", - "equipType": 1, - "equipEffect": { + "equip":{ + "type": 1, "def": 40 - }, + } }, "shield4": { "cls": "items", "name": "圣盾", "text": "一个很普通的圣盾", - "equipType": 1, - "equipEffect": { + "equip":{ + "type": 1, "def": 80 - }, + } }, "shield5": { "cls": "items", "name": "神圣盾", "text": "一个很普通的神圣盾", - "equipType": 1, - "equipEffect": { + "equip":{ + "type": 1, "def": 100, "mdef": 100 }, @@ -269,13 +269,6 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "name": "跳跃靴", "text": "能跳跃到前方两格处" }, - "blank": { - "cls": "blank", - "name": " ", - "text": " ", - "equipEffect": {}, - "animate": "hand" - }, }, "itemEffect": { "redJewel": "core.status.hero.atk += core.values.redJewel * ratio",