editor中显示useItem和canUseItem

This commit is contained in:
YouWei Zhao 2018-03-15 16:25:16 +08:00
parent ba3ff6e178
commit 1f221a1600
4 changed files with 38 additions and 24 deletions

View File

@ -174,33 +174,47 @@ editor_file = function(editor, callback){
}); });
saveSetting('items',actionList,function (err) { saveSetting('items',actionList,function (err) {
callback([ callback([
{'items':(function(){ (function(){
var locObj=Object.assign({},editor.core.items.items[id]); var locObj_ ={};
Object.keys(editor_file.comment.items.items).forEach(function(v){ Object.keys(editor_file.comment.items).forEach(function(v){
if (!isset(editor.core.items.items[id][v])) if (isset(editor.core.items[v][id]) && v!=='items')
/* locObj[v]=editor.core.items.items[id][v]; locObj_[v]=editor.core.items[v][id];
else */ else
locObj[v]=null; locObj_[v]=null;
}); });
return locObj; locObj_['items']=(function(){
var locObj=Object.assign({},editor.core.items.items[id]);
Object.keys(editor_file.comment.items.items).forEach(function(v){
if (!isset(editor.core.items.items[id][v]))
locObj[v]=null;
});
return locObj;
})();
return locObj_;
})(), })(),
'itemEffect':editor.core.items.itemEffect[id],'itemEffectTip':editor.core.items.itemEffectTip[id]},
editor_file.comment.items, editor_file.comment.items,
err]); err]);
}); });
} else { } else {
callback([ callback([
{'items':(function(){ (function(){
var locObj=Object.assign({},editor.core.items.items[id]); var locObj_ ={};
Object.keys(editor_file.comment.items.items).forEach(function(v){ Object.keys(editor_file.comment.items).forEach(function(v){
if (!isset(editor.core.items.items[id][v])) if (isset(editor.core.items[v][id]) && v!=='items')
/* locObj[v]=editor.core.items.items[id][v]; locObj_[v]=editor.core.items[v][id];
else */ else
locObj[v]=null; locObj_[v]=null;
}); });
return locObj; locObj_['items']=(function(){
var locObj=Object.assign({},editor.core.items.items[id]);
Object.keys(editor_file.comment.items.items).forEach(function(v){
if (!isset(editor.core.items.items[id][v]))
locObj[v]=null;
});
return locObj;
})();
return locObj_;
})(), })(),
'itemEffect':editor.core.items.itemEffect[id],'itemEffectTip':editor.core.items.itemEffectTip[id]},
editor_file.comment.items, editor_file.comment.items,
null]); null]);
} }

View File

@ -7,8 +7,8 @@ items.prototype.init = function () {
this.items = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.items; this.items = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.items;
this.itemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffect; this.itemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffect;
this.itemEffectTip = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffectTip; this.itemEffectTip = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffectTip;
this.useItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItem; this.useItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItemEffect;
this.canUseItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canUseItem; this.canUseItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canUseItemEffect;
//delete(items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a); //delete(items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a);
} }

View File

@ -9,8 +9,8 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
}, },
'itemEffect':'cls为items的即捡即用类物品的效果,执行时会对这里的字符串执行eval()', 'itemEffect':'cls为items的即捡即用类物品的效果,执行时会对这里的字符串执行eval()',
'itemEffectTip':'cls为items的即捡即用类物品,在获得时左上角额外显示的文字,执行时会对这里的字符串执行eval()得到字符串', 'itemEffectTip':'cls为items的即捡即用类物品,在获得时左上角额外显示的文字,执行时会对这里的字符串执行eval()得到字符串',
'useItem':'cls为tools或contants时的使用物品效果,执行时会对这里的字符串执行eval()', 'useItemEffect':'cls为tools或contants时的使用物品效果,执行时会对这里的字符串执行eval()',
'canUseItem':'cls为tools或contants时能否使用物品的判断,执行时会return这里的字符串执行eval()后的结果', 'canUseItemEffect':'cls为tools或contants时能否使用物品的判断,执行时会return这里的字符串执行eval()后的结果',
}, },
"items_template" : {'cls': 'items', 'name': '新物品'}, "items_template" : {'cls': 'items', 'name': '新物品'},
"enemys" : { "enemys" : {

View File

@ -114,7 +114,7 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"moneyPocket":"',金币+'+core.values.moneyPocket", "moneyPocket":"',金币+'+core.values.moneyPocket",
}, },
"useItem": { "useItemEffect": {
"book": "core.ui.drawBook(0);", "book": "core.ui.drawBook(0);",
"fly": "core.ui.drawFly(core.status.hero.flyRange.indexOf(core.status.floorId));", "fly": "core.ui.drawFly(core.status.hero.flyRange.indexOf(core.status.floorId));",
"earthquake": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});", "earthquake": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
@ -145,7 +145,7 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"shield5": "core.plugin.useEquipment(itemId)", "shield5": "core.plugin.useEquipment(itemId)",
}, },
"canUseItem": { "canUseItemEffect": {
"book": "true", "book": "true",
"fly": "core.status.hero.flyRange.indexOf(core.status.floorId)>=0", "fly": "core.status.hero.flyRange.indexOf(core.status.floorId)>=0",
"pickaxe": "var able=false;\nvar ids = [];\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) &&\n (block.event.id == 'yellowWall' || block.event.id=='whiteWall' || block.event.id=='blueWall')) // 能破哪些墙\n {\n // 四个方向\n if (core.flags.pickaxeFourDirections) {\n if (Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {\n ids.push(i);\n }\n }\n else {\n if (block.x == core.nextX() && block.y == core.nextY()) {\n ids.push(i);\n }\n }\n }\n}\nif (ids.length>0) {\n core.status.event.data = ids;\n able=true;\n}\nable", "pickaxe": "var able=false;\nvar ids = [];\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) &&\n (block.event.id == 'yellowWall' || block.event.id=='whiteWall' || block.event.id=='blueWall')) // 能破哪些墙\n {\n // 四个方向\n if (core.flags.pickaxeFourDirections) {\n if (Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {\n ids.push(i);\n }\n }\n else {\n if (block.x == core.nextX() && block.y == core.nextY()) {\n ids.push(i);\n }\n }\n }\n}\nif (ids.length>0) {\n core.status.event.data = ids;\n able=true;\n}\nable",