posodobitev
This commit is contained in:
@@ -10,7 +10,8 @@ class BuildingSystem {
|
||||
house: { name: 'House', cost: { wood: 20, stone: 20, gold: 50 }, w: 1, h: 1 }, // Visual is bigger but anchor is 1 tile
|
||||
barn: { name: 'Barn', cost: { wood: 50, stone: 10 }, w: 1, h: 1 },
|
||||
silo: { name: 'Silo', cost: { wood: 30, stone: 30 }, w: 1, h: 1 },
|
||||
stable: { name: 'Stable', cost: { wood: 40, stone: 20 }, w: 1, h: 1 }
|
||||
stable: { name: 'Stable', cost: { wood: 40, stone: 20 }, w: 1, h: 1 },
|
||||
greenhouse: { name: 'Greenhouse', cost: { glass: 20, wood: 15 }, w: 2, h: 2 } // Winter farming
|
||||
};
|
||||
|
||||
// Textures init
|
||||
|
||||
128
src/systems/VisualEffectsSystem.js
Normal file
128
src/systems/VisualEffectsSystem.js
Normal file
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* VISUAL EFFECTS SYSTEM
|
||||
* Handles juice effects: screenshake, particles, lighting
|
||||
*/
|
||||
class VisualEffectsSystem {
|
||||
constructor(scene) {
|
||||
this.scene = scene;
|
||||
this.camera = scene.cameras.main;
|
||||
this.isShaking = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Screenshake effect
|
||||
* @param {number} intensity - Shake strength (default 0.005)
|
||||
* @param {number} duration - Duration in ms (default 300)
|
||||
*/
|
||||
screenshake(intensity = 0.005, duration = 300) {
|
||||
if (this.isShaking) return;
|
||||
|
||||
this.isShaking = true;
|
||||
this.camera.shake(duration, intensity);
|
||||
|
||||
this.scene.time.delayedCall(duration, () => {
|
||||
this.isShaking = false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Hit particles (sparks)
|
||||
*/
|
||||
createHitParticles(x, y, color = 0xFFFFFF) {
|
||||
const particles = this.scene.add.particles(x, y, 'particle_white', {
|
||||
speed: { min: 100, max: 200 },
|
||||
angle: { min: 0, max: 360 },
|
||||
scale: { start: 0.5, end: 0 },
|
||||
lifespan: 300,
|
||||
quantity: 8,
|
||||
tint: color
|
||||
});
|
||||
|
||||
this.scene.time.delayedCall(500, () => {
|
||||
particles.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Explosion particles
|
||||
*/
|
||||
createExplosion(x, y, color = 0xFF4444) {
|
||||
const particles = this.scene.add.particles(x, y, 'particle_white', {
|
||||
speed: { min: 200, max: 400 },
|
||||
angle: { min: 0, max: 360 },
|
||||
scale: { start: 1, end: 0 },
|
||||
lifespan: 600,
|
||||
quantity: 20,
|
||||
tint: color,
|
||||
gravityY: 300
|
||||
});
|
||||
|
||||
this.scene.time.delayedCall(800, () => {
|
||||
particles.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Dust particles (for movement)
|
||||
*/
|
||||
createDustPuff(x, y) {
|
||||
const particles = this.scene.add.particles(x, y, 'particle_white', {
|
||||
speed: { min: 30, max: 60 },
|
||||
angle: { min: 0, max: 360 },
|
||||
scale: { start: 0.3, end: 0 },
|
||||
lifespan: 400,
|
||||
quantity: 5,
|
||||
tint: 0xCCBBAA,
|
||||
alpha: { start: 0.5, end: 0 }
|
||||
});
|
||||
|
||||
this.scene.time.delayedCall(500, () => {
|
||||
particles.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Flash effect (for damage, powerups)
|
||||
*/
|
||||
flash(color = 0xFFFFFF, duration = 100) {
|
||||
this.camera.flash(duration, ...this.hexToRGB(color));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fade effect
|
||||
*/
|
||||
fadeOut(duration = 1000, callback) {
|
||||
this.camera.fadeOut(duration, 0, 0, 0);
|
||||
if (callback) {
|
||||
this.scene.time.delayedCall(duration, callback);
|
||||
}
|
||||
}
|
||||
|
||||
fadeIn(duration = 1000) {
|
||||
this.camera.fadeIn(duration, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility: Hex to RGB
|
||||
*/
|
||||
hexToRGB(hex) {
|
||||
return [
|
||||
(hex >> 16) & 255,
|
||||
(hex >> 8) & 255,
|
||||
hex & 255
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create simple white pixel texture for particles
|
||||
*/
|
||||
static createParticleTexture(scene) {
|
||||
if (scene.textures.exists('particle_white')) return;
|
||||
|
||||
const graphics = scene.make.graphics({ x: 0, y: 0, add: false });
|
||||
graphics.fillStyle(0xFFFFFF, 1);
|
||||
graphics.fillCircle(4, 4, 4);
|
||||
graphics.generateTexture('particle_white', 8, 8);
|
||||
graphics.destroy();
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,11 @@ class WeatherSystem {
|
||||
|
||||
// Check for Season Change
|
||||
this.checkSeasonChange();
|
||||
|
||||
// DEMO MODE: 3-day limit
|
||||
if (this.dayCount > 3) {
|
||||
this.triggerDemoEnd();
|
||||
}
|
||||
}
|
||||
|
||||
// Update Phase
|
||||
@@ -348,4 +353,77 @@ class WeatherSystem {
|
||||
overlay.fillRect(0, 0, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
updateTemperature(delta) {
|
||||
// Calculate base temperature from season
|
||||
const seasonTemps = {
|
||||
spring: 15,
|
||||
summer: 30,
|
||||
autumn: 10,
|
||||
winter: -5
|
||||
};
|
||||
|
||||
this.baseTemp = seasonTemps[this.currentSeason] || 20;
|
||||
|
||||
// Time of day variation
|
||||
const timeVar = Math.sin((this.gameTime / 24) * Math.PI * 2) * 5;
|
||||
this.currentTemp = this.baseTemp + timeVar;
|
||||
|
||||
// Temperature damage logic
|
||||
this.tempCheckTimer += delta;
|
||||
if (this.tempCheckTimer >= this.tempDamageInterval) {
|
||||
this.tempCheckTimer = 0;
|
||||
this.checkTemperatureDamage();
|
||||
}
|
||||
}
|
||||
|
||||
checkTemperatureDamage() {
|
||||
if (!this.scene.player) return;
|
||||
|
||||
const player = this.scene.player;
|
||||
const inventory = this.scene.inventorySystem;
|
||||
|
||||
// Check for winter coat protection
|
||||
const hasWinterCoat = inventory && inventory.hasItem('winter_coat');
|
||||
const hasSummerHat = inventory && inventory.hasItem('summer_hat');
|
||||
|
||||
// Cold damage (Winter)
|
||||
if (this.currentTemp < 0 && !hasWinterCoat) {
|
||||
player.takeDamage(5);
|
||||
this.scene.events.emit('show-floating-text', {
|
||||
x: player.sprite.x,
|
||||
y: player.sprite.y - 40,
|
||||
text: '❄️ Freezing!',
|
||||
color: '#88D4FF'
|
||||
});
|
||||
}
|
||||
|
||||
// Heat damage (Summer)
|
||||
if (this.currentTemp > 35 && !hasSummerHat) {
|
||||
player.takeDamage(3);
|
||||
this.scene.events.emit('show-floating-text', {
|
||||
x: player.sprite.x,
|
||||
y: player.sprite.y - 40,
|
||||
text: '🔥 Overheating!',
|
||||
color: '#FF8844'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getTemperature() {
|
||||
return Math.round(this.currentTemp);
|
||||
}
|
||||
|
||||
triggerDemoEnd() {
|
||||
console.log('🎮 DEMO END - 3 Days Completed!');
|
||||
|
||||
// Pause game
|
||||
this.scene.physics.pause();
|
||||
|
||||
// Show demo end screen
|
||||
const uiScene = this.scene.scene.get('UIScene');
|
||||
if (uiScene) {
|
||||
uiScene.showDemoEndScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user