feat(expansion): implement Phase 3 (Town Restoration) and Phase 4 (Cannabis Textiles)
- Added TownSquareScene and linked it with M key transition - Integrated TownRestorationSystem with material costs and inventory - Added locked shop items in NPCShopSystem until buildings are restored - Updated InteractionSystem to handle ruin restoration triggers - Expanded Cannabis farming to yield Hemp Fiber - Added Hemp Clothing crafting recipe and procedural icons - Refactored StatusEffectSystem and NPCShopSystem to global classes
This commit is contained in:
101
src/systems/StatusEffectSystem.js
Normal file
101
src/systems/StatusEffectSystem.js
Normal file
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
update(time, delta) {
|
||||
const now = Date.now();
|
||||
this.activeEffects.forEach((effect, type) => {
|
||||
if (now >= effect.endTime) {
|
||||
this.stopEffect(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user