feat: 实装天气系统

This commit is contained in:
unanmed 2024-11-17 21:25:14 +08:00
parent e1d38ef81b
commit 597333adf7
7 changed files with 32 additions and 0 deletions

View File

@ -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);
};
////// 注册一个天气 //////

View File

@ -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);

View File

@ -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 {

7
src/module/index.ts Normal file
View File

@ -0,0 +1,7 @@
import { controller } from './weather';
import { WeatherController } from './weather/weather';
Mota.register('module', 'Weather', {
controller,
WeatherController
});

View File

@ -0,0 +1,3 @@
import { WeatherController } from './weather';
export const controller = new WeatherController();

View File

@ -36,6 +36,16 @@ export class WeatherController {
});
};
/**
*
*/
clearWeather() {
this.active.forEach(v => {
v.deactivate();
});
this.active.clear();
}
/**
*
* @param weather

View File

@ -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++;