This commit is contained in:
oc 2018-10-19 00:59:44 +08:00
parent dd33b635de
commit 082f57303f
8 changed files with 89 additions and 21 deletions

View File

@ -56,6 +56,7 @@ HTML5 canvas制作的魔塔样板支持全平台游戏
### 2018.10.14 V2.4.3
* [x] 并行事件处理
* [x] 事件:设置楼层属性
* [x] 增加光环属性,还可以制作区域光环效果
* [x] 将部分代码移动到脚本编辑中
* [x] 事件改变天气或画面色调,读档后仍有效

View File

@ -185,6 +185,7 @@ action
| setText_s
| tip_s
| setValue_s
| setFloor_s
| show_s
| hide_s
| trigger_s
@ -367,6 +368,21 @@ var code = '{"type": "setValue", "name": "'+idString_e_0+'", "value": "'+express
return code;
*/;
setFloor_s
: '设置楼层属性' ':' Floor_Meta_List '楼层名' IdString? '值' EvalString Newline
/* setFloor_s
tooltip : setFloor设置楼层属性该楼层属性和编辑器中的楼层属性一一对应
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=setFloor%ef%bc%9a%e8%ae%be%e7%bd%ae%e6%a5%bc%e5%b1%82%e5%b1%9e%e6%80%a7
default : ["title","","'字符串类型的值要加引号,其他类型则不用'"]
colour : this.dataColor
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
var code = '{"type": "setFloor", "name": "'+Floor_Meta_List_0+'"'+IdString_0+', "value": "'+EvalString_0+'"},\n';
return code;
*/;
show_s
: '显示事件' 'x' EvalString? ',' 'y' EvalString? '楼层' IdString? '动画时间' Int? Newline
@ -1461,6 +1477,9 @@ Bg_Fg_List
: '背景层'|'前景层'
/*Bg_Fg_List ['bg','fg']*/;
Floor_Meta_List
: '楼层中文名'|'状态栏名称'|'能否使用楼传'|'能否打开快捷商店'|'是否不可浏览地图'|'默认地面ID'|'楼层贴图'|'宝石血瓶效果'|'上楼点坐标'|'下楼点坐标'|'背景音乐'|'画面色调'|'天气和强度'|'是否地下层'
/*Floor_Meta_List ['title','name','canFlyTo', 'canUseQuickShop', 'cannotViewMap', 'defaultGround', 'images', 'item_ratio', 'upFloor', 'downFloor', 'bgm', 'color', 'weather', 'underGround']*/;
Bool: 'TRUE'
| 'FALSE'
@ -1921,6 +1940,10 @@ ActionParser.prototype.parseAction = function() {
MotaActionBlocks['evalString_e'].xmlText([data.value]),
this.next]);
break;
case "setFloor":
this.next = MotaActionBlocks['setFloor_s'].xmlText([
data.name, data.floorId||null, data.value, this.next]);
break;
case "input":
this.next = MotaActionBlocks['input_s'].xmlText([
data.text,this.next]);

View File

@ -87,6 +87,7 @@ editor_blockly = function () {
MotaActionBlocks['setValue_s'].xmlText([
MotaActionBlocks['idString_1_e'].xmlText(['status','hp'])
]),
MotaActionBlocks['setFloor_s'].xmlText(),
MotaActionBlocks['input_s'].xmlText(),
MotaActionBlocks['input2_s'].xmlText(),
MotaActionBlocks['update_s'].xmlText(),

View File

@ -359,6 +359,31 @@ value是一个表达式将通过这个表达式计算出的结果赋值给nam
另外注意一点的是如果hp被设置成了0或以下将触发lose事件直接死亡。
### setFloor设置楼层属性
使用`{"type":"setFloor"}`可以设置某层楼的楼层属性。
``` js
"x,y": [ // 实际执行的事件列表
{"type": "setFloor", "name": "title", "value": "'主塔 0 层'" } // 设置当前楼层的中文名为主塔0层
{"type": "setFloor", "name": "canFlyTo", "floorId": "MT2", "value": "false" } // 设置MT2层不可飞行
{"type": "setFloor", "name": "cannotViewMap", "floorId": "MT0", "value": "true" } // 设置MT0层不可被浏览地图
{"type": "setFloor", "name": "item_ratio", "value": "5" } // 设置当前楼层的宝石血瓶属性加成为5
{"type": "setFloor", "name": "images", "value": "[[0,0,'tree.png',2]]" } // 设置当前楼层的楼层贴图
{"type": "setFloor", "name": "upFloor", "value": "[2,3]" } // 设置当前楼层的上楼梯
{"type": "setFloor", "name": "bgm", "floorId": "MT10", "value": "'233.mp3'" } // 设置当前楼层的背景音乐
]
```
name为必填项代表要修改的楼层属性。其和楼层属性中一一对应目前只能为`"title", "name", "canFlyTo", "canUseQuickShop", "cannotViewMap", "color", "weather",
"defaultGround", "images", "item_ratio", "upFloor", "bgm", "downFloor", "underGround"`。
floorId为可选项代表要修改的楼层ID可以省略代表当前楼层。
value为必填项代表要修改到的数值。其应该和楼层属性中的对应数值类型完全一致对于字符串需要加单引号其他类型数字、true/false、数组等则不需要引号。
!> 如果修改到的是字符串类型比如楼层中文名、状态栏名称、地面素材ID、背景音乐等必须加引号否则会报错。
### show将一个禁用事件启用
我们上面提到了所有事件都必须靠其他事件驱动来完成不存在当某个flag为true时自动执行的说法。那么我们自然要有启用事件的写法。

View File

@ -793,6 +793,13 @@ events.prototype.doAction = function() {
this.doAction();
}
break;
case "setFloor":
{
core.status.maps[data.floorId||core.status.floorId][data.name] = core.calValue(data.value);
core.updateStatusBar();
this.doAction();
break;
}
case "setHeroIcon":
{
this.setHeroIcon(data.name);
@ -1188,6 +1195,29 @@ events.prototype.trigger = function (x, y) {
}
}
events.prototype.setFloorName = function (floorId) {
floorId = floorId || core.status.floorId;
// 根据文字判断是否斜体
var floorName = core.status.maps[floorId].name || "";
if (typeof floorName == 'number') floorName = ""+floorName;
if (!core.isset(floorName) || floorName=="") floorName=" "
if (core.statusBar.floor.innerHTML == floorName) return;
core.statusBar.floor.innerHTML = floorName;
if (/^[+-]?\d+$/.test(floorName)) {
core.statusBar.floor.style.fontStyle = 'italic';
core.statusBar.floor.style.fontSize = '1.1em';
}
else {
core.statusBar.floor.style.fontStyle = 'normal';
if (floorName.length<=5)
core.statusBar.floor.style.fontSize = '1.1em';
else if (floorName.length==6)
core.statusBar.floor.style.fontSize = '0.9em';
else
core.statusBar.floor.style.fontSize = '0.7em';
}
}
////// 楼层切换 //////
events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback, fromLoad) {
@ -1249,23 +1279,7 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback
var changing = function () {
// 根据文字判断是否斜体
var floorName = core.status.maps[floorId].name;
if (!core.isset(floorName) || floorName=="") floorName="&nbsp;"
core.statusBar.floor.innerHTML = floorName;
if (/^[+-]?\d+$/.test(floorName)) {
core.statusBar.floor.style.fontStyle = 'italic';
core.statusBar.floor.style.fontSize = '1.1em';
}
else {
core.statusBar.floor.style.fontStyle = 'normal';
if (floorName.length<=5)
core.statusBar.floor.style.fontSize = '1.1em';
else if (floorName.length==6)
core.statusBar.floor.style.fontSize = '0.9em';
else
core.statusBar.floor.style.fontSize = '0.7em';
}
core.events.setFloorName(floorId);
// 更改BGM
if (core.isset(core.status.maps[floorId].bgm)) {

View File

@ -16,9 +16,9 @@ maps.prototype.loadFloor = function (floorId, map) {
map = {"map": map};
}
var content = {};
["floorId", "title", "name", "canFlyTo", "canUseQuickShop", "cannotViewMap",
"defaultGround", "images", "item_ratio", "upFloor", "bgm", "downFloor"].forEach(function (e) {
if (core.isset(map) && core.isset(map[e])) content[e] = core.clone(map[e]);
["floorId", "title", "name", "canFlyTo", "canUseQuickShop", "cannotViewMap", "color", "weather",
"defaultGround", "images", "item_ratio", "upFloor", "bgm", "downFloor", "underGround"].forEach(function (e) {
if (core.isset(map[e])) content[e] = core.clone(map[e]);
else content[e] = core.clone(floor[e]);
});
map=map.map;
@ -194,7 +194,7 @@ maps.prototype.save = function(maps, floorId) {
});
delete thisFloor.blocks;
thisFloor.map = blocks;
return thisFloor;
return main.mode == 'editor' ? blocks : thisFloor;
}
////// 更改地图画布的尺寸

View File

@ -603,6 +603,9 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
core.setStatus('hp', Math.min(core.getStatus('hpmax'), core.getStatus('hp')));
}
// 设置楼层名
core.events.setFloorName();
// 设置勇士名字和图标
core.statusBar.name.innerHTML = core.getStatus('name');

View File

@ -1,6 +1,7 @@
HTML5魔塔样板V2.4.3
并行事件处理
事件:设置楼层属性
增加光环属性,还可以制作区域光环效果
将部分代码移动到脚本编辑中
(怪物属性获取、楼层传送、数据统计等)