mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-01 22:29:32 +00:00
@@ -26,6 +26,7 @@ export function conquestFxFactory(
|
||||
x,
|
||||
y,
|
||||
FxType.Conquest,
|
||||
2500,
|
||||
);
|
||||
const fadeAnimation = new FadeFx(swordAnimation, 0.1, 0.6);
|
||||
conquestFx.push(fadeAnimation);
|
||||
|
||||
@@ -16,8 +16,4 @@ export enum FxType {
|
||||
UnderConstruction = "UnderConstruction",
|
||||
Dust = "Dust",
|
||||
Conquest = "Conquest",
|
||||
Tentacle = "Tentacle",
|
||||
Shark = "Shark",
|
||||
Bubble = "Bubble",
|
||||
Tornado = "Tornado",
|
||||
}
|
||||
|
||||
@@ -19,35 +19,6 @@ function fadeInOut(
|
||||
return 1 - f * f;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Move a sprite around
|
||||
*/
|
||||
export class MoveSpriteFx implements Fx {
|
||||
private originX: number;
|
||||
private originY: number;
|
||||
constructor(
|
||||
private fxToMove: SpriteFx,
|
||||
private toX: number,
|
||||
private toY: number,
|
||||
private fadeIn: number = 0.1,
|
||||
private fadeOut: number = 0.9,
|
||||
) {
|
||||
this.originX = fxToMove.x;
|
||||
this.originY = fxToMove.y;
|
||||
}
|
||||
|
||||
renderTick(duration: number, ctx: CanvasRenderingContext2D): boolean {
|
||||
const t = this.fxToMove.getElapsedTime() / this.fxToMove.getDuration();
|
||||
this.fxToMove.x = Math.floor(this.originX * (1 - t) + this.toX * t);
|
||||
this.fxToMove.y = Math.floor(this.originY * (1 - t) + this.toY * t);
|
||||
ctx.save();
|
||||
ctx.globalAlpha = fadeInOut(t, this.fadeIn, this.fadeOut);
|
||||
const result = this.fxToMove.renderTick(duration, ctx);
|
||||
ctx.restore();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fade in/out another FX
|
||||
*/
|
||||
@@ -78,8 +49,8 @@ export class SpriteFx implements Fx {
|
||||
protected waitToTheEnd = false;
|
||||
constructor(
|
||||
animatedSpriteLoader: AnimatedSpriteLoader,
|
||||
public x: number,
|
||||
public y: number,
|
||||
protected x: number,
|
||||
protected y: number,
|
||||
fxType: FxType,
|
||||
duration?: number,
|
||||
owner?: PlayerView,
|
||||
|
||||
Reference in New Issue
Block a user