diff --git a/public/libs/control.js b/public/libs/control.js index 17d63cd..09790dd 100644 --- a/public/libs/control.js +++ b/public/libs/control.js @@ -2894,6 +2894,9 @@ control.prototype.getMappedName = function (name) { ////// 更改天气效果 ////// control.prototype.setWeather = function (type, level) { // Deprecated. Use WeatherController API instead. + const controller = Mota.require('module', 'Weather').controller; + controller.clearWeather(); + if (type !== null && type !== void 0) controller.activate(type, level); }; ////// 注册一个天气 ////// diff --git a/src/core/index.ts b/src/core/index.ts index 5d7f596..96314fb 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -76,6 +76,7 @@ import { Camera } from './render/camera'; import * as Animation from 'mutate-animate'; import './render/index'; import * as RenderUtils from './render/utils'; +import '@/module'; // ----- 类注册 Mota.register('class', 'AudioPlayer', AudioPlayer); diff --git a/src/game/system.ts b/src/game/system.ts index e50cbaa..aceb992 100644 --- a/src/game/system.ts +++ b/src/game/system.ts @@ -41,6 +41,7 @@ import type { BlockMover, HeroMover, ObjectMoverBase } from './state/move'; import type { Camera } from '@/core/render/camera'; import type * as Animation from 'mutate-animate'; import type * as RenderUtils from '@/core/render/utils'; +import type { WeatherController } from '@/module/weather/weather'; interface ClassInterface { // 渲染进程与游戏进程通用 @@ -140,6 +141,10 @@ interface ModuleInterface { HeroKeyMover: typeof HeroKeyMover; }; Animation: typeof Animation; + Weather: { + controller: WeatherController; + WeatherController: typeof WeatherController; + }; } interface SystemInterfaceMap { diff --git a/src/module/index.ts b/src/module/index.ts new file mode 100644 index 0000000..caf9910 --- /dev/null +++ b/src/module/index.ts @@ -0,0 +1,7 @@ +import { controller } from './weather'; +import { WeatherController } from './weather/weather'; + +Mota.register('module', 'Weather', { + controller, + WeatherController +}); diff --git a/src/module/weather/index.ts b/src/module/weather/index.ts new file mode 100644 index 0000000..91de7e9 --- /dev/null +++ b/src/module/weather/index.ts @@ -0,0 +1,3 @@ +import { WeatherController } from './weather'; + +export const controller = new WeatherController(); diff --git a/src/module/weather/weather.ts b/src/module/weather/weather.ts index 1d9de42..7e08f0f 100644 --- a/src/module/weather/weather.ts +++ b/src/module/weather/weather.ts @@ -36,6 +36,16 @@ export class WeatherController { }); }; + /** + * 清空所有天气 + */ + clearWeather() { + this.active.forEach(v => { + v.deactivate(); + }); + this.active.clear(); + } + /** * 获取一个天气 * @param weather 要获取的天气 diff --git a/src/plugin/boss/towerBoss.ts b/src/plugin/boss/towerBoss.ts index 47359be..3f91020 100644 --- a/src/plugin/boss/towerBoss.ts +++ b/src/plugin/boss/towerBoss.ts @@ -21,6 +21,7 @@ import { } from './towerBossProjectile'; import { IStateDamageable } from '@/game/state/interface'; import { HeroRenderer } from '@/core/render/preset/hero'; +import { controller } from '@/module/weather'; Mota.require('var', 'loading').once('coreInit', () => { const shader = new Shader(); @@ -427,6 +428,8 @@ export class TowerBoss extends BarrageBoss { const skill5Release = this.skill5Time * this.skill5Interval; const attack = this.attackTime * this.attackInterval; + controller.activate('rain', 6); + if (time > skill4Release) { this.releaseSkill4(); this.skill4Time++;