diff --git a/_server/comment.js b/_server/comment.js index e6e61334..82a312fc 100644 --- a/_server/comment.js +++ b/_server/comment.js @@ -19,10 +19,11 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "keys", "items", "constants", - "tools" + "tools", + "equips" ] }, - "_data": "只能取keys(钥匙) items(宝石、血瓶) constants(永久物品) tools(消耗道具)" + "_data": "只能取keys(钥匙) items(宝石、血瓶) constants(永久物品) tools(消耗道具) equip(装备)" }, "name": { "_leaf": true, @@ -35,6 +36,39 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_type": "textarea", "_string": true, "_data": "道具在道具栏中显示的描述" + }, + "equiptype": { + "_leaf": true, + "_type": "textarea", + "_string": true, + "_data": "装备的类别,与equipName按顺序对应" + }, + "equipEffect": { + "_leaf": false, + "_type": "object", + "_data": { + "atk": { + "_leaf": true, + "_type": "textarea", + "_data": "装备增加的攻击数值" + }, + "def": { + "_leaf": true, + "_type": "textarea", + "_data": "装备增加的防御数值" + }, + "mdef": { + "_leaf": true, + "_type": "textarea", + "_data": "装备增加的魔防数值" + }, + } + }, + "animate": { + "_leaf": false, + "_type": "textarea", + "_string": true, + "_data": "装备的攻击动画,仅对equiptype为0的装备有效" } } }, diff --git a/_server/data.comment.js b/_server/data.comment.js index 3cd98103..69715eaf 100644 --- a/_server/data.comment.js +++ b/_server/data.comment.js @@ -47,6 +47,11 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_type": "textarea", "_data": "难度选择:每个数组的第一个是其在标题界面显示的难度,第二个是在游戏内部传输的字符串,会显示在状态栏,修改此处后需要在project/functions中作相应更改" }, + "equipName": { + "_leaf": true, + "_type": "textarea", + "_data": "装备位名称,为不超过6个的数组,此项的顺序与equiptype数值关联" + }, "statusLeftBackground": { "_leaf": true, "_type": "textarea", @@ -144,6 +149,11 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_type": "textarea", "_data": "初始经验" }, + "equipment": { + "_leaf": true, + "_type": "textarea", + "_data": "初始装备" + }, "items": { "_leaf": false, "_type": "object", @@ -162,6 +172,11 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_leaf": true, "_type": "textarea", "_data": "初始消耗道具个数,例如初始有两破可以写 {\"pickaxe\": 2}" + }, + "equips": { + "_leaf": true, + "_type": "textarea", + "_data": "初始装备个数,例如初始送铁剑可以写 {\"sword1\": 1}" } } }, @@ -276,66 +291,6 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_type": "textarea", "_data": "绿血瓶加血数值" }, - "sword0": { - "_leaf": true, - "_type": "textarea", - "_data": "空剑的攻击力,此项请保持为0" - }, - "shield0": { - "_leaf": true, - "_type": "textarea", - "_data": "空盾的防御力,此项请保持为0" - }, - "sword1": { - "_leaf": true, - "_type": "textarea", - "_data": "铁剑加攻数值" - }, - "shield1": { - "_leaf": true, - "_type": "textarea", - "_data": "铁盾加防数值" - }, - "sword2": { - "_leaf": true, - "_type": "textarea", - "_data": "银剑加攻数值" - }, - "shield2": { - "_leaf": true, - "_type": "textarea", - "_data": "银盾加防数值" - }, - "sword3": { - "_leaf": true, - "_type": "textarea", - "_data": "骑士剑加攻数值" - }, - "shield3": { - "_leaf": true, - "_type": "textarea", - "_data": "骑士盾加防数值" - }, - "sword4": { - "_leaf": true, - "_type": "textarea", - "_data": "圣剑加攻数值" - }, - "shield4": { - "_leaf": true, - "_type": "textarea", - "_data": "圣盾加防数值" - }, - "sword5": { - "_leaf": true, - "_type": "textarea", - "_data": "神圣剑加攻数值" - }, - "shield5": { - "_leaf": true, - "_type": "textarea", - "_data": "神圣盾加防数值" - }, "moneyPocket": { "_leaf": true, "_type": "textarea", @@ -472,7 +427,13 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_leaf": true, "_type": "checkbox", "_bool": "bool", - "_data": "剑和盾是否直接作为装备。如果此项为true,则作为装备,需要在道具栏使用,否则将直接加属性。" + "_data": "剑和盾是否作为装备。如果此项为true,则作为装备,需要在装备栏使用,否则将直接加属性。" + }, + "equipboxBotton": { + "_leaf": true, + "_type": "checkbox", + "_bool": "bool", + "_data": "若此项为true则将状态栏中的楼层转换器按钮换为装备栏按钮,同时启用装备栏,无论equipment是否为true" }, /* "enableDeleteItem": { diff --git a/libs/actions.js b/libs/actions.js index 01619092..bed546eb 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -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=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=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; + } + } + } + } +} + +////// 装备栏界面时,放开某个键的操作 ////// +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) { diff --git a/libs/control.js b/libs/control.js index a59adf5a..a9b20f50 100644 --- a/libs/control.js +++ b/libs/control.js @@ -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 = " "; }); 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; diff --git a/libs/core.js b/libs/core.js index ee47c077..6afd2468 100644 --- a/libs/core.js +++ b/libs/core.js @@ -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); diff --git a/libs/events.js b/libs/events.js index 73497b87..8ce50c87 100644 --- a/libs/events.js +++ b/libs/events.js @@ -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'); diff --git a/libs/items.js b/libs/items.js index 82ee9204..4aa87a7f 100644 --- a/libs/items.js +++ b/libs/items.js @@ -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(); +} \ No newline at end of file diff --git a/libs/ui.js b/libs/ui.js index a365323f..bde0adca 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -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'); } diff --git a/main.js b/main.js index 26190b34..53ef15ce 100644 --- a/main.js +++ b/main.js @@ -118,6 +118,7 @@ function main() { 'speedDown': 20, 'speedUp': 21, 'rewind': 22, + 'equipbox': 23, }, 'floor': document.getElementById('floor'), 'lv': document.getElementById('lv'), @@ -387,7 +388,7 @@ main.statusBar.image.book.onclick = function () { main.core.openBook(true); } -////// 点击状态栏中的楼层传送器时 ////// +////// 点击状态栏中的楼层传送器/装备栏时 ////// main.statusBar.image.fly.onclick = function () { if (core.isset(core.status.replay) && core.status.replay.replaying) { @@ -395,8 +396,14 @@ main.statusBar.image.fly.onclick = function () { return; } - if (main.core.isPlaying()) - main.core.useFly(true); + if (main.core.isPlaying()) { + if (!main.core.flags.equipboxBotton) { + main.core.useFly(true); + } + else { + main.core.openEquipbox(true) + } + } } ////// 点击状态栏中的工具箱时 ////// diff --git a/mota-js b/mota-js new file mode 160000 index 00000000..45645884 --- /dev/null +++ b/mota-js @@ -0,0 +1 @@ +Subproject commit 45645884940c700b6121ffdd3624f9ed0ed062cb diff --git a/project/data.js b/project/data.js index 5bbb87a6..2bea651c 100644 --- a/project/data.js +++ b/project/data.js @@ -1,173 +1,228 @@ -data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = -{ - "main" : { - "floorIds" : [ - "sample0", "sample1", "sample2", "sample3", "MT0" - ], - "images" : [ - "bg.jpg" - ], - "animates" : [ - "hand", "sword", "zone" - ], - "bgms" : [ - 'bgm.mp3' - ], - "sounds" : [ - 'floor.mp3', 'attack.mp3', 'door.mp3', 'item.mp3', 'zone.mp3', 'jump.mp3' - ], - "startBackground" : "bg.jpg", - "startLogoStyle" : "color: black", - "levelChoose" : [["简单","Easy"],["普通","Normal"],["困难","Hard"],["噩梦","Hell"]], - "statusLeftBackground": "url(project/images/ground.png) repeat", - "statusTopBackground": "url(project/images/ground.png) repeat", - "toolsBackground": "url(project/images/ground.png) repeat", - "borderColor": "white" - }, - "firstData" : { - "title": "魔塔样板", - "name": "template", - "version": "Ver 2.4", - "floorId": "sample0", - "hero": { - "name": "阳光", - 'lv': 1, - "hpmax": 9999, - "hp": 1000, - "atk": 100, - "def": 100, - "mdef": 100, - "money": 100, - "experience": 0, - "items": { - "keys": { - "yellowKey": 0, - "blueKey": 0, - "redKey": 0 - }, - "constants": {}, - "tools": {} - }, - "flyRange": [], - "loc": {"direction": "up", "x": 6, "y": 10}, - "flags": {}, - "steps": 0, - }, - "startText": [ - "Hi,欢迎来到 HTML5 魔塔样板!\n\n本样板由艾之葵制作,可以让你在不会写任何代码\n的情况下也能做出属于自己的H5魔塔!", - "这里游戏开始时的剧情。\n定义在data.js的startText处。\n\n你可以在这里写上自己的内容。", - "赶快来试一试吧!" - ], - "shops": [ - { - "id": "moneyShop1", - "name": "贪婪之神", - "icon": "blueShop", - "textInList": "1F金币商店", - "use": "money", - "need": "20+10*times*(times+1)", - "text": "勇敢的武士啊,给我${need}金币就可以:", - "choices": [ - {"text": "生命+800", "effect": "status:hp+=800"}, - {"text": "攻击+4", "effect": "status:atk+=4"}, - {"text": "防御+4", "effect": "status:def+=4"}, - {"text": "魔防+10", "effect": "status:mdef+=10"} - ] - }, - { - "id": "expShop1", - "name": "经验之神", - "icon": "pinkShop", - "textInList": "1F经验商店", - "use": "experience", - "need": "-1", - "text": "勇敢的武士啊,给我若干经验就可以:", - "choices": [ - {"text": "等级+1", "need": "100", "effect": "status:lv+=1;status:hp+=1000;status:atk+=7;status:def+=7"}, - {"text": "攻击+5", "need": "30", "effect": "status:atk+=5"}, - {"text": "防御+5", "need": "30", "effect": "status:def+=5"}, - ] - } - ], - "levelUp": [ - {}, - {"need": 20, "name": "第二级", "effect": "status:hp+=2*(status:atk+status:def);status:atk+=10;status:def+=10"}, - {"need": 40, "effect": function () { - core.insertAction("恭喜升级!"); - core.status.hero.hp *= 2; - core.status.hero.atk += 100; - core.status.hero.def += 100; - }}, - ] - }, - - "values" : { - "lavaDamage": 100, - "poisonDamage": 10, - "weakValue": 20, - "redJewel": 3, - "blueJewel": 3, - "greenJewel": 5, - "redPotion": 100, - "bluePotion": 250, - "yellowPotion": 500, - "greenPotion": 800, - "sword0": 0, - "shield0": 0, - "sword1": 10, - "shield1": 10, - "sword2": 20, - "shield2": 20, - "sword3": 40, - "shield3": 40, - "sword4": 80, - "shield4": 80, - "sword5": 160, - "shield5": 160, - "moneyPocket": 500, - 'breakArmor': 0.9, - 'counterAttack': 0.1, - 'purify': 3, - 'hatred': 2, - 'maxValidHp': null, - 'animateSpeed': 300, - }, - - "flags" : { - "enableFloor": true, - "enableLv": false, - "enableHPMax": false, - "enableMDef": true, - "enableMoney": true, - "enableExperience": false, - "enableLevelUp": false, - "enableKeys": true, - "enablePZF": false, - "enableDebuff": false, - "flyNearStair": true, - "pickaxeFourDirections": false, - "bombFourDirections": false, - "snowFourDirections": false, - "bigKeyIsBox": false, - "equipment": false, - "enableAddPoint": false, - "enableNegativeDamage": false, - "hatredDecrease": true, - "betweenAttackCeil": false, - "useLoop": false, - "startDirectly": false, - "canOpenBattleAnimate": true, - "showBattleAnimateConfirm": false, - "battleAnimate": false, - "displayEnemyDamage": true, - "displayCritical": true, - "displayExtraDamage": true, - "enableGentleClick": true, - "potionWhileRouting": false, - "enableViewMaps": true, - "portalWithoutTrigger": true, - "canGoDeadZone": false, - "enableMoveDirectly": true, - "clickMoveDirectly": true, - } +data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = +{ + "main": { + "floorIds": [ + "sample0", + "sample1", + "sample2", + "sample3", + "MT0" + ], + "images": [ + "bg.jpg" + ], + "animates": [ + "hand", + "sword", + "zone" + ], + "bgms": [ + "bgm.mp3" + ], + "sounds": [ + "floor.mp3", + "attack.mp3", + "door.mp3", + "item.mp3", + "equip.mp3", + "zone.mp3", + "jump.mp3" + ], + "startBackground": "bg.jpg", + "startLogoStyle": "color: black", + "levelChoose": [ + [ + "简单", + "Easy" + ], + [ + "普通", + "Normal" + ], + [ + "困难", + "Hard" + ], + [ + "噩梦", + "Hell" + ] + ], + "equipName": [ + "武器", + "盾牌" + ], + "statusLeftBackground": "url(project/images/ground.png) repeat", + "statusTopBackground": "url(project/images/ground.png) repeat", + "toolsBackground": "url(project/images/ground.png) repeat", + "borderColor": "white" + }, + "firstData": { + "title": "魔塔样板", + "name": "template", + "version": "Ver 2.4", + "floorId": "sample0", + "hero": { + "name": "阳光", + "lv": 1, + "hpmax": 9999, + "hp": 1000, + "atk": 100, + "def": 100, + "mdef": 100, + "money": 100, + "experience": 0, + "equipment": [ + "blank", + "blank" + ], + "items": { + "keys": { + "yellowKey": 0, + "blueKey": 0, + "redKey": 0 + }, + "constants": {}, + "tools": {}, + "equips": {} + }, + "flyRange": [], + "loc": { + "direction": "up", + "x": 6, + "y": 10 + }, + "flags": {}, + "steps": 0 + }, + "startText": [ + "Hi,欢迎来到 HTML5 魔塔样板!\n\n本样板由艾之葵制作,可以让你在不会写任何代码\n的情况下也能做出属于自己的H5魔塔!", + "这里游戏开始时的剧情。\n定义在data.js的startText处。\n\n你可以在这里写上自己的内容。", + "赶快来试一试吧!" + ], + "shops": [ + { + "id": "moneyShop1", + "name": "贪婪之神", + "icon": "blueShop", + "textInList": "1F金币商店", + "use": "money", + "need": "20+10*times*(times+1)", + "text": "勇敢的武士啊,给我${need}金币就可以:", + "choices": [ + { + "text": "生命+800", + "effect": "status:hp+=800" + }, + { + "text": "攻击+4", + "effect": "status:atk+=4" + }, + { + "text": "防御+4", + "effect": "status:def+=4" + }, + { + "text": "魔防+10", + "effect": "status:mdef+=10" + } + ] + }, + { + "id": "expShop1", + "name": "经验之神", + "icon": "pinkShop", + "textInList": "1F经验商店", + "use": "experience", + "need": "-1", + "text": "勇敢的武士啊,给我若干经验就可以:", + "choices": [ + { + "text": "等级+1", + "need": "100", + "effect": "status:lv+=1;status:hp+=1000;status:atk+=7;status:def+=7" + }, + { + "text": "攻击+5", + "need": "30", + "effect": "status:atk+=5" + }, + { + "text": "防御+5", + "need": "30", + "effect": "status:def+=5" + } + ] + } + ], + "levelUp": [ + {}, + { + "need": 20, + "name": "第二级", + "effect": "status:hp+=2*(status:atk+status:def);status:atk+=10;status:def+=10" + }, + { + "need": 40, + "effect": "function () {\r\n\t\t\tcore.insertAction(\"恭喜升级!\");\r\n\t\t\tcore.status.hero.hp *= 2;\r\n\t\t\tcore.status.hero.atk += 100;\r\n\t\t\tcore.status.hero.def += 100;\r\n\t\t}" + } + ] + }, + "values": { + "lavaDamage": 100, + "poisonDamage": 10, + "weakValue": 20, + "redJewel": 3, + "blueJewel": 3, + "greenJewel": 5, + "redPotion": 100, + "bluePotion": 250, + "yellowPotion": 500, + "greenPotion": 800, + "moneyPocket": 500, + "breakArmor": 0.9, + "counterAttack": 0.1, + "purify": 3, + "hatred": 2, + "maxValidHp": null, + "animateSpeed": 300 + }, + "flags": { + "enableFloor": true, + "enableLv": false, + "enableHPMax": false, + "enableMDef": true, + "enableMoney": true, + "enableExperience": false, + "enableLevelUp": false, + "enableKeys": true, + "enablePZF": false, + "enableDebuff": false, + "flyNearStair": true, + "pickaxeFourDirections": false, + "bombFourDirections": false, + "snowFourDirections": false, + "bigKeyIsBox": false, + "equipment": true, + "equipboxBotton": false, + "enableAddPoint": false, + "enableNegativeDamage": false, + "hatredDecrease": true, + "betweenAttackCeil": false, + "useLoop": false, + "startDirectly": false, + "canOpenBattleAnimate": true, + "showBattleAnimateConfirm": false, + "battleAnimate": false, + "displayEnemyDamage": true, + "displayCritical": true, + "displayExtraDamage": true, + "enableGentleClick": true, + "potionWhileRouting": false, + "enableViewMaps": true, + "portalWithoutTrigger": true, + "canGoDeadZone": false, + "enableMoveDirectly": true, + "clickMoveDirectly": true + } } \ No newline at end of file diff --git a/project/floors/sample0.js b/project/floors/sample0.js index 78e04a85..cec16491 100644 --- a/project/floors/sample0.js +++ b/project/floors/sample0.js @@ -1,120 +1,215 @@ -main.floors.sample0 = +main.floors.sample0= { - "floorId": "sample0", // 这里需要改楼层名,请和文件名及下面的floorId保持完全一致 - // 楼层唯一标识符仅能由字母、数字、下划线组成,且不能由数字开头 - // 推荐用法:第20层就用MT20,第38层就用MT38,地下6层就用MT_6(用下划线代替负号),隐藏3层用MT3h(h表示隐藏),等等 - // 楼层唯一标识符,需要和名字完全一致 - "title": "样板 0 层", // 楼层中文名 - "name": "0", // 显示在状态栏中的层数 - "canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器) - "canUseQuickShop": true, // 该层是否允许使用快捷商店 - "defaultGround": "ground", // 默认地面的图块ID(terrains中) - "images": [], // 该层默认显示的所有图片;详细用法请查看文档“自定义素材”中的说明。 - // "color": [0,0,0,0.3] // 该层的默认画面色调。本项可不写(代表无色调),如果写需要是一个RGBA数组。 - // "weather": ["snow",5], // 该层的默认天气。本项可忽略表示晴天,如果写则第一项为"rain"或"snow"代表雨雪,第二项为1-10之间的数代表强度。 - "bgm": "bgm.mp3", // 到达该层后默认播放的BGM。本项可忽略。 - "item_ratio": 2, // 该层的宝石/血瓶倍率 - "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 - [0, 0, 220, 0, 0, 20, 87, 3, 65, 64, 44, 43, 42], - [0, 246, 0, 246, 0, 20, 0, 3, 58, 59, 60, 61, 41], - [219, 0, 0, 0, 219, 20, 0, 3, 57, 26, 62, 63, 40], - [20, 20, 125, 20, 20, 20, 0, 3, 53, 54, 55, 56, 39], - [216, 247, 263, 235, 248, 6, 0, 3, 49, 50, 51, 52, 38], - [6, 6, 125, 6, 6, 6, 0, 1, 45, 46, 47, 48, 37], - [224, 254, 212, 262, 204, 5, 0, 1, 31, 32, 34, 33, 36], - [201, 261, 217, 264, 207, 5, 0, 1, 27, 28, 29, 30, 35], - [5, 5, 125, 5, 5, 5, 0, 1, 21, 22, 23, 24, 25], - [0, 0, 237, 0, 0, 0, 45, 1, 1, 1, 121, 1, 1], - [4, 4, 133, 4, 4, 4, 0, 0, 0, 0, 0, 85, 124], - [87, 11, 12, 13, 14, 4, 4, 2, 2, 2, 122, 2, 2], - [88, 89, 90, 91, 92, 93, 94, 2, 81, 82, 83, 84, 86], +"floorId": "sample0", +"title": "样板 0 层", +"name": "0", +"canFlyTo": true, +"canUseQuickShop": true, +"defaultGround": "ground", +"images": [], +"bgm": "bgm.mp3", +"item_ratio": 2, +"map": [ + [ 0, 0,220, 0, 0, 20, 87, 3, 65, 64, 44, 43, 42], + [ 0,246, 0,246, 0, 20, 0, 3, 58, 59, 60, 61, 41], + [219, 0, 0, 0,219, 20, 0, 3, 57, 26, 62, 63, 40], + [ 20, 20,125, 20, 20, 20, 0, 3, 53, 54, 55, 56, 39], + [216,247,263,235,248, 6, 0, 3, 49, 50, 51, 52, 38], + [ 6, 6,125, 6, 6, 6, 0, 1, 45, 46, 47, 48, 37], + [224,254,212,262,204, 5, 0, 1, 31, 32, 34, 33, 36], + [201,261,217,264,207, 5, 0, 1, 27, 28, 29, 30, 35], + [ 5, 5,125, 5, 5, 5, 0, 1, 21, 22, 23, 24, 25], + [ 0, 0,237, 0, 0, 0, 45, 1, 1, 1,121, 1, 1], + [ 4, 4,133, 4, 4, 4, 0, 0, 0, 0, 0, 85,124], + [ 87, 11, 12, 13, 14, 4, 4, 2, 2, 2,122, 2, 2], + [ 88, 89, 90, 91, 92, 93, 94, 2, 81, 82, 83, 84, 86] +], +"firstArrive": [ + "\t[样板提示]首次到达某层可以触发 firstArrive 事件,该事件可类似于RMXP中的“自动执行脚本”。\n\n本事件支持一切的事件类型,常常用来触发对话,例如:", + "\t[hero]\b[up,hero]我是谁?我从哪来?我又要到哪去?", + "\t[仙子,fairy]你问我...?我也不知道啊...", + "本层主要对道具、门、怪物等进行介绍,有关事件的各种信息在下一层会有更为详细的说明。" +], +"events": { + "10,9": [ + "\t[老人,man]这些是本样板支持的所有的道具。\n\n道具分为三类:items, constants, tools。\nitems 为即捡即用类道具,例如宝石、血瓶、剑盾等。\nconstants 为永久道具,例如怪物手册、楼层传送器、幸运金币等。\ntools 为消耗类道具,例如破墙镐、炸弹、中心对称飞行器等。\n\n后两类道具在工具栏中可以看到并使用。", + "\t[老人,man]\b[up]有关道具效果,定义在items.js中。\n目前大多数道具已有默认行为,如有自定义的需求则需在items.js中修改代码。", + "\t[老人,man]constants 和 tools 各最多只允许12种,多了会导致图标溢出。", + "\t[老人,man]\b[up]拾取道具结束后可触发 afterGetItem 事件。\n\n有关事件的各种信息在下一层会有更为详细的说明。", + { + "type": "hide", + "time": 500 + } ], - "firstArrive": [ // 第一次到该楼层触发的事件 - "\t[样板提示]首次到达某层可以触发 firstArrive 事件,该事件可类似于RMXP中的“自动执行脚本”。\n\n本事件支持一切的事件类型,常常用来触发对话,例如:", - "\t[hero]\b[up,hero]我是谁?我从哪来?我又要到哪去?", - "\t[仙子,fairy]你问我...?我也不知道啊...", - "本层主要对道具、门、怪物等进行介绍,有关事件的各种信息在下一层会有更为详细的说明。", + "10,11": [ + "\t[老人,woman]这些是门,需要对应的钥匙打开。\n机关门必须使用特殊的开法。", + "\t[老人,woman]开门后可触发 afterOpenDoor 事件。\n\n有关事件的各种信息在下一层会有更为详细的说明。", + { + "type": "hide", + "time": 500 + } ], - "events": { // 该楼的所有可能事件列表 - "10,9": [ // 守着道具的老人 - "\t[老人,man]这些是本样板支持的所有的道具。\n\n道具分为三类:items, constants, tools。\nitems 为即捡即用类道具,例如宝石、血瓶、剑盾等。\nconstants 为永久道具,例如怪物手册、楼层传送器、幸运金币等。\ntools 为消耗类道具,例如破墙镐、炸弹、中心对称飞行器等。\n\n后两类道具在工具栏中可以看到并使用。", - "\t[老人,man]\b[up]有关道具效果,定义在items.js中。\n目前大多数道具已有默认行为,如有自定义的需求则需在items.js中修改代码。", - "\t[老人,man]constants 和 tools 各最多只允许12种,多了会导致图标溢出。", - "\t[老人,man]\b[up]拾取道具结束后可触发 afterGetItem 事件。\n\n有关事件的各种信息在下一层会有更为详细的说明。", - {"type": "hide", "time": 500} // 消失 - ], - "10,11": [ // 守着门的老人 - "\t[老人,woman]这些是门,需要对应的钥匙打开。\n机关门必须使用特殊的开法。", - "\t[老人,woman]开门后可触发 afterOpenDoor 事件。\n\n有关事件的各种信息在下一层会有更为详细的说明。", - {"type": "hide", "time": 500} - ], - "2,10": [ // 守着楼梯、传送门、路障的老人 - "\t[少女,npc0]这些是路障、楼梯、传送门。", - "\t[少女,npc0]血网的伤害数值、中毒后每步伤害数值、衰弱时攻防下降的数值,都在 data.js 内定义。\n\n路障同样会尽量被自动寻路绕过。", - "\t[少女,npc0]楼梯和传送门需要在changeFloor中定义目标楼层和位置,可参见样板里已有的的写法。", - {"type": "hide", "time": 500} - ], - "2,8": [ // 守着第一批怪物的老人 - "\t[老人,magician]这些都是各种各样的怪物,所有怪物的数据都在enemys.js中设置。", - "\t[老人,magician]这批怪物分别为:普通、先攻、魔攻、坚固、2连击、3连击、4连击、破甲、反击、净化。", - "\t[老人,magician]打败怪物后可触发 afterBattle 事件。\n\n有关事件的各种信息在下一层会有更为详细的说明。", - {"type": "hide", "time": 500} - ], - "2,5": [ // 守着第二批怪物的老人 - "\t[老人,magician]模仿、吸血、中毒、衰弱、诅咒。\n\n请注意吸血怪需要设置value为吸血数值,可参见样板中黑暗大法师的写法。", - {"type": "hide", "time": 500} - ], - "2,3": [ // 守着第三批怪物的老人 - "\t[老人,magician]领域、夹击。\n请注意领域怪需要设置value为伤害数值,可参见样板中初级巫师的写法。", - "\t[老人,magician]夹击和领域同时发生时先计算领域,再夹击。\n自动寻路同样会尽量绕过你设置的这些点。", - {"type": "hide", "time": 500} - ], - "12,10": { // 隐藏的仙子 - "enable": false, // enable: false代表初始时禁用事件 - "data": [ - "\t[仙子,fairy]只有楼上启用事件后,才能看到我并可以和我对话来触发事件。", - {"type": "hide", "time": 500} - ] - }, + "2,10": [ + "\t[少女,npc0]这些是路障、楼梯、传送门。", + "\t[少女,npc0]血网的伤害数值、中毒后每步伤害数值、衰弱时攻防下降的数值,都在 data.js 内定义。\n\n路障同样会尽量被自动寻路绕过。", + "\t[少女,npc0]楼梯和传送门需要在changeFloor中定义目标楼层和位置,可参见样板里已有的的写法。", + { + "type": "hide", + "time": 500 + } + ], + "2,8": [ + "\t[老人,magician]这些都是各种各样的怪物,所有怪物的数据都在enemys.js中设置。", + "\t[老人,magician]这批怪物分别为:普通、先攻、魔攻、坚固、2连击、3连击、4连击、破甲、反击、净化。", + "\t[老人,magician]打败怪物后可触发 afterBattle 事件。\n\n有关事件的各种信息在下一层会有更为详细的说明。", + { + "type": "hide", + "time": 500 + } + ], + "2,5": [ + "\t[老人,magician]模仿、吸血、中毒、衰弱、诅咒。\n\n请注意吸血怪需要设置value为吸血数值,可参见样板中黑暗大法师的写法。", + { + "type": "hide", + "time": 500 + } + ], + "2,3": [ + "\t[老人,magician]领域、夹击。\n请注意领域怪需要设置value为伤害数值,可参见样板中初级巫师的写法。", + "\t[老人,magician]夹击和领域同时发生时先计算领域,再夹击。\n自动寻路同样会尽量绕过你设置的这些点。", + { + "type": "hide", + "time": 500 + } + ], + "12,10": { + "enable": false, + "data": [ + "\t[仙子,fairy]只有楼上启用事件后,才能看到我并可以和我对话来触发事件。", + { + "type": "hide", + "time": 500 + } + ] + } +}, +"changeFloor": { + "6,0": { + "floorId": "sample1", + "stair": "downFloor" }, - "changeFloor": { // 楼层转换事件;该事件不能和上面的events有冲突(同位置点),否则会被覆盖 - "6,0": {"floorId": "sample1", "stair": "downFloor"}, // 目标点:sample1层的下楼梯位置 - "0,11": {"floorId": "sample0", "loc": [0,12]}, // 目标点:sample0层的x=0,y=12位置 - "0,12": {"floorId": "sample0", "stair": "upFloor"}, // 注意,目标层有多个楼梯的话,写stair可能会导致到达位置不确定。这时候推荐写loc指明目标点位置。 - "1,12": {"floorId": "sample0", "loc": [1,12]}, - "2,12": {"floorId": "sample0", "loc": [2,12]}, - "3,12": {"floorId": "sample0", "loc": [6,1], "direction": "up"}, // 切换楼层后勇士面对上方 - "4,12": {"floorId": "sample0", "loc": [0,9], "direction": "left", "time": 1000}, // 切换楼层后勇士面对左边,切换动画1000ms - "5,12": {"floorId": "sample0", "loc": [6,10], "time": 0, "portalWithoutTrigger": false}, // time=0表示无切换时间 - "6,12": {"floorId": "sample0", "loc": [10,10], "direction": "left", "time": 1000}, + "0,11": { + "floorId": "sample0", + "loc": [ + 0, + 12 + ] }, - "afterBattle": { // 战斗后可能触发的事件列表 - "2,6": ["\t[ghostSkeleton]不可能,你怎么可能打败我!\n(一个打败怪物触发的事件)"], + "0,12": { + "floorId": "sample0", + "stair": "upFloor" }, - "afterGetItem": { // 获得道具后可能触发的事件列表 - "11,8": ["由于状态栏放不下,绿钥匙和铁门钥匙均视为tools,放入工具栏中。\n碰到绿门和铁门仍然会自动使用开门。"], - "8,6": ["由于吸血和夹击等的存在,血瓶默认自动被绕路。\n你可以修改data.js中的系统Flag来设置这一项。"], - "8,7": ["如需修改消耗品的效果,请前往 data.js ,找到并修改values内对应的具体数值即可。\n如果有更高级的需求(如每个区域宝石数值变化),详见doc文档内的做法说明。"], - "10,7": ["在 data.js 的系统Flag中设置是否启用魔防。\n如果不启用魔防则不会在状态栏显示。"], - "9,5": [ - "每层楼的 canFlyTo 决定了该楼层能否被飞到。\n\n不能被飞到的楼层也无法使用楼层传送器。", - "飞行的楼层顺序由 main.js 中 floorIds 加载顺序所决定。\n\n是否必须在楼梯边使用楼传器由 data.js 中的系统Flag所决定。" + "1,12": { + "floorId": "sample0", + "loc": [ + 1, + 12 + ] + }, + "2,12": { + "floorId": "sample0", + "loc": [ + 2, + 12 + ] + }, + "3,12": { + "floorId": "sample0", + "loc": [ + 6, + 1 ], - "10,5": ["破墙镐是破面前的墙壁还是四个方向的墙壁,由data.js中的系统Flag所决定。"], - "8,4": [ - "炸弹是只能炸面前的怪物还是四个方向的怪物,由data.js中的系统Flag所决定。\n如只能炸前方怪物则和上面的圣锤等价。\n不能被炸的怪物在enemys中可以定义,可参见样板里黑衣魔王和黑暗大法师的写法。", + "direction": "up" + }, + "4,12": { + "floorId": "sample0", + "loc": [ + 0, + 9 ], - "10,4": ["“上楼”和“下楼”的目标层由 main.js 的 floorIds顺序所决定。"], - "9,2": ["该道具默认是大黄门钥匙,如需改为钥匙盒直接修改 data.js 中的系统Flag即可。"], - "10,2": ["屠龙匕首目前未被定义,可能需要自行实现功能。\n有关如何实现一个道具功能参见doc文档。"], + "direction": "left", + "time": 1000 }, - "afterOpenDoor": { // 开完门后可能触发的事件列表 - "11,12": ["你开了一个绿门,触发了一个afterOpenDoor事件"] + "5,12": { + "floorId": "sample0", + "loc": [ + 6, + 10 + ], + "time": 0, + "portalWithoutTrigger": false }, - "cannotMove": { // 每个图块不可通行的方向 - // 可以在这里定义每个点不能前往哪个方向,例如悬崖边不能跳下去 - // "x,y": ["up", "left"], // (x,y)点不能往上和左走 - - }, - -} + "6,12": { + "floorId": "sample0", + "loc": [ + 10, + 10 + ], + "direction": "left", + "time": 1000 + } +}, +"afterBattle": { + "2,6": [ + "\t[ghostSkeleton]不可能,你怎么可能打败我!\n(一个打败怪物触发的事件)" + ] +}, +"afterGetItem": { + "11,8": [ + "由于状态栏放不下,绿钥匙和铁门钥匙均视为tools,放入工具栏中。\n碰到绿门和铁门仍然会自动使用开门。" + ], + "8,6": [ + "由于吸血和夹击等的存在,血瓶默认自动被绕路。\n你可以修改data.js中的系统Flag来设置这一项。" + ], + "8,7": [ + "如需修改消耗品的效果,请前往 data.js ,找到并修改values内对应的具体数值即可。\n如果有更高级的需求(如每个区域宝石数值变化),详见doc文档内的做法说明。" + ], + "10,7": [ + "在 data.js 的系统Flag中设置是否启用装备栏按钮。\n如果启用则装备栏按钮会代替楼层传送器按钮" + ], + "9,5": [ + "每层楼的 canFlyTo 决定了该楼层能否被飞到。\n\n不能被飞到的楼层也无法使用楼层传送器。", + "飞行的楼层顺序由 main.js 中 floorIds 加载顺序所决定。\n\n是否必须在楼梯边使用楼传器由 data.js 中的系统Flag所决定。" + ], + "10,5": [ + "破墙镐是破面前的墙壁还是四个方向的墙壁,由data.js中的系统Flag所决定。" + ], + "8,4": [ + "炸弹是只能炸面前的怪物还是四个方向的怪物,由data.js中的系统Flag所决定。\n如只能炸前方怪物则和上面的圣锤等价。\n不能被炸的怪物在enemys中可以定义,可参见样板里黑衣魔王和黑暗大法师的写法。" + ], + "10,4": [ + "“上楼”和“下楼”的目标层由 main.js 的 floorIds顺序所决定。" + ], + "9,2": [ + "该道具默认是大黄门钥匙,如需改为钥匙盒直接修改 data.js 中的系统Flag即可。" + ], + "10,2": [ + "屠龙匕首目前未被定义,可能需要自行实现功能。\n有关如何实现一个道具功能参见doc文档。" + ], + "12,7": [ + "在 data.js 的系统Flag中设置是否启用装备栏。\n如果不启用则装备会直接增加属性。" + ], + "12,6": [ + "在 data.js 的系统Flag中设置是否启用装备栏按钮。\n如果启用则装备栏按钮会替代楼传按钮。" + ], + "12,5": [ + "装备的种类由全塔属性中的equipName决定,equiptype的值就是该类型在equipName中的顺序,例如默认情况下equiptype为0代表武器,同时只有euqiptype为0的装备的攻击动画生效" + ] +}, +"afterOpenDoor": { + "11,12": [ + "你开了一个绿门,触发了一个afterOpenDoor事件" + ] +}, +"cannotMove": {}, +} \ No newline at end of file diff --git a/project/functions.js b/project/functions.js index 5c0517ad..8d6468b0 100644 --- a/project/functions.js +++ b/project/functions.js @@ -15,17 +15,22 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.material.items.bomb.text = "可以炸掉勇士四周的怪物"; if (core.flags.snowFourDirections) core.material.items.bomb.text = "可以将四周的熔岩变成平地"; + // 是否启用装备栏 + if (core.flags.equipboxBotton) { + core.statusBar.image.fly.src = core.statusBar.icons.equipbox.src; + core.flags.equipment = true; + } if (core.flags.equipment) { - core.material.items.sword1.cls = 'constants'; - core.material.items.sword2.cls = 'constants'; - core.material.items.sword3.cls = 'constants'; - core.material.items.sword4.cls = 'constants'; - core.material.items.sword5.cls = 'constants'; - core.material.items.shield1.cls = 'constants'; - core.material.items.shield2.cls = 'constants'; - core.material.items.shield3.cls = 'constants'; - core.material.items.shield4.cls = 'constants'; - core.material.items.shield5.cls = 'constants'; + core.material.items.sword1.cls = 'equips'; + core.material.items.sword2.cls = 'equips'; + core.material.items.sword3.cls = 'equips'; + core.material.items.sword4.cls = 'equips'; + core.material.items.sword5.cls = 'equips'; + core.material.items.shield1.cls = 'equips'; + core.material.items.shield2.cls = 'equips'; + core.material.items.shield3.cls = 'equips'; + core.material.items.shield4.cls = 'equips'; + core.material.items.shield5.cls = 'equips'; } }, ////// 不同难度分别设置初始属性 ////// @@ -501,40 +506,6 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = this.test = function () { console.log("插件函数执行测试"); } - - var _useEquipment = function (itemId, name, type) { // 具体的装备使用效果 - if (itemId.indexOf(name)==0) { - var now=core.getFlag(name, name+"0"); - - if (typeof core.values[now] == 'number') { - core.status.hero[type] -= core.values[now]; - } - else { - core.status.hero.atk -= core.values[now].atk || 0; - core.status.hero.def -= core.values[now].def || 0; - core.status.hero.mdef -= core.values[now].mdef || 0; - } - - if (typeof core.values[itemId] == 'number') { - core.status.hero[type] += core.values[itemId]; - } - else { - core.status.hero.atk += core.values[itemId].atk || 0; - core.status.hero.def += core.values[itemId].def || 0; - core.status.hero.mdef += core.values[itemId].mdef || 0; - } - - core.setItem(now, 1); - core.setItem(itemId, 0); - core.setFlag(name, itemId); - core.drawTip("已装备"+core.material.items[itemId].name); - } - } - - this.useEquipment = function (itemId) { // 使用装备 - _useEquipment(itemId, "sword", "atk"); - _useEquipment(itemId, "shield", "def"); - } // 可以在任何地方(如afterXXX或自定义脚本事件)调用函数,方法为 core.plugin.xxx(); diff --git a/project/icons.js b/project/icons.js index 2d7e35df..98e69bb6 100644 --- a/project/icons.js +++ b/project/icons.js @@ -203,13 +203,12 @@ icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = 'greenPotion': 22, 'yellowPotion': 23, 'lifeWand': 33, - 'sword0': 60, + 'blank': 60, 'sword1': 50, 'sword2': 51, 'sword3': 52, 'sword4': 53, 'sword5': 54, - 'shield0': 61, 'shield1': 55, 'shield2': 56, 'shield3': 57, diff --git a/project/images/icons.png b/project/images/icons.png index dbd9658b..cbf4aee4 100644 Binary files a/project/images/icons.png and b/project/images/icons.png differ diff --git a/project/images/items.png b/project/images/items.png index cce829cc..4979dc24 100644 Binary files a/project/images/items.png and b/project/images/items.png differ diff --git a/project/items.js b/project/items.js index 05fc0df0..2f1e87f2 100644 --- a/project/items.js +++ b/project/items.js @@ -46,54 +46,100 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "name": "绿血瓶" }, "sword1": { - "cls": "items", + "cls": "item", "name": "铁剑", - "text": "一把很普通的铁剑" + "text": "一把很普通的铁剑", + "equipType": 0, + "equipEffect": { + "atk": 10 + }, + "animate": "sword" }, "sword2": { "cls": "items", "name": "银剑", - "text": "一把很普通的银剑" + "text": "一把很普通的银剑", + "equipType": 0, + "equipEffect": { + "atk": 20 + }, + "animate": "sword" }, "sword3": { "cls": "items", "name": "骑士剑", - "text": "一把很普通的骑士剑" + "text": "一把很普通的骑士剑", + "equipType": 0, + "equipEffect": { + "atk": 40 + }, + "animate": "sword" }, "sword4": { "cls": "items", "name": "圣剑", - "text": "一把很普通的圣剑" + "text": "一把很普通的圣剑", + "equipType": 0, + "equipEffect": { + "atk": 80 + }, + "animate": "sword" }, "sword5": { "cls": "items", "name": "神圣剑", - "text": "一把很普通的神圣剑" + "text": "一把很普通的神圣剑", + "equipType": 0, + "equipEffect": { + "atk": 100 + }, + "animate": "sword" }, "shield1": { "cls": "items", "name": "铁盾", - "text": "一个很普通的铁盾" + "text": "一个很普通的铁盾", + "equipType": 1, + "equipEffect": { + "def": 10 + }, }, "shield2": { "cls": "items", "name": "银盾", - "text": "一个很普通的银盾" + "text": "一个很普通的银盾", + "equipType": 1, + "equipEffect": { + "def": 20 + }, }, "shield3": { "cls": "items", "name": "骑士盾", - "text": "一个很普通的骑士盾" + "text": "一个很普通的骑士盾", + "equipType": 1, + "equipEffect": { + "def": 40 + }, }, "shield4": { "cls": "items", "name": "圣盾", - "text": "一个很普通的圣盾" + "text": "一个很普通的圣盾", + "equipType": 1, + "equipEffect": { + "def": 80 + }, }, "shield5": { "cls": "items", "name": "神圣盾", - "text": "一个很普通的神圣盾" + "text": "一个很普通的神圣盾", + "equipType": 1, + "equipEffect": { + "def": 100, + "mdef": 100 + }, }, "superPotion": { "cls": "items", @@ -103,16 +149,6 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "cls": "items", "name": "金钱袋" }, - "sword0": { - "cls": "constants", - "name": "空剑", - "text": "使用可脱掉当前装备的剑。" - }, - "shield0": { - "cls": "constants", - "name": "空盾", - "text": "使用可脱掉当前装备的盾。" - }, "book": { "cls": "constants", "name": "怪物手册", @@ -232,7 +268,13 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "cls": "tools", "name": "跳跃靴", "text": "能跳跃到前方两格处" - } + }, + "blank": { + "cls": "blank", + "name": " ", + "text": " ", + "animate": "hand" + }, }, "itemEffect": { "redJewel": "core.status.hero.atk += core.values.redJewel * ratio", @@ -243,16 +285,16 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "bluePotion": "core.status.hero.hp += core.values.bluePotion * ratio", "yellowPotion": "core.status.hero.hp += core.values.yellowPotion * ratio", "greenPotion": "core.status.hero.hp += core.values.greenPotion * ratio", - "sword1": "core.status.hero.atk += core.values.sword1", - "sword2": "core.status.hero.atk += core.values.sword2", - "sword3": "core.status.hero.atk += core.values.sword3", - "sword4": "core.status.hero.atk += core.values.sword4", - "sword5": "core.status.hero.atk += core.values.sword5", - "shield1": "core.status.hero.def += core.values.shield1", - "shield2": "core.status.hero.def += core.values.shield2", - "shield3": "core.status.hero.def += core.values.shield3", - "shield4": "core.status.hero.def += core.values.shield4", - "shield5": "core.status.hero.def += core.values.shield5", + "sword1": "core.status.hero.atk += 10", + "sword2": "core.status.hero.atk += 20", + "sword3": "core.status.hero.atk += 40", + "sword4": "core.status.hero.atk += 80", + "sword5": "core.status.hero.atk += 100", + "shield1": "core.status.hero.def += 10", + "shield2": "core.status.hero.def += 20", + "shield3": "core.status.hero.def += 40", + "shield4": "core.status.hero.def += 80", + "shield5": "core.status.hero.def += 100;core.status.hero.mdef += 100", "bigKey": "core.status.hero.items.keys.yellowKey++;core.status.hero.items.keys.blueKey++;core.status.hero.items.keys.redKey++;", "superPotion": "core.status.hero.hp *= 2", "moneyPocket": "core.status.hero.money += core.values.moneyPocket" @@ -266,16 +308,16 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "bluePotion": "',生命+'+core.values.bluePotion * ratio", "yellowPotion": "',生命+'+core.values.yellowPotion * ratio", "greenPotion": "',生命+'+core.values.greenPotion * ratio", - "sword1": "',攻击+'+core.values.sword1", - "sword2": "',攻击+'+core.values.sword2", - "sword3": "',攻击+'+core.values.sword3", - "sword4": "',攻击+'+core.values.sword4", - "sword5": "',攻击+'+core.values.sword5", - "shield1": "',防御+'+core.values.shield1", - "shield2": "',防御+'+core.values.shield2", - "shield3": "',防御+'+core.values.shield3", - "shield4": "',防御+'+core.values.shield4", - "shield5": "',防御+'+core.values.shield5", + "sword1": ",攻击+10", + "sword2": ",攻击+20", + "sword3": ",攻击+40", + "sword4": ",攻击+80", + "sword5": ",攻击+100", + "shield1": ",防御+10", + "shield2": ",防御+20", + "shield3": ",防御+40", + "shield4": ",防御+80", + "shield5": ",防御+100,魔防+100", "bigKey": "',全钥匙+1'", "superPotion": "',生命值翻倍'", "moneyPocket": "',金币+'+core.values.moneyPocket" @@ -297,18 +339,6 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "weakWine": "core.setFlag('weak', false);\ncore.status.hero.atk += core.getFlag('weakAtk', core.values.weakValue);\ncore.status.hero.def += core.getFlag('weakDef', core.values.weakValue);", "curseWine": "core.setFlag('curse', false);", "superWine": "core.setFlag('poison', false);\nif (core.hasFlag('weak')) {\n core.setFlag('weak', false);\n core.status.hero.atk += core.getFlag('weakAtk', core.values.weakValue);\n core.status.hero.def += core.getFlag('weakDef', core.values.weakValue);\n}\ncore.setFlag('curse', false);", - "sword0": "core.plugin.useEquipment(itemId)", - "sword1": "core.plugin.useEquipment(itemId)", - "sword2": "core.plugin.useEquipment(itemId)", - "sword3": "core.plugin.useEquipment(itemId)", - "sword4": "core.plugin.useEquipment(itemId)", - "sword5": "core.plugin.useEquipment(itemId)", - "shield0": "core.plugin.useEquipment(itemId)", - "shield1": "core.plugin.useEquipment(itemId)", - "shield2": "core.plugin.useEquipment(itemId)", - "shield3": "core.plugin.useEquipment(itemId)", - "shield4": "core.plugin.useEquipment(itemId)", - "shield5": "core.plugin.useEquipment(itemId)", "lifeWand": "core.insertAction([\n\t{\"type\": \"input\", \"text\": \"请输入生命魔杖使用次数:(0-${item:lifeWand})\"},\n\t{\"type\": \"if\", \"condition\": \"flag:input<=item:lifeWand\",\n\t\t\"true\": [\n\t\t\t{\"type\": \"setValue\", \"name\": \"item:lifeWand\", \"value\": \"item:lifeWand-flag:input\"},\n\t\t\t{\"type\": \"setValue\", \"name\": \"status:hp\", \"value\": \"status:hp+flag:input*100\"},\n\t\t\t\"成功使用${flag:input}次生命魔杖,恢复${flag:input*100}点生命。\"\n\t\t],\n\t\t\"false\": [\"输入不合法!\"]\n\t},\n]);\ncore.setItem('lifeWand', core.itemCount('lifeWand')+1);", "jumpShoes": "core.insertAction({\"type\":\"jumpHero\",\"loc\":[core.nextX(2),core.nextY(2)]});" }, @@ -329,19 +359,6 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "weakWine": "core.hasFlag('weak')", "curseWine": "core.hasFlag('curse')", "superWine": "core.hasFlag('poison') || core.hasFlag('weak') || core.hasFlag('curse')", - "sword0": "true", - "sword1": "true", - "sword2": "true", - "sword3": "true", - "sword4": "true", - "sword5": "true", - "shield0": "true", - "shield1": "true", - "shield2": "true", - "shield3": "true", - "shield4": "true", - "shiled5": "true", - "shield5": "true", "lifeWand": "true", "jumpShoes": "var nx=core.nextX(2),ny=core.nextY(2);nx>=0&&nx=0&&ny