112 lines
3.4 KiB
JavaScript
112 lines
3.4 KiB
JavaScript
/**
|
|
* StatusEffectSystem.js
|
|
* ====================
|
|
* Manages temporary status effects for the player.
|
|
*/
|
|
|
|
class StatusEffectSystem {
|
|
constructor(scene) {
|
|
this.scene = scene;
|
|
this.activeEffects = new Map();
|
|
|
|
// Initial state
|
|
this.originalSpeed = 0;
|
|
|
|
console.log('🌈 StatusEffectSystem initialized');
|
|
}
|
|
|
|
applyEffect(type, duration = 15000) {
|
|
if (this.activeEffects.has(type)) {
|
|
// Refresh duration
|
|
const effect = this.activeEffects.get(type);
|
|
effect.endTime = Date.now() + duration;
|
|
console.log(`✨ Refreshed effect: ${type}`);
|
|
return true;
|
|
}
|
|
|
|
const effect = {
|
|
type,
|
|
startTime: Date.now(),
|
|
endTime: Date.now() + duration
|
|
};
|
|
|
|
this.activeEffects.set(type, effect);
|
|
this.startEffect(type);
|
|
return true;
|
|
}
|
|
|
|
startEffect(type) {
|
|
console.log(`🚀 Starting effect: ${type}`);
|
|
|
|
if (type === 'high') {
|
|
// Visual: Rainbow Tint
|
|
const uiScene = this.scene.scene.get('UIScene');
|
|
if (uiScene && uiScene.overlayGraphics) {
|
|
this.scene.tweens.addCounter({
|
|
from: 0,
|
|
to: 360,
|
|
duration: 4000,
|
|
repeat: -1,
|
|
onUpdate: (tween) => {
|
|
if (!this.activeEffects.has('high')) return;
|
|
const hull = Phaser.Display.Color.HSVToRGB(tween.getValue() / 360, 0.4, 1);
|
|
const alpha = 0.1 + Math.sin(tween.getValue() * 0.05) * 0.05; // Breathing alpha
|
|
uiScene.overlayGraphics.clear();
|
|
uiScene.overlayGraphics.fillStyle(hull.color, alpha);
|
|
uiScene.overlayGraphics.fillRect(0, 0, this.scene.scale.width, this.scene.scale.height);
|
|
}
|
|
});
|
|
}
|
|
|
|
// Gameplay: Movement slow
|
|
if (this.scene.player) {
|
|
this.originalSpeed = this.scene.player.moveSpeed;
|
|
this.scene.player.moveSpeed *= 0.6;
|
|
}
|
|
|
|
// Camera Shake/Waves?
|
|
this.scene.cameras.main.setLerp(0.05, 0.05); // Looser camera
|
|
|
|
// Audio: High Ambient
|
|
if (this.scene.soundManager) {
|
|
this.scene.soundManager.playHighAmbient();
|
|
}
|
|
}
|
|
}
|
|
|
|
stopEffect(type) {
|
|
console.log(`🛑 Stopping effect: ${type}`);
|
|
this.activeEffects.delete(type);
|
|
|
|
if (type === 'high') {
|
|
// Clear visual
|
|
const uiScene = this.scene.scene.get('UIScene');
|
|
if (uiScene && uiScene.overlayGraphics) {
|
|
uiScene.overlayGraphics.clear();
|
|
}
|
|
|
|
// Reset movement
|
|
if (this.scene.player) {
|
|
this.scene.player.moveSpeed = this.originalSpeed || 100;
|
|
}
|
|
|
|
// Reset camera
|
|
this.scene.cameras.main.setLerp(1, 1);
|
|
|
|
// Audio: Stop High Ambient
|
|
if (this.scene.soundManager) {
|
|
this.scene.soundManager.stopHighAmbient();
|
|
}
|
|
}
|
|
}
|
|
|
|
update(time, delta) {
|
|
const now = Date.now();
|
|
this.activeEffects.forEach((effect, type) => {
|
|
if (now >= effect.endTime) {
|
|
this.stopEffect(type);
|
|
}
|
|
});
|
|
}
|
|
}
|