optimize 264
This commit is contained in:
parent
263ed22432
commit
80715f20de
@ -973,6 +973,10 @@ core.getCommonEvent(name)
|
||||
core.recoverEvents(data)
|
||||
恢复事件现场。一般用于呼出怪物手册、呼出存读档页面等时,恢复事件执行流。
|
||||
|
||||
core.checkAutoEvents()
|
||||
检测自动事件并执行。
|
||||
|
||||
|
||||
// ------ 点击状态栏图标时执行的一些操作 ------ //
|
||||
|
||||
core.openBook(fromUserAction)
|
||||
@ -1220,6 +1224,10 @@ core.quickSaveEquip(index)
|
||||
|
||||
core.quickLoadEquip()
|
||||
读取当前套装。index为读取的套装编号。
|
||||
|
||||
|
||||
core.getEquippedStatus(name)
|
||||
获得装备直接增加的属性数据。
|
||||
```
|
||||
|
||||
## loader.js
|
||||
|
||||
@ -2193,14 +2193,14 @@ UI绘制事件。此事件可以绘制闪烁光标。
|
||||
|
||||
```js
|
||||
[
|
||||
{"type": "drawSelector", "image": "winskin.png", "x": 0, "y": 0, "width": 100, "height": 100},
|
||||
{"type": "drawSelector", "image": "winskin.png", "x": 0, "y": 0, "width": 100, "height": 100, "clear": true},
|
||||
{"type": "drawSelector"} // 清除闪烁光标
|
||||
]
|
||||
```
|
||||
|
||||
image为要绘制的WindowSkin图片名;如果不填则视为“清除闪烁光标”。
|
||||
|
||||
x, y, width, height分别为要绘制的起点坐标和长宽。
|
||||
x, y, width, height分别为要绘制的起点坐标和长宽。clear可选,如果为true则在绘制前清空已有光标。
|
||||
|
||||
请注意,同时只会有一个闪烁光标存在,如果创建多个则后者会替换前者。
|
||||
|
||||
|
||||
@ -2388,15 +2388,16 @@ return code;
|
||||
*/;
|
||||
|
||||
drawSelector_s
|
||||
: '绘制闪烁光标' EvalString '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString Newline
|
||||
: '绘制闪烁光标' EvalString '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '清空已有光标' Bool Newline
|
||||
|
||||
|
||||
/* drawSelector_s
|
||||
tooltip : drawSelector:绘制闪烁光标
|
||||
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawSelector%ef%bc%9a%e7%bb%98%e5%88%b6%e9%97%aa%e7%83%81%e5%85%89%e6%a0%87
|
||||
default : ["winskin.png","0","0","100","100"]
|
||||
default : ["winskin.png","0","0","100","100", false]
|
||||
colour : this.subColor
|
||||
var code = '{"type": "drawSelector", "image": "'+EvalString_0+'", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+'},\n';
|
||||
Bool_0 = Bool_0 ? (',"clear": true') : '';
|
||||
var code = '{"type": "drawSelector", "image": "'+EvalString_0+'", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+Bool_0+'},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
@ -3540,7 +3541,7 @@ ActionParser.prototype.parseAction = function() {
|
||||
case "drawSelector": // 绘制光标
|
||||
if (data.image) {
|
||||
this.next = MotaActionBlocks['drawSelector_s'].xmlText([
|
||||
data.image, data.x, data.y, data.width, data.height, this.next
|
||||
data.image, data.x, data.y, data.width, data.height, data.clear || false, this.next
|
||||
]);
|
||||
}
|
||||
else {
|
||||
|
||||
@ -779,7 +779,7 @@ function omitedcheckUpdateFunction(event) {
|
||||
"jump_s": ["PosString_2", "PosString_3"], // 跳跃暂时只考虑终点
|
||||
"showBgFgMap_s": ["EvalString_0", "EvalString_1", "IdString_0"],
|
||||
"hideBgFgMap_s": ["EvalString_0", "EvalString_1", "IdString_0"],
|
||||
"setBgFgBlock_s": ["PosString_0", "PosString_1", "IdString_0"],
|
||||
"setBgFgBlock_s": ["EvalString_1", "EvalString_2", "IdString_0"],
|
||||
"showFloorImg_s": ["EvalString_0", "EvalString_1", "IdString_0"],
|
||||
"hideFloorImg_s": ["EvalString_0", "EvalString_1", "IdString_0"],
|
||||
"trigger_s": ["PosString_0", "PosString_1"],
|
||||
|
||||
@ -94,6 +94,12 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
||||
"_lint": true,
|
||||
"_data": "炸弹事件"
|
||||
},
|
||||
"afterPassNet": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "经过特殊地形后的事件"
|
||||
},
|
||||
"canUseQuickShop": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
|
||||
@ -489,17 +489,31 @@ events.prototype.afterGetItem = function (id, x, y, callback) {
|
||||
|
||||
////// 获得面前的物品(轻按) //////
|
||||
events.prototype.getNextItem = function (noRoute) {
|
||||
if (core.isMoving() || !core.canMoveHero() || !core.flags.enableGentleClick) return false;
|
||||
if (core.isMoving() || !core.flags.enableGentleClick) return false;
|
||||
if (this._canGetNextItem()) return this._getNextItem(null, noRoute);
|
||||
|
||||
var nextX = core.nextX(), nextY = core.nextY();
|
||||
var block = core.getBlock(nextX, nextY);
|
||||
if (block == null) return false;
|
||||
if (block.block.event.trigger == 'getItem') {
|
||||
if (!noRoute) core.status.route.push("getNext");
|
||||
this.getItem(block.block.event.id, 1, nextX, nextY);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
var directions = ["up", "down", "left", "right"].filter(function (dir) {
|
||||
return core.events._canGetNextItem(dir);
|
||||
});
|
||||
return directions.length == 1 ? this._getNextItem(directions[0]) : false;
|
||||
}
|
||||
|
||||
events.prototype._canGetNextItem = function (direction) {
|
||||
direction = direction || core.getHeroLoc('direction');
|
||||
if (!core.canMoveHero(null, null, direction)) return;
|
||||
var nx = core.getHeroLoc('x') + core.utils.scan[direction].x;
|
||||
var ny = core.getHeroLoc('y') + core.utils.scan[direction].y;
|
||||
var block = core.getBlock(nx, ny);
|
||||
return block != null && block.block.event.trigger == 'getItem';
|
||||
}
|
||||
|
||||
events.prototype._getNextItem = function (direction, noRoute) {
|
||||
direction = direction || core.getHeroLoc('direction');
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
||||
events.prototype._sys_changeFloor = function (data, callback) {
|
||||
@ -663,20 +677,26 @@ events.prototype._sys_passNet = function (data, callback) {
|
||||
|
||||
////// 经过一个路障 //////
|
||||
events.prototype.passNet = function (data) {
|
||||
if (core.hasItem('shoes')) return;
|
||||
// 血网 lavaNet 移动到 checkBlock 中处理
|
||||
if (data.event.id == 'poisonNet') { // 毒网
|
||||
core.insertAction({"type":"insert","name":"毒衰咒处理","args":[0]});
|
||||
}
|
||||
else if (data.event.id == 'weakNet') { // 衰网
|
||||
core.insertAction({"type":"insert","name":"毒衰咒处理","args":[1]});
|
||||
}
|
||||
else if (data.event.id == 'curseNet') { // 咒网
|
||||
core.insertAction({"type":"insert","name":"毒衰咒处理","args":[2]});
|
||||
if (!core.hasItem('shoes')) {
|
||||
// 血网 lavaNet 移动到 checkBlock 中处理
|
||||
if (data.event.id == 'poisonNet') { // 毒网
|
||||
core.insertAction({"type":"insert","name":"毒衰咒处理","args":[0]});
|
||||
}
|
||||
else if (data.event.id == 'weakNet') { // 衰网
|
||||
core.insertAction({"type":"insert","name":"毒衰咒处理","args":[1]});
|
||||
}
|
||||
else if (data.event.id == 'curseNet') { // 咒网
|
||||
core.insertAction({"type":"insert","name":"毒衰咒处理","args":[2]});
|
||||
}
|
||||
}
|
||||
this.afterPassNet(data.x, data.y, data.event.id);
|
||||
core.updateStatusBar();
|
||||
}
|
||||
|
||||
events.prototype.afterPassNet = function (x, y, id) {
|
||||
if (this.eventdata.afterPassNet) this.eventdata.afterPassNet(x, y, id);
|
||||
}
|
||||
|
||||
events.prototype._sys_pushBox = function (data, callback) {
|
||||
this.pushBox(data);
|
||||
if (callback) callback();
|
||||
|
||||
@ -424,3 +424,14 @@ items.prototype.quickLoadEquip = function (index) {
|
||||
|
||||
core.drawTip("成功换上" + index + "号套装");
|
||||
}
|
||||
|
||||
////// 获得装备直接增加的属性数据 //////
|
||||
items.prototype.getEquippedStatus = function (name) {
|
||||
var value = 0;
|
||||
core.status.hero.equipment.forEach(function (v) {
|
||||
if (!v || !(core.material.items[v] || {}).equip) return;
|
||||
if (core.material.items[v].equip.percentage) return;
|
||||
value += core.material.items[v].equip[name] || 0;
|
||||
});
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -590,11 +590,11 @@ maps.prototype._canMoveDirectly_bfs = function (sx, sy, locs, number, ans) {
|
||||
maps.prototype._canMoveDirectly_checkNextPoint = function (blocksObj, x, y) {
|
||||
var index = x + "," + y;
|
||||
// 该点是否有事件
|
||||
if (blocksObj[index]) return false;
|
||||
if (blocksObj[index] && (blocksObj[index].event.trigger || blocksObj[index].event.noPass)) return false;
|
||||
// 是否存在阻激夹域伤害
|
||||
if (core.status.checkBlock.damage[x + "," + y]) return false;
|
||||
if (core.status.checkBlock.damage[index]) return false;
|
||||
// 是否存在捕捉
|
||||
if (core.status.checkBlock.ambush[x + "," + y]) return false;
|
||||
if (core.status.checkBlock.ambush[index]) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
24
libs/ui.js
24
libs/ui.js
@ -644,12 +644,15 @@ ui.prototype.drawWindowSelector = function(background, x, y, w, h) {
|
||||
this._drawSelector(ctx, background, w, h);
|
||||
}
|
||||
|
||||
ui.prototype._uievent_drawSelector = function (data) {
|
||||
if (data.image == null) {
|
||||
if (main.mode != 'editor')
|
||||
core.deleteCanvas('_uievent_selector');
|
||||
return;
|
||||
ui.prototype._deleteAllSelectors = function () {
|
||||
for (var i = 0; core.dymCanvas['_uievent_selector_' + i]; i++) {
|
||||
core.deleteCanvas('_uievent_selector_' + i);
|
||||
}
|
||||
}
|
||||
|
||||
ui.prototype._uievent_drawSelector = function (data) {
|
||||
if (data.image == null) return this._deleteAllSelectors();
|
||||
if (data.clear) this,this._deleteAllSelectors();
|
||||
|
||||
var background = data.image || core.status.textAttribute.background;
|
||||
if (typeof background != 'string') return;
|
||||
@ -661,7 +664,10 @@ ui.prototype._uievent_drawSelector = function (data) {
|
||||
}
|
||||
var z = 136;
|
||||
if (core.dymCanvas.uievent) z = (parseInt(core.dymCanvas.uievent.canvas.style.zIndex) || 135) + 1;
|
||||
var ctx = core.createCanvas('_uievent_selector', x, y, w, h, z);
|
||||
var i = 0;
|
||||
while (core.dymCanvas['_uievent_selector_' + i]) i++;
|
||||
var ctx = core.createCanvas('_uievent_selector_' + i, x, y, w, h, z);
|
||||
ctx.canvas.classlist.add('_uievent_selector');
|
||||
this._drawSelector(ctx, background, w, h);
|
||||
}
|
||||
|
||||
@ -1711,13 +1717,13 @@ ui.prototype._drawBook_drawName = function (index, enemy, top, left, width) {
|
||||
core.setTextAlign('ui', 'center');
|
||||
if (enemy.specialText=='') {
|
||||
core.fillText('ui', enemy.name, left + width / 2,
|
||||
top + 35, '#DDDDDD', this._buildFont(17, true));
|
||||
top + 35, '#DDDDDD', this._buildFont(17, true), width);
|
||||
}
|
||||
else {
|
||||
core.fillText('ui', enemy.name, left + width / 2,
|
||||
top + 28, '#DDDDDD', this._buildFont(17, true));
|
||||
core.fillText('ui', enemy.specialText, left + width / 2,
|
||||
top + 50, '#FF6A6A', this._buildFont(15, true));
|
||||
top + 50, '#FF6A6A', this._buildFont(15, true), width);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2118,7 +2124,7 @@ ui.prototype._drawMaps_drawHint = function () {
|
||||
ui.prototype._drawMaps_buildData = function (index, x, y) {
|
||||
var damage = (core.status.event.data||{}).damage;
|
||||
var paint = (core.status.event.data||{}).paint;
|
||||
var all = (core.status.event.data||{}).all;
|
||||
var all = (core.status.event.data||{all: true}).all;
|
||||
if (index.damage != null) damage=index.damage;
|
||||
if (index.paint != null) paint=index.paint;
|
||||
if (index.all != null) all=index.all;
|
||||
|
||||
@ -444,6 +444,13 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
}
|
||||
*/
|
||||
|
||||
},
|
||||
"afterPassNet": function (x, y, id) {
|
||||
// 经过特殊地形后的事件;x和y为当前坐标,id为当前的图块id
|
||||
|
||||
// 这是个一次性血网的例子
|
||||
// if (id == 'lavaNet') core.removeBlock(x, y);
|
||||
|
||||
},
|
||||
"canUseQuickShop": function(shopId) {
|
||||
// 当前能否使用某个快捷商店
|
||||
|
||||
@ -380,7 +380,7 @@ p#name {
|
||||
margin-right: 10%;
|
||||
}
|
||||
|
||||
#_selector, #_uievent_selector {
|
||||
#_selector, ._uievent_selector {
|
||||
animation: selector 2s ease-in-out 0s infinite normal none running;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user