showHero & hideHero

This commit is contained in:
ckcz123 2019-08-13 11:23:37 +08:00
parent c210778a2a
commit c995f81017
7 changed files with 146 additions and 92 deletions

View File

@ -888,6 +888,14 @@ name是可选的代表目标行走图的文件名。
使用`{"type": "showStatusBar"}`会重新显示状态栏。
### hideHero隐藏勇士
使用`{"type": "hideHero"}`可以隐藏勇士。
### showHero显示勇士
使用`{"type": "showHero"}`会重新显示勇士。
### updateEnemys更新怪物数据
使用 `{"type": "updateEnemys"}` 可以动态修改怪物数据。

View File

@ -562,8 +562,6 @@ core.statusBar.speed.innerHTML = core.getFlag('speed', 0);
如果flag:skill不为0则代表当前处于某个技能开启状态且状态栏显示flag:skillName值。伤害计算函数中只需要对flag:skill进行处理即可。
!> 关于魔力上限样板中默认没有提供status:manamax
### 状态栏的显示
从V2.5开始,魔力值和技能名的状态栏项目已经被添加,可以直接使用。

View File

@ -282,6 +282,8 @@ action
| update_s
| showStatusBar_s
| hideStatusBar_s
| showHero_s
| hideHero_s
| updateEnemys_s
| sleep_s
| wait_s
@ -995,6 +997,30 @@ var code = '{"type": "hideStatusBar"'+Bool_0+'},\n';
return code;
*/;
showHero_s
: '显示勇士' Newline
/* showHero_s
tooltip : showHero: 显示勇士
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showHero%3a+%e6%98%be%e7%a4%ba%e5%8b%87%e5%a3%ab
colour : this.soundColor
var code = '{"type": "showHero"},\n';
return code;
*/;
hideHero_s
: '隐藏勇士' Newline
/* hideHero_s
tooltip : hideHero: 隐藏勇士
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=hideHero%ef%bc%9a%e9%9a%90%e8%97%8f%e5%8b%87%e5%a3%ab
colour : this.soundColor
var code = '{"type": "hideHero"},\n';
return code;
*/;
updateEnemys_s
: '更新怪物数据' Newline
@ -3313,6 +3339,14 @@ ActionParser.prototype.parseAction = function() {
this.next = MotaActionBlocks['hideStatusBar_s'].xmlText([
data.toolbox||false,this.next]);
break;
case "showHero":
this.next = MotaActionBlocks['showHero_s'].xmlText([
this.next]);
break;
case "hideHero":
this.next = MotaActionBlocks['hideHero_s'].xmlText([
this.next]);
break;
case "updateEnemys":
this.next = MotaActionBlocks['updateEnemys_s'].xmlText([
this.next]);

View File

@ -154,6 +154,8 @@ editor_blockly = function () {
MotaActionBlocks['moveViewport_s'].xmlText(),
MotaActionBlocks['showStatusBar_s'].xmlText(),
MotaActionBlocks['hideStatusBar_s'].xmlText(),
MotaActionBlocks['showHero_s'].xmlText(),
MotaActionBlocks['hideHero_s'].xmlText(),
MotaActionBlocks['setCurtain_0_s'].xmlText(),
MotaActionBlocks['setCurtain_1_s'].xmlText(),
MotaActionBlocks['screenFlash_s'].xmlText(),

View File

@ -772,11 +772,13 @@ control.prototype.drawHero = function (status, offset) {
core.clearAutomaticRouteNode(x+dx, y+dy);
core.clearMap('hero');
this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) {
core.drawImage('hero', block.img, block.heroIcon[block.status]*block.width,
block.heroIcon.loc * block.height, block.width, block.height,
block.posx+(32-block.width)/2, block.posy+32-block.height, block.width, block.height);
});
if (!core.hasFlag('hideHero')) {
this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) {
core.drawImage('hero', block.img, block.heroIcon[block.status]*block.width,
block.heroIcon.loc * block.height, block.width, block.height,
block.posx+(32-block.width)/2, block.posy+32-block.height, block.width, block.height);
});
}
core.control.updateViewport();
core.setGameCanvasTranslate('hero', 0, 0);

View File

@ -790,7 +790,7 @@ events.prototype.doEvent = function (data, x, y, prefix) {
}
if (this["_action_" + type]) return this["_action_" + type](data, x, y, prefix);
core.insertAction("未知的自定义事件: " + type + "");
core.doAction();
setTimeout(core.doAction);
}
events.prototype.setEvents = function (list, x, y, callback) {
@ -814,7 +814,7 @@ events.prototype.startEvents = function (list, x, y, callback) {
// 停止勇士
core.waitHeroToStop(function () {
core.lockControl();
core.doAction();
setTimeout(core.doAction);
});
}
@ -863,7 +863,7 @@ events.prototype._popEvents = function (current, prefix) {
else {
core.status.event.data.list.shift(); // remove stack
}
core.doAction();
setTimeout(core.doAction);
return true;
}
return false;
@ -908,7 +908,7 @@ events.prototype.recoverEvents = function (data) {
core.status.event.id = 'action';
core.status.event.data = data;
setTimeout(function () {
core.doAction();
setTimeout(core.doAction);
}, 30);
return true;
}
@ -919,7 +919,7 @@ events.prototype.recoverEvents = function (data) {
events.prototype.__action_checkReplaying = function () {
if (core.isReplaying()) {
core.doAction();
setTimeout(core.doAction);
return true;
}
return false;
@ -947,7 +947,7 @@ events.prototype.__action_doAsyncFunc = function (isAsync, func) {
var parameters = Array.prototype.slice.call(arguments, 2);
if (isAsync) {
func.apply(this, parameters);
core.doAction();
setTimeout(core.doAction);
}
else {
func.apply(this, parameters.concat(core.doAction));
@ -971,7 +971,7 @@ events.prototype._action_scrollText = function (data, x, y, prefix) {
}
events.prototype._action_comment = function (data, x, y, prefix) {
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setText = function (data, x, y, prefix) {
@ -992,12 +992,12 @@ events.prototype._action_setText = function (data, x, y, prefix) {
}
});
core.setFlag('textAttribute', core.status.textAttribute);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_tip = function (data, x, y, prefix) {
core.drawTip(core.replaceText(data.text), data.icon);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_show = function (data, x, y, prefix) {
@ -1009,7 +1009,7 @@ events.prototype._action_show = function (data, x, y, prefix) {
data.loc.forEach(function (t) {
core.showBlock(t[0], t[1], data.floorId);
});
core.doAction();
setTimeout(core.doAction);
}
}
@ -1025,7 +1025,7 @@ events.prototype._action_hide = function (data, x, y, prefix) {
data.loc.forEach(function (t) {
core.removeBlock(t[0], t[1], data.floorId)
});
core.doAction();
setTimeout(core.doAction);
}
}
@ -1034,7 +1034,7 @@ events.prototype._action_setBlock = function (data, x, y, prefix) {
data.loc.forEach(function (t) {
core.setBlock(data.number, t[0], t[1], data.floorId);
});
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_showFloorImg = function (data, x, y, prefix) {
@ -1058,17 +1058,17 @@ events.prototype._action_setBgFgBlock = function (data, x, y, prefix) {
data.loc.forEach(function (t) {
core.setBgFgBlock(data.name, data.number, t[0], t[1], data.floorId);
});
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_follow = function (data, x, y, prefix) {
this.follow(data.name);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_unfollow = function (data, x, y, prefix) {
this.unfollow(data.name);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_animate = function (data, x, y, prefix) {
@ -1085,7 +1085,7 @@ events.prototype._action_setViewport = function (data, x, y, prefix) {
var loc = this.__action_getLoc(data.loc, x, y, prefix);
core.setViewport(32 * loc[0], 32 * loc[1]);
}
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_moveViewport = function (data, x, y, prefix) {
@ -1125,7 +1125,7 @@ events.prototype._action_changePos = function (data, x, y, prefix) {
core.setHeroLoc('y', loc[1]);
if (data.direction) core.setHeroLoc('direction', data.direction);
core.drawHero();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_showImage = function (data, x, y, prefix) {
@ -1149,7 +1149,7 @@ events.prototype._action_hideImage = function (data, x, y, prefix) {
events.prototype._action_showGif = function (data, x, y, prefix) {
var loc = this.__action_getLoc(data.loc, 0, 0, prefix);
this.showGif(data.name, loc[0], loc[1]);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_moveImage = function (data, x, y, prefix) {
@ -1165,12 +1165,12 @@ events.prototype._action_setCurtain = function (data, x, y, prefix) {
if (data.async) {
core.setCurtain(data.color, data.time);
core.setFlag('__color__', data.color || null);
core.doAction();
setTimeout(core.doAction);
}
else {
core.setCurtain(data.color, data.time, function () {
core.setFlag('__color__', data.color || null);
core.doAction();
setTimeout(core.doAction);
});
}
}
@ -1184,7 +1184,7 @@ events.prototype._action_setWeather = function (data, x, y, prefix) {
if (data.name == 'rain' || data.name == 'snow' || data.name == 'fog')
core.setFlag('__weather__', [data.name, data.level]);
else core.removeFlag('__weather__');
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_openDoor = function (data, x, y, prefix) {
@ -1195,7 +1195,7 @@ events.prototype._action_openDoor = function (data, x, y, prefix) {
}
else {
core.removeBlock(loc[0], loc[1], floorId);
core.doAction();
setTimeout(core.doAction);
}
}
@ -1211,7 +1211,7 @@ events.prototype._action_useItem = function (data, x, y, prefix) {
}
else {
core.drawTip("当前无法使用" + ((core.material.items[data.id] || {}).name || "未知道具"));
core.doAction();
setTimeout(core.doAction);
}
}
@ -1221,12 +1221,12 @@ events.prototype._action_openShop = function (data, x, y, prefix) {
if (!core.isReplaying())
this.openShop(data.id);
if (core.status.event.id == 'action')
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_disableShop = function (data, x, y, prefix) {
this.disableQuickShop(data.id);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_battle = function (data, x, y, prefix) {
@ -1252,7 +1252,7 @@ events.prototype._action_trigger = function (data, x, y, prefix) {
return;
}
}
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_insert = function (data, x, y, prefix) {
@ -1277,44 +1277,44 @@ events.prototype._action_insert = function (data, x, y, prefix) {
var event = (core.floors[floorId][which]||[])[loc[0] + "," + loc[1]];
if (event) this.insertAction(event.data || event);
}
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_playBgm = function (data, x, y, prefix) {
core.playBgm(data.name);
core.setFlag("__bgm__", data.keep ? data.name : null);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_pauseBgm = function (data, x, y, prefix) {
core.pauseBgm();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_resumeBgm = function (data, x, y, prefix) {
core.resumeBgm();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_loadBgm = function (data, x, y, prefix) {
core.loadBgm(data.name);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_freeBgm = function (data, x, y, prefix) {
core.freeBgm(data.name);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_playSound = function (data, x, y, prefix) {
if (data.stop) core.stopSound();
core.playSound(data.name);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_stopSound = function (data, x, y, prefix) {
core.stopSound();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setVolume = function (data, x, y, prefix) {
@ -1325,7 +1325,7 @@ events.prototype._action_setVolume = function (data, x, y, prefix) {
events.prototype._action_setValue = function (data, x, y, prefix) {
this.setValue(data.name, data.value, prefix);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setValue2 = function (data, x, y, prefix) {
@ -1334,32 +1334,32 @@ events.prototype._action_setValue2 = function (data, x, y, prefix) {
events.prototype._action_addValue = function (data, x, y, prefix) {
this.addValue(data.name, data.value, prefix);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setFloor = function (data, x, y, prefix) {
this.setFloorInfo(data.name, data.value, data.floorId, prefix);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setGlobalAttribute = function (data, x, y, prefix) {
this.setGlobalAttribute(data.name, data.value);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setGlobalValue = function (data, x, y, prefix) {
core.values[data.name] = data.value;
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setGlobalFlag = function (data, x, y, prefix) {
this.setGlobalFlag(data.name, data.value);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setHeroIcon = function (data, x, y, prefix) {
this.setHeroIcon(data.name);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_input = function (data, x, y, prefix) {
@ -1367,7 +1367,7 @@ events.prototype._action_input = function (data, x, y, prefix) {
value = Math.abs(parseInt(value) || 0);
core.status.route.push("input:" + value);
core.setFlag("input", value);
core.doAction();
setTimeout(core.doAction);
});
}
@ -1376,7 +1376,7 @@ events.prototype._action_input2 = function (data, x, y, prefix) {
value = value || "";
core.status.route.push("input2:" + core.encodeBase64(value));
core.setFlag("input", value);
core.doAction();
setTimeout(core.doAction);
});
}
@ -1406,7 +1406,7 @@ events.prototype._action_if = function (data, x, y, prefix) {
core.events.insertAction(data["true"])
else
core.events.insertAction(data["false"])
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_switch = function (data, x, y, prefix) {
@ -1421,7 +1421,7 @@ events.prototype._action_switch = function (data, x, y, prefix) {
}
}
core.insertAction(list);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_choices = function (data, x, y, prefix) {
@ -1439,7 +1439,7 @@ events.prototype._action_choices = function (data, x, y, prefix) {
setTimeout(function () {
core.status.route.push("choices:" + index);
core.insertAction(data.choices[index].action);
core.doAction();
setTimeout(core.doAction);
}, core.status.replay.speed == 24 ? 1 : 750 / Math.max(1, core.status.replay.speed))
}
else {
@ -1462,7 +1462,7 @@ events.prototype._action_confirm = function (data, x, y, prefix) {
core.status.route.push("choices:" + index);
if (index == 0) core.insertAction(data.yes);
else core.insertAction(data.no);
core.doAction();
setTimeout(core.doAction);
}, core.status.replay.speed == 24 ? 1 : 750 / Math.max(1, core.status.replay.speed))
}
else {
@ -1482,19 +1482,19 @@ events.prototype._action_while = function (data, x, y, prefix) {
{"todo": core.clone(data.data), "total": core.clone(data.data), "condition": data.condition}
);
}
core.doAction();
setTimeout(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();
setTimeout(core.doAction);
}
events.prototype._action_break = function (data, x, y, prefix) {
core.status.event.data.list.shift();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_continue = function (data, x, y, prefix) {
@ -1504,7 +1504,7 @@ events.prototype._action_continue = function (data, x, y, prefix) {
else {
core.status.event.data.list.shift();
}
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_win = function (data, x, y, prefix) {
@ -1529,28 +1529,40 @@ events.prototype._action_function = function (data, x, y, prefix) {
main.log(e);
}
if (!data.async)
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_update = function (data, x, y, prefix) {
core.updateStatusBar();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_showStatusBar = function (data, x, y, prefix) {
core.showStatusBar();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_hideStatusBar = function (data, x, y, prefix) {
core.hideStatusBar(data.toolbox);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_showHero = function (data, x, y, prefix) {
core.removeFlag('hideHero');
core.drawHero();
setTimeout(core.doAction);
}
events.prototype._action_hideHero = function (data, x, y, prefix) {
core.setFlag('hideHero', true);
core.drawHero();
setTimeout(core.doAction);
}
events.prototype._action_updateEnemys = function (data, x, y, prefix) {
core.enemys.updateEnemys();
core.updateStatusBar();
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_vibrate = function (data, x, y, prefix) {
@ -1560,7 +1572,7 @@ events.prototype._action_vibrate = function (data, x, y, prefix) {
events.prototype._action_sleep = function (data, x, y, prefix) {
core.timeout.sleepTimeout = setTimeout(function () {
core.timeout.sleepTimeout = null;
core.doAction();
setTimeout(core.doAction);
}, core.isReplaying() ? Math.min(data.time, 20) : data.time);
}
@ -1577,7 +1589,7 @@ events.prototype._action_wait = function (data, x, y, prefix) {
core.stopReplay();
core.insertAction(["录像文件出错,请在控制台查看报错信息。", {"type": "exit"}]);
}
core.doAction();
setTimeout(core.doAction);
return;
}
}
@ -1609,7 +1621,7 @@ events.prototype._action_waitAsync = function (data, x, y, prefix) {
var test = window.setInterval(function () {
if (!core.hasAsync()) {
clearInterval(test);
core.doAction();
setTimeout(core.doAction);
}
}, 50);
}
@ -1618,12 +1630,12 @@ events.prototype._action_revisit = function (data, x, y, prefix) {
var block = core.getBlock(x, y);
if (block != null && block.block.event.trigger == 'action')
this.setEvents(block.block.event.data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_callBook = function (data, x, y, prefix) {
if (core.isReplaying() || !core.hasItem('book')) {
core.doAction();
setTimeout(core.doAction);
}
else {
var e = core.clone(core.status.event.data);
@ -1636,7 +1648,7 @@ events.prototype._action_callBook = function (data, x, y, prefix) {
events.prototype._action_callSave = function (data, x, y, prefix) {
if (core.isReplaying() || core.hasFlag("__events__")) {
core.removeFlag("__events__");
core.doAction();
setTimeout(core.doAction);
}
else {
var e = core.clone(core.status.event.data);
@ -1649,7 +1661,7 @@ events.prototype._action_callSave = function (data, x, y, prefix) {
events.prototype._action_autoSave = function (data, x, y, prefix) {
core.autosave();
if (!data.nohint) core.drawTip("已自动存档");
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_callLoad = function (data, x, y, prefix) {
@ -1662,97 +1674,97 @@ events.prototype._action_callLoad = function (data, x, y, prefix) {
events.prototype._action_exit = function (data, x, y, prefix) {
this.setEvents([]);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_previewUI = function (data, x, y, prefix) {
this.insertAction(data.action);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_clearMap = function (data, x, y, prefix) {
core.ui._uievent_clearMap(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_fillText = function (data, x, y, prefix) {
core.ui._uievent_fillText(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_fillBoldText = function (data, x, y, prefix) {
core.ui._uievent_fillBoldText(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_fillRect = function (data, x, y, prefix) {
core.ui._uievent_fillRect(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_fillPolygon = function (data, x, y, prefix) {
core.ui._uievent_fillPolygon(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_strokeRect = function (data, x, y, prefix) {
core.ui._uievent_strokeRect(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_strokePolygon = function (data, x, y, prefix) {
core.ui._uievent_strokePolygon(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_fillCircle = function (data, x, y, prefix) {
core.ui._uievent_fillCircle(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_strokeCircle = function (data, x, y, prefix) {
core.ui._uievent_strokeCircle(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_drawLine = function (data, x, y, prefix) {
core.ui._uievent_drawLine(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_drawArrow = function (data, x, y, prefix) {
core.ui._uievent_drawArrow(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_setAttribute = function (data, x, y, prefix) {
core.ui._uievent_setAttribute(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_drawImage = function (data, x, y, prefix) {
core.ui._uievent_drawImage(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_drawIcon = function (data, x, y, prefix) {
core.ui._uievent_drawIcon(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_drawSelector = function (data, x, y, prefix) {
core.ui._uievent_drawSelector(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_drawBackground = function (data, x, y, prefix) {
core.ui._uievent_drawBackground(data);
core.doAction();
setTimeout(core.doAction);
}
events.prototype._action_drawTextContent = function (data, x, y, prefix) {
core.ui._uievent_drawTextContent(data);
core.doAction();
setTimeout(core.doAction);
}
// ------ 点击状态栏图标所进行的一些操作 ------ //

View File

@ -125,10 +125,8 @@ items.prototype._afterUseItem = function (itemId) {
if (core.status.hero.items[itemCls][itemId] <= 0)
delete core.status.hero.items[itemCls][itemId];
if (!core.status.event.id) {
core.status.event.data = null;
if (!core.status.event.id)
core.status.event.ui = null;
}
core.updateStatusBar();
}