afterGetItem disableOnGentleClick

This commit is contained in:
ckcz123 2020-05-14 14:17:18 +08:00
parent 41a94b9685
commit 48bd70fbde
3 changed files with 30 additions and 14 deletions

View File

@ -34,7 +34,7 @@ autoEvent_m
/* autoEvent_m
tooltip : ?????
tooltip : 自动事件
helpUrl : https://h5mota.com/games/template/_docs/#/event
default : ["flag:__door__==2",0,true,false,false,null]
var code = {
@ -140,7 +140,7 @@ helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e5%85%a8%e5%b1%80%
default : ["攻击+1","status:money>=20+2*flag:shop1","","","rgba(255,255,255,1)",""]
colour : this.subColor
ColorString_0 = ColorString_0 ? (', "color": ['+ColorString_0+']') : '';
EvalString_2 = EvalString_2 && (', "condition": "'+EvalString_1+'"')
EvalString_2 = EvalString_2 && (', "condition": "'+EvalString_2+'"')
IdString_0 = IdString_0? (', "icon": "'+IdString_0+'"'):'';
var code = '{"text": "'+EvalString_0+'", "need": "'+EvalString_1+'"'+IdString_0+ColorString_0+EvalString_2+', "action": [\n'+action_0+']},\n';
return code;
@ -220,14 +220,17 @@ return code;
//afterGetItem 事件编辑器入口之一
afterGetItem_m
: '获取道具后' BGNL? Newline action+ BEND
: '获取道具后' '轻按时不触发' Bool BGNL? Newline action+ BEND
/* afterGetItem_m
tooltip : 系统引发的自定义事件
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e7%b3%bb%e7%bb%9f%e5%bc%95%e5%8f%91%e7%9a%84%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6
var code = '[\n'+action_0+']\n';
return code;
if (Bool_0) {
return '{"disableOnGentleClick": true, "data": [\n'+action_0+']\n}';
} else {
return '[\n'+action_0+']\n';
}
*/;
//afterOpenDoor 事件编辑器入口之一
@ -2703,7 +2706,7 @@ IgnoreChangeFloor_List
/*IgnoreChangeFloor_List ['null','true','false']*/;
Event_List
: '事件'|'战后事件'|'道具后事件'|'开门后事件'
: '普通事件'|'战后事件'|'道具后事件'|'开门后事件'
/*Event_List ['null','afterBattle','afterGetItem','afterOpenDoor']*/;
Floor_Meta_List
@ -2880,6 +2883,13 @@ ActionParser.prototype.parse = function (obj,type) {
obj.floorType||'floorId',obj.floorId,obj.stair||'loc',obj.loc[0],obj.loc[1],obj.direction,
obj.time,obj.ignoreChangeFloor
]);
case 'afterGetItem':
if (!obj) obj = [];
if (obj instanceof Array) obj = {'data': obj};
return MotaActionBlocks['afterGetItem_m'].xmlText([
obj.disableOnGentleClick||false, this.parseList(obj.data)
]);
case 'level':
if(!obj)obj={};

View File

@ -486,11 +486,11 @@ events.prototype.afterOpenDoor = function (doorId, x, y, callback) {
}
events.prototype._sys_getItem = function (data, callback) {
this.getItem(data.event.id, 1, data.x, data.y, callback);
this.getItem(data.event.id, 1, data.x, data.y, false, callback);
}
////// 获得某个物品 //////
events.prototype.getItem = function (id, num, x, y, callback) {
events.prototype.getItem = function (id, num, x, y, isGentleClick, callback) {
if (num == null) num = 1;
num = num || 1;
var itemCls = core.material.items[id].cls;
@ -519,11 +519,11 @@ events.prototype.getItem = function (id, num, x, y, callback) {
itemHint.push(id);
}
this.afterGetItem(id, x, y, callback);
this.afterGetItem(id, x, y, isGentleClick, callback);
}
events.prototype.afterGetItem = function (id, x, y, callback) {
this.eventdata.afterGetItem(id, x, y, callback);
events.prototype.afterGetItem = function (id, x, y, isGentleClick, callback) {
this.eventdata.afterGetItem(id, x, y, isGentleClick, callback);
}
////// 获得面前的物品(轻按) //////
@ -551,7 +551,7 @@ events.prototype._getNextItem = function (direction, noRoute) {
var nx = core.getHeroLoc('x') + core.utils.scan[direction].x;
var ny = core.getHeroLoc('y') + core.utils.scan[direction].y;
if (!noRoute) core.status.route.push("getNext");
this.getItem(core.getBlockId(nx, ny), 1, nx, ny);
this.getItem(core.getBlockId(nx, ny), 1, nx, ny, true);
return true;
}

View File

@ -380,6 +380,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 开一个门后触发的事件
var todo = [];
// 检查该点的获得开门后事件。
var event = core.floors[core.status.floorId].afterOpenDoor[x + "," + y];
if (event) core.unshift(todo, event);
@ -392,13 +393,18 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
if (callback) callback();
},
"afterGetItem": function (itemId, x, y, callback) {
"afterGetItem": function (itemId, x, y, isGentleClick, callback) {
// 获得一个道具后触发的事件
// itemId获得的道具IDx和y是该道具所在的坐标
// isGentleClick是否是轻按触发的
core.playSound('item.mp3');
var todo = [];
// 检查该点的获得道具后事件。
var event = core.floors[core.status.floorId].afterGetItem[x + "," + y];
if (event) core.unshift(todo, event);
if (event && (event instanceof Array || !isGentleClick || !event.disableOnGentleClick)) {
core.unshift(todo, event);
}
if (todo.length > 0) core.insertAction(todo, x, y);