udomacenje zombija in uboj\

This commit is contained in:
2025-12-07 12:47:47 +01:00
parent 8e401a9d6f
commit 2404d44ef7
10 changed files with 1086 additions and 532 deletions

View File

@@ -11,7 +11,8 @@ class WeatherSystem {
this.currentWeather = 'clear';
this.weatherDuration = 0;
this.maxWeatherDuration = 10000; // Random duration logic handles this
this.rainParticles = []; // {x, y, speed, length}
this.rainEmitter = null; // Replaced manual Array with Emitter
// --- State ---
this.currentPhase = 'day';
@@ -90,20 +91,7 @@ class WeatherSystem {
}
updateWeatherPhysics(delta) {
if (this.currentWeather === 'rain' || this.currentWeather === 'storm') {
const width = this.scene.scale.width;
const height = this.scene.scale.height;
for (const drop of this.rainParticles) {
drop.y += (drop.speed * delta) / 1000;
// Wrap around
if (drop.y > height) {
drop.y = -10;
drop.x = Math.random() * width;
}
}
}
// Optimisation: Physics now handled by Phaser Particles
}
render() {
@@ -168,14 +156,7 @@ class WeatherSystem {
overlay.fillStyle(0x000033, isDark);
overlay.fillRect(0, 0, width, height);
// Draw drops
overlay.lineStyle(1, 0x88aaff, 0.5);
for (const drop of this.rainParticles) {
overlay.beginPath();
overlay.moveTo(drop.x, drop.y);
overlay.lineTo(drop.x - 2, drop.y + drop.length);
overlay.strokePath();
}
// Rain drops are now particles (separate GameObject)
}
}
@@ -204,22 +185,61 @@ class WeatherSystem {
}
startRain(heavy) {
const width = this.scene.scale.width;
const height = this.scene.scale.height;
const dropCount = heavy ? 150 : 100;
const uiScene = this.scene.scene.get('UIScene');
if (!uiScene) return;
for (let i = 0; i < dropCount; i++) {
this.rainParticles.push({
x: Math.random() * width,
y: Math.random() * height,
speed: heavy ? Phaser.Math.Between(400, 600) : Phaser.Math.Between(200, 400),
length: heavy ? Phaser.Math.Between(10, 15) : Phaser.Math.Between(5, 10)
});
// Check Settings
const quality = this.scene.settings ? this.scene.settings.particles : 'HIGH';
if (quality === 'NONE') return;
// Ensure texture exists
if (!this.scene.textures.exists('rain_drop')) {
const graphics = this.scene.make.graphics({ x: 0, y: 0, add: false });
graphics.fillStyle(0x88aaff, 1);
graphics.fillRect(0, 0, 2, 8);
graphics.generateTexture('rain_drop', 2, 8);
graphics.destroy();
}
// Clean up old
if (this.rainEmitter) {
this.rainEmitter.destroy();
}
const width = this.scene.scale.width;
let pQuantity = heavy ? 5 : 2;
let pFreq = heavy ? 10 : 30;
if (quality === 'LOW') {
pQuantity = heavy ? 2 : 1;
pFreq = heavy ? 50 : 100;
}
// Use modern particles or fallback
// Helper to support both if needed, but standard 3.60+ is:
this.rainEmitter = uiScene.add.particles(0, 0, 'rain_drop', {
x: { min: 0, max: width },
y: -20,
quantity: pQuantity,
frequency: pFreq, // Emit every X ms
lifespan: 1500,
speedY: { min: heavy ? 600 : 400, max: heavy ? 900 : 600 },
speedX: { min: -50, max: 0 }, // Slight wind
scaleY: { min: 1.0, max: 2.0 },
alpha: { start: 0.6, end: 0 },
emitting: true
});
// Depth just above overlay (-1000)
this.rainEmitter.setDepth(-990);
}
clearWeather() {
this.rainParticles = [];
if (this.rainEmitter) {
this.rainEmitter.destroy();
this.rainEmitter = null;
}
}
// --- Getters for Other Systems ---