diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4 index 5db2748e..399a4c1b 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/blockly/MotaAction.g4 @@ -1651,8 +1651,8 @@ Arithmetic_List ; Weather_List - : '无'|'雨'|'雪' - /*Weather_List ['','rain','snow']*/; + : '无'|'雨'|'雪'|'雾' + /*Weather_List ['','rain','snow','fog']*/; B_0_List : '不改变'|'不可通行'|'可以通行' diff --git a/_server/comment.js b/_server/comment.js index 2b7fcc33..9577712f 100644 --- a/_server/comment.js +++ b/_server/comment.js @@ -376,7 +376,7 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "weather": { "_leaf": true, "_type": "textarea", - "_data": "该层的默认天气。本项可忽略表示晴天,如果写则第一项为\"rain\"或\"snow\"代表雨雪,第二项为1-10之间的数代表强度。\n如[\"rain\", 8]代表8级雨天。" + "_data": "该层的默认天气。本项可忽略表示晴天,如果写则第一项为\"rain\",\"snow\"或\"fog\"代表雨雪雾,第二项为1-10之间的数代表强度。\n如[\"rain\", 8]代表8级雨天。" }, "bgm": { "_leaf": true, diff --git a/docs/element.md b/docs/element.md index e3388285..7ef586d3 100644 --- a/docs/element.md +++ b/docs/element.md @@ -361,7 +361,7 @@ floorId指定的是目标楼层的唯一标识符(ID)。 在每层楼的剧本文件里存在一个weather选项,表示该层楼的默认天气。 ``` js -// 该层的默认天气。本项可忽略表示晴天,如果写则第一项为"rain"或"snow"代表雨雪,第二项为1-10之间的数代表强度。 +// 该层的默认天气。本项可忽略表示晴天,如果写则第一项为"rain","snow"或"fog"代表雨雪雾,第二项为1-10之间的数代表强度。 "weather": ["snow",5] ``` diff --git a/docs/event.md b/docs/event.md index f2cb169f..69e2214a 100644 --- a/docs/event.md +++ b/docs/event.md @@ -1035,6 +1035,8 @@ async可选,如果为true则会异步执行(即不等待当前事件执行 name为天气选项。目前只支持`rain`和`snow`,即雨天和雪天。 +从V2.5.3开始,也支持雾天`fog`。 + level为天气的强度等级,在1-10之间。1级为最弱,10级为最强。 如果想改回晴天则直接不加任何参数。 diff --git a/libs/control.js b/libs/control.js index 0c15502b..a0a655bc 100644 --- a/libs/control.js +++ b/libs/control.js @@ -212,6 +212,37 @@ control.prototype.setRequestAnimationFrame = function () { core.canvas.weather.fill(); + } + else if (core.animateFrame.weather.type == 'fog' && core.animateFrame.weather.level > 0) { + core.clearMap('weather'); + if (core.animateFrame.weather.fog) { + var w = 416, h = 416; + core.setAlpha('weather', 0.5); + core.animateFrame.weather.nodes.forEach(function (p) { + core.canvas.weather.drawImage(core.animateFrame.weather.fog, p.x - ox, p.y - oy, w, h); + + p.x += p.xs; + p.y += p.ys; + if (p.x > core.bigmap.width*32 - w/2) { + p.x = core.bigmap.width*32 - w/2 - 1; + p.xs = -p.xs; + } + if (p.x < -w/2) { + p.x = -w/2+1; + p.xs = -p.xs; + } + if (p.y > core.bigmap.height*32 - h/2) { + p.y = core.bigmap.height*32 - h/2 - 1; + p.ys = -p.ys; + } + if (p.y < -h/2) { + p.y = -h/2+1; + p.ys = -p.ys; + } + }) + core.setAlpha('weather',1); + } + } core.animateFrame.weather.time = timestamp; @@ -1438,7 +1469,7 @@ control.prototype.snipe = function (snipes) { control.prototype.setWeather = function (type, level) { // 非雨雪 - if (type!='rain' && type!='snow') { + if (type!='rain' && type!='snow' && type!='fog') { core.clearMap('weather') core.animateFrame.weather.type = null; core.animateFrame.weather.level = 0; @@ -1485,6 +1516,18 @@ control.prototype.setWeather = function (type, level) { }) } } + else if (type=='fog') { + if (core.animateFrame.weather.fog) { + for (var a=0;a