mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-22 19:49:09 +00:00
Halloween Event (#2285)
## Description: Changed theme colors for an "autumn" ambiance: <img width="395" height="254" alt="image" src="https://github.com/user-attachments/assets/67bd07d3-e74b-49e2-ba0b-c87958767d45" /> Changed structures pixel art: <img width="756" height="605" alt="image" src="https://github.com/user-attachments/assets/5158ae81-0641-413c-8862-367259496a9a" /> Change existing FX with new halloween-themed ones: https://github.com/user-attachments/assets/fb99be49-43cd-4d85-ad77-8c153070edaf Added new FX playing randomly on the map: https://github.com/user-attachments/assets/16631113-77e6-4b8c-b1b6-c147f5f1d275 Added a couple of new emojis, which are used by the bots when attacked: 👻🎃 ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: IngloriousTom
This commit is contained in:
@@ -13,7 +13,7 @@ import { AnimatedSpriteLoader } from "../AnimatedSpriteLoader";
|
||||
import { conquestFxFactory } from "../fx/ConquestFx";
|
||||
import { Fx, FxType } from "../fx/Fx";
|
||||
import { nukeFxFactory, ShockwaveFx } from "../fx/NukeFx";
|
||||
import { SpriteFx } from "../fx/SpriteFx";
|
||||
import { FadeFx, MoveSpriteFx, SpriteFx } from "../fx/SpriteFx";
|
||||
import { TargetFx } from "../fx/TargetFx";
|
||||
import { TextFx } from "../fx/TextFx";
|
||||
import { UnitExplosionFx } from "../fx/UnitExplosionFx";
|
||||
@@ -21,6 +21,8 @@ import { Layer } from "./Layer";
|
||||
export class FxLayer implements Layer {
|
||||
private canvas: HTMLCanvasElement;
|
||||
private context: CanvasRenderingContext2D;
|
||||
private lastRandomEvent: number = 0;
|
||||
private randomEventRate: number = 8;
|
||||
|
||||
private lastRefresh: number = 0;
|
||||
private refreshRate: number = 10;
|
||||
@@ -40,6 +42,14 @@ export class FxLayer implements Layer {
|
||||
}
|
||||
|
||||
tick() {
|
||||
if (!this.game.config().userSettings()?.fxLayer()) {
|
||||
return;
|
||||
}
|
||||
this.lastRandomEvent += 1;
|
||||
if (this.lastRandomEvent > this.randomEventRate) {
|
||||
this.lastRandomEvent = 0;
|
||||
this.randomEvent();
|
||||
}
|
||||
this.manageBoatTargetFx();
|
||||
this.game
|
||||
.updatesSinceLastTick()
|
||||
@@ -116,6 +126,72 @@ export class FxLayer implements Layer {
|
||||
this.allFx.push(textFx);
|
||||
}
|
||||
|
||||
randomEvent() {
|
||||
const randX = Math.floor(Math.random() * this.game.width());
|
||||
const randY = Math.floor(Math.random() * this.game.height());
|
||||
const ref = this.game.ref(randX, randY);
|
||||
if (this.game.isOcean(ref) && !this.game.isShoreline(ref)) {
|
||||
const animation = Math.floor(Math.random() * 4);
|
||||
if (animation === 0) {
|
||||
const fx = new SpriteFx(
|
||||
this.animatedSpriteLoader,
|
||||
randX,
|
||||
randY,
|
||||
FxType.Shark,
|
||||
);
|
||||
this.allFx.push(fx);
|
||||
} else if (animation === 1) {
|
||||
const fx = new SpriteFx(
|
||||
this.animatedSpriteLoader,
|
||||
randX,
|
||||
randY,
|
||||
FxType.Bubble,
|
||||
);
|
||||
this.allFx.push(fx);
|
||||
} else if (animation === 2) {
|
||||
const fx = new MoveSpriteFx(
|
||||
new SpriteFx(
|
||||
this.animatedSpriteLoader,
|
||||
randX,
|
||||
randY,
|
||||
FxType.Tornado,
|
||||
6000,
|
||||
),
|
||||
randX - 40,
|
||||
randY,
|
||||
0.1,
|
||||
0.8,
|
||||
);
|
||||
this.allFx.push(fx);
|
||||
} else if (animation === 3) {
|
||||
const fx = new FadeFx(
|
||||
new SpriteFx(
|
||||
this.animatedSpriteLoader,
|
||||
randX,
|
||||
randY,
|
||||
FxType.Tentacle,
|
||||
),
|
||||
0.1,
|
||||
0.8,
|
||||
);
|
||||
this.allFx.push(fx);
|
||||
}
|
||||
} else {
|
||||
const ghost = new FadeFx(
|
||||
new SpriteFx(
|
||||
this.animatedSpriteLoader,
|
||||
randX,
|
||||
randY,
|
||||
FxType.MiniSmoke,
|
||||
4000,
|
||||
),
|
||||
0.1,
|
||||
0.8,
|
||||
);
|
||||
this.allFx.push(ghost);
|
||||
}
|
||||
}
|
||||
|
||||
onUnitEvent(unit: UnitView) {
|
||||
switch (unit.type()) {
|
||||
case UnitType.TransportShip: {
|
||||
|
||||
Reference in New Issue
Block a user