optimize 264

This commit is contained in:
ckcz123 2019-10-21 14:33:33 +08:00
parent 263ed22432
commit 80715f20de
11 changed files with 99 additions and 40 deletions

View File

@ -973,6 +973,10 @@ core.getCommonEvent(name)
core.recoverEvents(data) core.recoverEvents(data)
恢复事件现场。一般用于呼出怪物手册、呼出存读档页面等时,恢复事件执行流。 恢复事件现场。一般用于呼出怪物手册、呼出存读档页面等时,恢复事件执行流。
core.checkAutoEvents()
检测自动事件并执行。
// ------ 点击状态栏图标时执行的一些操作 ------ // // ------ 点击状态栏图标时执行的一些操作 ------ //
core.openBook(fromUserAction) core.openBook(fromUserAction)
@ -1220,6 +1224,10 @@ core.quickSaveEquip(index)
core.quickLoadEquip() core.quickLoadEquip()
读取当前套装。index为读取的套装编号。 读取当前套装。index为读取的套装编号。
core.getEquippedStatus(name)
获得装备直接增加的属性数据。
``` ```
## loader.js ## loader.js

View File

@ -2193,14 +2193,14 @@ UI绘制事件。此事件可以绘制闪烁光标。
```js ```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"} // 清除闪烁光标 {"type": "drawSelector"} // 清除闪烁光标
] ]
``` ```
image为要绘制的WindowSkin图片名如果不填则视为“清除闪烁光标”。 image为要绘制的WindowSkin图片名如果不填则视为“清除闪烁光标”。
x, y, width, height分别为要绘制的起点坐标和长宽。 x, y, width, height分别为要绘制的起点坐标和长宽。clear可选如果为true则在绘制前清空已有光标。
请注意,同时只会有一个闪烁光标存在,如果创建多个则后者会替换前者。 请注意,同时只会有一个闪烁光标存在,如果创建多个则后者会替换前者。

View File

@ -2388,15 +2388,16 @@ return code;
*/; */;
drawSelector_s drawSelector_s
: '绘制闪烁光标' EvalString '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString Newline : '绘制闪烁光标' EvalString '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '清空已有光标' Bool Newline
/* drawSelector_s /* drawSelector_s
tooltip : drawSelector绘制闪烁光标 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 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 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; return code;
*/; */;
@ -3540,7 +3541,7 @@ ActionParser.prototype.parseAction = function() {
case "drawSelector": // 绘制光标 case "drawSelector": // 绘制光标
if (data.image) { if (data.image) {
this.next = MotaActionBlocks['drawSelector_s'].xmlText([ 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 { else {

View File

@ -779,7 +779,7 @@ function omitedcheckUpdateFunction(event) {
"jump_s": ["PosString_2", "PosString_3"], // 跳跃暂时只考虑终点 "jump_s": ["PosString_2", "PosString_3"], // 跳跃暂时只考虑终点
"showBgFgMap_s": ["EvalString_0", "EvalString_1", "IdString_0"], "showBgFgMap_s": ["EvalString_0", "EvalString_1", "IdString_0"],
"hideBgFgMap_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"], "showFloorImg_s": ["EvalString_0", "EvalString_1", "IdString_0"],
"hideFloorImg_s": ["EvalString_0", "EvalString_1", "IdString_0"], "hideFloorImg_s": ["EvalString_0", "EvalString_1", "IdString_0"],
"trigger_s": ["PosString_0", "PosString_1"], "trigger_s": ["PosString_0", "PosString_1"],

View File

@ -94,6 +94,12 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_lint": true, "_lint": true,
"_data": "炸弹事件" "_data": "炸弹事件"
}, },
"afterPassNet": {
"_leaf": true,
"_type": "textarea",
"_lint": true,
"_data": "经过特殊地形后的事件"
},
"canUseQuickShop": { "canUseQuickShop": {
"_leaf": true, "_leaf": true,
"_type": "textarea", "_type": "textarea",

View File

@ -489,17 +489,31 @@ events.prototype.afterGetItem = function (id, x, y, callback) {
////// 获得面前的物品(轻按) ////// ////// 获得面前的物品(轻按) //////
events.prototype.getNextItem = function (noRoute) { 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 directions = ["up", "down", "left", "right"].filter(function (dir) {
var block = core.getBlock(nextX, nextY); return core.events._canGetNextItem(dir);
if (block == null) return false; });
if (block.block.event.trigger == 'getItem') { return directions.length == 1 ? this._getNextItem(directions[0]) : false;
if (!noRoute) core.status.route.push("getNext"); }
this.getItem(block.block.event.id, 1, nextX, nextY);
return true; events.prototype._canGetNextItem = function (direction) {
} direction = direction || core.getHeroLoc('direction');
return false; 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) { events.prototype._sys_changeFloor = function (data, callback) {
@ -663,20 +677,26 @@ events.prototype._sys_passNet = function (data, callback) {
////// 经过一个路障 ////// ////// 经过一个路障 //////
events.prototype.passNet = function (data) { events.prototype.passNet = function (data) {
if (core.hasItem('shoes')) return; if (!core.hasItem('shoes')) {
// 血网 lavaNet 移动到 checkBlock 中处理 // 血网 lavaNet 移动到 checkBlock 中处理
if (data.event.id == 'poisonNet') { // 毒网 if (data.event.id == 'poisonNet') { // 毒网
core.insertAction({"type":"insert","name":"毒衰咒处理","args":[0]}); core.insertAction({"type":"insert","name":"毒衰咒处理","args":[0]});
} }
else if (data.event.id == 'weakNet') { // 衰网 else if (data.event.id == 'weakNet') { // 衰网
core.insertAction({"type":"insert","name":"毒衰咒处理","args":[1]}); core.insertAction({"type":"insert","name":"毒衰咒处理","args":[1]});
} }
else if (data.event.id == 'curseNet') { // 咒网 else if (data.event.id == 'curseNet') { // 咒网
core.insertAction({"type":"insert","name":"毒衰咒处理","args":[2]}); core.insertAction({"type":"insert","name":"毒衰咒处理","args":[2]});
}
} }
this.afterPassNet(data.x, data.y, data.event.id);
core.updateStatusBar(); 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) { events.prototype._sys_pushBox = function (data, callback) {
this.pushBox(data); this.pushBox(data);
if (callback) callback(); if (callback) callback();

View File

@ -424,3 +424,14 @@ items.prototype.quickLoadEquip = function (index) {
core.drawTip("成功换上" + 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;
}

View File

@ -590,11 +590,11 @@ maps.prototype._canMoveDirectly_bfs = function (sx, sy, locs, number, ans) {
maps.prototype._canMoveDirectly_checkNextPoint = function (blocksObj, x, y) { maps.prototype._canMoveDirectly_checkNextPoint = function (blocksObj, x, y) {
var index = 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; return true;
} }

View File

@ -644,12 +644,15 @@ ui.prototype.drawWindowSelector = function(background, x, y, w, h) {
this._drawSelector(ctx, background, w, h); this._drawSelector(ctx, background, w, h);
} }
ui.prototype._uievent_drawSelector = function (data) { ui.prototype._deleteAllSelectors = function () {
if (data.image == null) { for (var i = 0; core.dymCanvas['_uievent_selector_' + i]; i++) {
if (main.mode != 'editor') core.deleteCanvas('_uievent_selector_' + i);
core.deleteCanvas('_uievent_selector');
return;
} }
}
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; var background = data.image || core.status.textAttribute.background;
if (typeof background != 'string') return; if (typeof background != 'string') return;
@ -661,7 +664,10 @@ ui.prototype._uievent_drawSelector = function (data) {
} }
var z = 136; var z = 136;
if (core.dymCanvas.uievent) z = (parseInt(core.dymCanvas.uievent.canvas.style.zIndex) || 135) + 1; 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); this._drawSelector(ctx, background, w, h);
} }
@ -1711,13 +1717,13 @@ ui.prototype._drawBook_drawName = function (index, enemy, top, left, width) {
core.setTextAlign('ui', 'center'); core.setTextAlign('ui', 'center');
if (enemy.specialText=='') { if (enemy.specialText=='') {
core.fillText('ui', enemy.name, left + width / 2, core.fillText('ui', enemy.name, left + width / 2,
top + 35, '#DDDDDD', this._buildFont(17, true)); top + 35, '#DDDDDD', this._buildFont(17, true), width);
} }
else { else {
core.fillText('ui', enemy.name, left + width / 2, core.fillText('ui', enemy.name, left + width / 2,
top + 28, '#DDDDDD', this._buildFont(17, true)); top + 28, '#DDDDDD', this._buildFont(17, true));
core.fillText('ui', enemy.specialText, left + width / 2, 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) { ui.prototype._drawMaps_buildData = function (index, x, y) {
var damage = (core.status.event.data||{}).damage; var damage = (core.status.event.data||{}).damage;
var paint = (core.status.event.data||{}).paint; 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.damage != null) damage=index.damage;
if (index.paint != null) paint=index.paint; if (index.paint != null) paint=index.paint;
if (index.all != null) all=index.all; if (index.all != null) all=index.all;

View File

@ -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) { "canUseQuickShop": function(shopId) {
// 当前能否使用某个快捷商店 // 当前能否使用某个快捷商店

View File

@ -380,7 +380,7 @@ p#name {
margin-right: 10%; margin-right: 10%;
} }
#_selector, #_uievent_selector { #_selector, ._uievent_selector {
animation: selector 2s ease-in-out 0s infinite normal none running; animation: selector 2s ease-in-out 0s infinite normal none running;
} }