Merge branch 'v2.x' into blockly-entrance

This commit is contained in:
YouWei Zhao 2020-05-22 21:24:50 +08:00 committed by GitHub
commit 7f79e9be59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 44 additions and 16 deletions

View File

@ -714,7 +714,7 @@ if (EvalString_0==''){
if (EvalString_1=='')title='\\t['+EvalString_0+']';
else title='\\t['+EvalString_0+','+EvalString_1+']';
}
if(EvalString_2 && !(/^(up|center|down|hero|null)(,(hero|null|\d+,\d+|\d+))?$/.test(EvalString_2))) {
if(EvalString_2 && !(/^(up|center|down|hero|this)(,(hero|null|\d+,\d+|\d+))?$/.test(EvalString_2))) {
throw new Error('对话框效果的用法请右键点击帮助');
}
EvalString_2 = EvalString_2 && ('\\b['+EvalString_2+']');
@ -754,7 +754,7 @@ if (EvalString_0==''){
if (EvalString_1=='')title='\\t['+EvalString_0+']';
else title='\\t['+EvalString_0+','+EvalString_1+']';
}
if(EvalString_2 && !(/^(up|down)(,hero)?(,([+-]?\d+),([+-]?\d+))?$/.test(EvalString_2))) {
if(EvalString_2 && !(/^(up|center|down|hero|this)(,(hero|null|\d+,\d+|\d+))?$/.test(EvalString_2))) {
throw new Error('对话框效果的用法请右键点击帮助');
}
EvalString_2 = EvalString_2 && ('\\b['+EvalString_2+']');

View File

@ -493,8 +493,9 @@ editor_blockly = function () {
var namesObj={};
namesObj.allIds = core.getAllIconIds();
namesObj.allIds = ["this"].concat(core.getAllIconIds());
namesObj.allIconIds = namesObj.allIds.concat(Object.keys(core.statusBar.icons).filter(function (x) {
return core.statusBar.icons[x] instanceof Image;
}));
namesObj.allImages = Object.keys(core.material.images.images);

View File

@ -388,6 +388,10 @@ editor_datapanel_wrapper = function (editor) {
printe('不合法的id请使用字母、数字或下划线且不能以数字开头')
return;
}
if (id == 'hero' || id == 'this' || id == 'none' || id == 'airwall') {
printe('不得使用保留关键字作为id');
return;
}
editor.file.changeIdAndIdnum(id, null, editor_mode.info, function (err) {
if (err) {
printe(err);

View File

@ -1579,10 +1579,12 @@ control.prototype._replayAction_getNext = function (action) {
control.prototype._replayAction_moveDirectly = function (action) {
if (action.indexOf("move:")!=0) return false;
// 忽略连续的瞬移事件
while (core.status.replay.toReplay.length>0 &&
core.status.replay.toReplay[0].indexOf('move:')==0) {
core.status.route.push(action);
action = core.status.replay.toReplay.shift();
if (!core.hasFlag('poison')) {
while (core.status.replay.toReplay.length>0 &&
core.status.replay.toReplay[0].indexOf('move:')==0) {
core.status.route.push(action);
action = core.status.replay.toReplay.shift();
}
}
var pos=action.substring(5).split(":");

View File

@ -988,7 +988,7 @@ events.prototype.insertCommonEvent = function (name, x, y, callback, addToLast)
if (callback) callback();
return;
}
this.insertAction(commonEvent, x, y, callback, addToLast);
this.insertAction({"type": "dowhile", "condition": "false", "data": commonEvent}, x, y, callback, addToLast);
}
////// 获得一个公共事件 //////

View File

@ -53,6 +53,7 @@ icons.prototype._getAnimateFrames = function (cls, useOriginValue) {
icons.prototype.getTilesetOffset = function (id) {
if (typeof id == 'string') {
id = core.getIdOfThis(id);
// Tileset的ID必须是 X+数字 的形式
if (!/^X\d+$/.test(id)) return null;
id = parseInt(id.substring(1));
@ -74,4 +75,4 @@ icons.prototype.getTilesetOffset = function (id) {
startOffset += this.tilesetStartOffset;
}
return null;
}
}

View File

@ -79,6 +79,7 @@ maps.prototype._mapIntoBlocks = function (map, floor, floorId) {
////// 从ID获得数字 //////
maps.prototype.getNumberById = function (id) {
id = this.getIdOfThis(id);
core.status.id2number = core.status.id2number || {};
if (core.status.id2number[id] != null) return core.status.id2number[id];
return core.status.id2number[id] = this._getNumberById(id);
@ -109,6 +110,13 @@ maps.prototype.getBlockById = function (id) {
return this.getBlockByNumber(this.getNumberById(id));
}
maps.prototype.getIdOfThis = function (id) {
if (id != 'this') return id;
if (core.status.event.id != 'action') return id;
if (!core.status.event.data || core.status.event.data.x == null || core.status.event.data.y == null) return id;
return core.getBlockId(core.status.event.data.x, core.status.event.data.y) || id;
}
////// 数字和ID的对应关系 //////
maps.prototype.initBlock = function (x, y, id, addInfo, eventFloor) {
var disable = null;
@ -562,8 +570,6 @@ maps.prototype._canMoveDirectly_checkGlobal = function () {
if (core.status.thisMap.cannotMoveDirectly) return false;
// flag:cannotMoveDirectly为true不能
if (core.hasFlag('cannotMoveDirectly')) return false;
// 中毒状态:不能
if (core.hasFlag('poison')) return false;
return true;
}

View File

@ -596,7 +596,7 @@ ui.prototype.closePanel = function () {
if (core.status.hero && core.status.hero.flags) {
// 清除全部临时变量
Object.keys(core.status.hero.flags).forEach(function (name) {
if (name.startsWith("@temp@")) {
if (name.startsWith("@temp@") || /^arg\d+$/.test(name)) {
delete core.status.hero.flags[name];
}
});
@ -752,7 +752,7 @@ ui.prototype._getPosition = function (content) {
py = core.status.event.data.y;
}
content = content.replace("\b", "\\b")
.replace(/\\b\[(up|center|down|hero|null)(,(hero|null|\d+,\d+|\d+))?]/g, function (s0, s1, s2, s3) {
.replace(/\\b\[(up|center|down|hero|this)(,(hero|null|\d+,\d+|\d+))?]/g, function (s0, s1, s2, s3) {
pos = s1;
if (s3 == 'hero' || s1=='hero' && !s3) {
px = core.status.hero.loc.x;
@ -776,7 +776,7 @@ ui.prototype._getPosition = function (content) {
noPeak = core.getBlockId(px, py) == null;
}
}
if(pos=='hero' || pos=='null'){
if(pos=='hero' || pos=='this'){
pos = py==null?'center':(py>=core.__HALF_SIZE__? 'up':'down');
}
return "";
@ -974,6 +974,7 @@ ui.prototype._getDrawableIconInfo = function (id) {
if (id && id.indexOf('flag:') === 0) {
id = core.getFlag(id.substring(5), id);
}
id = core.getIdOfThis(id);
var image = null, icon = null;
["terrains","animates","items","npcs","enemys"].forEach(function (v) {
if (core.material.icons[v][id] != null) {
@ -1401,10 +1402,12 @@ ui.prototype._drawTextBox_drawTitleAndIcon = function (titleInfo, hPos, vPos, al
// --- 勇士
if (titleInfo.image == core.material.images.hero) {
if (core.status.hero.animate) {
var direction = core.getHeroLoc('direction');
if (direction == 'up') direction = 'down';
core.status.boxAnimateObjs.push({
'bgx': hPos.left + 15, 'bgy': image_top, 'bgWidth': 32, 'bgHeight': titleInfo.height,
'x': hPos.left + 15, 'y': image_top, 'height': titleInfo.height, 'animate': 4,
'image': titleInfo.image, 'pos': core.material.icons.hero[core.getHeroLoc('direction')].loc * titleInfo.height
'image': titleInfo.image, 'pos': core.material.icons.hero[direction].loc * titleInfo.height
})
} else {
core.clearMap('ui', hPos.left + 15, image_top, 32, titleInfo.height);

View File

@ -1287,6 +1287,14 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 判定能否瞬移到该点
if (ignoreSteps == null) ignoreSteps = core.canMoveDirectly(x, y);
if (ignoreSteps >= 0) {
// 中毒也允许瞬移
if (core.hasFlag('poison')) {
var damage = ignoreSteps * core.values.poisonDamage;
if (damage >= core.status.hero.hp) return false;
core.status.hero.statistics.poisonDamage += damage;
core.status.hero.hp -= damage;
}
core.clearMap('hero');
// 获得勇士最后的朝向
var lastDirection = core.status.route[core.status.route.length - 1];
@ -1301,6 +1309,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 统计信息
core.status.hero.statistics.moveDirectly++;
core.status.hero.statistics.ignoreSteps += ignoreSteps;
if (core.hasFlag('poison')) {
core.updateStatusBar();
}
return true;
}
return false;

View File

@ -67,7 +67,7 @@
(已完成!) 勇士帧动画
(不处理;现在静止状态可以有帧动画了,所以不考虑行走过程动画) 行走动画
合并main中一些设置内容
\t[this], 勇士朝下flag:arg清理瞬移扣血
(已完成!) \t[this], 勇士朝下flag:arg清理瞬移扣血
-------------