Fix bug: follow, callBook & dowhile
This commit is contained in:
parent
29e9edae0e
commit
f93c6d03f0
@ -655,7 +655,7 @@ revisit常常使用在一些商人之类的地方,当用户购买物品后不
|
||||
``` js
|
||||
[
|
||||
{"type": "setBlock", "floorId": "MT1", "loc": [3,3], "number": 233}, // 将MT1层的(3,3)点变成数字233
|
||||
{"type": "setBlock", "loc": [2,1], "number": 121}, // 省略floorId则默认为本层
|
||||
{"type": "setBlock", "loc": [2,1],setVa "number": 121}, // 省略floorId则默认为本层
|
||||
{"type": "setBlock", "number": 57}, // loc也可省略,默认为当前点
|
||||
{"type": "setBlock", "number": "yellowDoor"}, // 从V2.6开始也允许写图块ID
|
||||
]
|
||||
@ -1645,7 +1645,7 @@ default可选,如果为true则显示选择项时默认选中【确定】,否
|
||||
|
||||
yes和no均为必填项,即用户点击确认或取消后执行的事件。
|
||||
|
||||
### while:循环处理
|
||||
### while:前置条件循环
|
||||
|
||||
从2.2.1样板开始,我们提供了循环处理(while事件)。
|
||||
|
||||
@ -1681,6 +1681,12 @@ yes和no均为必填项,即用户点击确认或取消后执行的事件。
|
||||
]
|
||||
```
|
||||
|
||||
### dowhile:后置条件循环
|
||||
|
||||
`type:dowhile`可以制作一个后置条件循环。
|
||||
|
||||
其写法与参数和`type:while`完全一致,不过与其不同的是,会先执行一次事件列表,再对条件进行判定,就和C/C++中的 `do {...} while (...);` 语法一样。
|
||||
|
||||
### break:跳出循环
|
||||
|
||||
使用 `{"type": "break"}` 可以跳出当前循环。
|
||||
|
||||
@ -327,6 +327,7 @@ action
|
||||
| if_1_s
|
||||
| switch_s
|
||||
| while_s
|
||||
| dowhile_s
|
||||
| break_s
|
||||
| continue_s
|
||||
| input_s
|
||||
@ -1693,11 +1694,11 @@ return code;
|
||||
*/;
|
||||
|
||||
while_s
|
||||
: '循环处理' ':' '当' expression '时' BGNL? Newline action+ BEND Newline
|
||||
: '前置条件循环' ':' '当' expression '时' BGNL? Newline action+ BEND Newline
|
||||
|
||||
/* while_s
|
||||
tooltip : while:循环处理
|
||||
helpUrl : https://h5mota.com/games/template/docs/#/event?id=while%EF%BC%9A%E5%BE%AA%E7%8E%AF%E5%A4%84%E7%90%86
|
||||
tooltip : while:前置条件循环
|
||||
helpUrl : https://h5mota.com/games/template/docs/#/event?id=while%ef%bc%9a%e5%89%8d%e7%bd%ae%e6%9d%a1%e4%bb%b6%e5%be%aa%e7%8e%af
|
||||
colour : this.eventColor
|
||||
var code = ['{"type": "while", "condition": "',expression_0,'",\n',
|
||||
'"data": [\n',action_0,'],\n',
|
||||
@ -1705,6 +1706,19 @@ var code = ['{"type": "while", "condition": "',expression_0,'",\n',
|
||||
return code;
|
||||
*/;
|
||||
|
||||
dowhile_s
|
||||
: '后置条件循环' ':' BGNL? Newline action+ BEND '当' expression '时' Newline
|
||||
|
||||
/* dowhile_s
|
||||
tooltip : dowhile:后置条件循环
|
||||
helpUrl : https://h5mota.com/games/template/docs/#/event?id=dowhile%ef%bc%9a%e5%90%8e%e7%bd%ae%e6%9d%a1%e4%bb%b6%e5%be%aa%e7%8e%af
|
||||
colour : this.eventColor
|
||||
var code = ['{"type": "dowhile", "condition": "',expression_0,'",\n',
|
||||
'"data": [\n',action_0,'],\n',
|
||||
'},\n'].join('');
|
||||
return code;
|
||||
*/;
|
||||
|
||||
break_s
|
||||
: '跳出循环' Newline
|
||||
|
||||
@ -2639,13 +2653,20 @@ ActionParser.prototype.parseAction = function() {
|
||||
this.next = MotaActionBlocks['choices_s'].xmlText([
|
||||
this.isset(data.text)?this.EvalString(data.text):null,'','',text_choices,this.next]);
|
||||
break;
|
||||
case "while": // 循环处理
|
||||
case "while": // 前置条件循环处理
|
||||
this.next = MotaActionBlocks['while_s'].xmlText([
|
||||
// MotaActionBlocks['evalString_e'].xmlText([data.condition]),
|
||||
this.tryToUseEvFlag_e('evalString_e', [data.condition]),
|
||||
this.insertActionList(data["data"]),
|
||||
this.next]);
|
||||
break;
|
||||
case "dowhile": // 后置条件循环处理
|
||||
this.next = MotaActionBlocks['dowhile_s'].xmlText([
|
||||
this.insertActionList(data["data"]),
|
||||
// MotaActionBlocks['evalString_e'].xmlText([data.condition]),
|
||||
this.tryToUseEvFlag_e('evalString_e', [data.condition]),
|
||||
this.next]);
|
||||
break;
|
||||
case "break": // 跳出循环
|
||||
this.next = MotaActionBlocks['break_s'].xmlText([
|
||||
this.next]);
|
||||
|
||||
@ -118,6 +118,7 @@ editor_blockly = function () {
|
||||
{"case": "default", "action": [{"type": "comment", "text": "当没有符合的值的场合执行default事件"}]},
|
||||
]}),
|
||||
MotaActionBlocks['while_s'].xmlText(),
|
||||
MotaActionBlocks['dowhile_s'].xmlText(),
|
||||
MotaActionBlocks['break_s'].xmlText(),
|
||||
MotaActionBlocks['continue_s'].xmlText(),
|
||||
MotaActionBlocks['revisit_s'].xmlText(),
|
||||
|
||||
@ -554,6 +554,12 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
||||
"_bool": "bool",
|
||||
"_data": "状态栏的装备按钮。若此项为true则将状态栏中的楼层转换器按钮换为装备栏按钮"
|
||||
},
|
||||
"iconInEquipbox": {
|
||||
"_leaf": true,
|
||||
"_type": "checkbox",
|
||||
"_bool": "bool",
|
||||
"_data": "在装备栏中的属性变化,是否绘制图标;如果此项开启,则会绘制图标而不是文字"
|
||||
},
|
||||
"enableAddPoint": {
|
||||
"_leaf": true,
|
||||
"_type": "checkbox",
|
||||
|
||||
@ -798,8 +798,8 @@ control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, off
|
||||
});
|
||||
(core.status.hero.followers||[]).forEach(function (t) {
|
||||
drawObjs.push({
|
||||
"img": t.img,
|
||||
"height": t.img.height/4,
|
||||
"img": core.material.images.images[t.name],
|
||||
"height": core.material.images.images[t.name].height/4,
|
||||
"heroIcon": heroIconArr[t.direction],
|
||||
"posx": 32*t.x - core.bigmap.offsetX + (t.stop?0:core.utils.scan[t.direction].x*offset),
|
||||
"posy": 32*t.y - core.bigmap.offsetY + (t.stop?0:core.utils.scan[t.direction].y*offset),
|
||||
@ -1882,6 +1882,15 @@ control.prototype.getHeroLoc = function (name) {
|
||||
return core.status.hero.loc[name];
|
||||
}
|
||||
|
||||
////// 获得某个属性的中文名 //////
|
||||
control.prototype.getStatusName = function (name) {
|
||||
var map = {
|
||||
name: "名称", lv: "等级", hpmax: "生命上限", hp: "生命", manamax: "魔力上限", mana: "魔力",
|
||||
atk: "攻击", def: "防御", mdef: "魔防", money: "金币", exp: "经验", experience: "经验", steps: "步数"
|
||||
};
|
||||
return map[name] || name;
|
||||
}
|
||||
|
||||
////// 获得某个等级的名称 //////
|
||||
control.prototype.getLvName = function (lv) {
|
||||
if (!core.status.hero) return null;
|
||||
|
||||
@ -776,6 +776,8 @@ events.prototype.startEvents = function (list, x, y, callback) {
|
||||
events.prototype.doAction = function () {
|
||||
// 清空boxAnimate和UI层
|
||||
core.clearUI();
|
||||
clearInterval(core.status.event.interval);
|
||||
core.status.event.interval = null;
|
||||
// 判定是否执行完毕
|
||||
if (this._doAction_finishEvents()) return;
|
||||
// 当前点坐标和前缀
|
||||
@ -1408,6 +1410,13 @@ events.prototype._action_while = function (data, x, y, prefix) {
|
||||
core.doAction();
|
||||
}
|
||||
|
||||
events.prototype._action_dowhile = function (data, x, y, prefix) {
|
||||
core.unshift(core.status.event.data.list,
|
||||
{"todo": core.clone(data.data), "total": core.clone(data.data), "condition": data.condition}
|
||||
);
|
||||
core.doAction();
|
||||
}
|
||||
|
||||
events.prototype._action_break = function (data, x, y, prefix) {
|
||||
core.status.event.data.list.shift();
|
||||
core.doAction();
|
||||
@ -1718,7 +1727,7 @@ events.prototype.follow = function (name) {
|
||||
core.status.hero.followers = core.status.hero.followers || [];
|
||||
if (core.material.images.images[name]
|
||||
&& core.material.images.images[name].width == 128) {
|
||||
core.status.hero.followers.push({"name": name, "img": core.material.images.images[name]});
|
||||
core.status.hero.followers.push({"name": name});
|
||||
core.gatherFollowers();
|
||||
core.clearMap('hero');
|
||||
core.drawHero();
|
||||
|
||||
@ -261,8 +261,6 @@ ui.prototype.closePanel = function () {
|
||||
}
|
||||
|
||||
ui.prototype.clearUI = function () {
|
||||
clearInterval(core.status.event.interval);
|
||||
core.status.event.interval = null;
|
||||
core.status.boxAnimateObjs = [];
|
||||
if (core.dymCanvas._selector) core.deleteCanvas("_selector");
|
||||
core.clearMap('ui');
|
||||
@ -1980,13 +1978,14 @@ ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipTy
|
||||
core.setFont('ui', this._buildFont(14, true));
|
||||
for (var name in compare) {
|
||||
var img = core.statusBar.icons[name];
|
||||
if (img) { // 绘制图标
|
||||
var text = core.getStatusName(name);
|
||||
if (img && core.flags.iconInEquipbox) { // 绘制图标
|
||||
core.drawImage('ui', img, 0, 0, 32, 32, drawOffset, y - 13, 16, 16);
|
||||
drawOffset += 20;
|
||||
}
|
||||
else { // 绘制文字
|
||||
core.fillText('ui', name + " ", drawOffset, y, '#CCCCCC');
|
||||
drawOffset += core.calWidth('ui', name + " ");
|
||||
core.fillText('ui', text + " ", drawOffset, y, '#CCCCCC');
|
||||
drawOffset += core.calWidth('ui', text + " ");
|
||||
}
|
||||
var nowValue = core.getStatus(name) * core.getBuff(name), newValue = (nowValue + compare[name]) * core.getBuff(name);
|
||||
if (equip.equip.percentage) {
|
||||
|
||||
@ -390,6 +390,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
"steelDoorWithoutKey": false,
|
||||
"equipment": false,
|
||||
"equipboxButton": false,
|
||||
"iconInEquipbox": false,
|
||||
"enableAddPoint": false,
|
||||
"enableNegativeDamage": false,
|
||||
"hatredDecrease": true,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user