stanje 4am
This commit is contained in:
@@ -13,15 +13,18 @@ class WeatherSystem {
|
||||
}
|
||||
|
||||
init() {
|
||||
// Create weather overlay
|
||||
this.overlay = this.scene.add.graphics();
|
||||
this.overlay.setDepth(5000); // Above everything but UI
|
||||
this.overlay.setScrollFactor(0); // Fixed to camera
|
||||
|
||||
// Start with random weather
|
||||
// No local overlay - we use UI Scene
|
||||
this.changeWeather();
|
||||
}
|
||||
|
||||
getOverlay() {
|
||||
const uiScene = this.scene.scene.get('UIScene');
|
||||
if (uiScene && uiScene.weatherGraphics) {
|
||||
return uiScene.weatherGraphics;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
changeWeather() {
|
||||
// Clean up old weather
|
||||
this.clearWeather();
|
||||
@@ -61,10 +64,10 @@ class WeatherSystem {
|
||||
}
|
||||
|
||||
startRain(heavy = false) {
|
||||
const width = this.scene.cameras.main.width;
|
||||
const height = this.scene.cameras.main.height;
|
||||
const width = this.scene.scale.width;
|
||||
const height = this.scene.scale.height;
|
||||
|
||||
// Create rain drops
|
||||
// Create rain drops (keep logic for drops)
|
||||
const dropCount = heavy ? 150 : 100;
|
||||
|
||||
for (let i = 0; i < dropCount; i++) {
|
||||
@@ -77,27 +80,16 @@ class WeatherSystem {
|
||||
this.rainParticles.push(drop);
|
||||
}
|
||||
|
||||
// Darken screen slightly
|
||||
this.overlay.clear();
|
||||
this.overlay.fillStyle(0x000033, heavy ? 0.3 : 0.2);
|
||||
this.overlay.fillRect(0, 0, width, height);
|
||||
// No drawing here - handled in renderWeather
|
||||
}
|
||||
|
||||
applyFog() {
|
||||
const width = this.scene.cameras.main.width;
|
||||
const height = this.scene.cameras.main.height;
|
||||
|
||||
this.overlay.clear();
|
||||
this.overlay.fillStyle(0xcccccc, 0.4);
|
||||
this.overlay.fillRect(0, 0, width, height);
|
||||
// No drawing here - handled in renderWeather
|
||||
}
|
||||
|
||||
clearWeather() {
|
||||
// Remove all weather effects
|
||||
this.rainParticles = [];
|
||||
if (this.overlay) {
|
||||
this.overlay.clear();
|
||||
}
|
||||
// No clearing here - handled by DayNightSystem clearing the frame
|
||||
}
|
||||
|
||||
update(delta) {
|
||||
@@ -108,42 +100,50 @@ class WeatherSystem {
|
||||
this.changeWeather();
|
||||
}
|
||||
|
||||
// Update rain
|
||||
if (this.currentWeather === 'rain' || this.currentWeather === 'storm') {
|
||||
this.updateRain(delta);
|
||||
// Always render active weather
|
||||
if (this.currentWeather !== 'clear') {
|
||||
this.renderWeather(delta);
|
||||
}
|
||||
}
|
||||
|
||||
updateRain(delta) {
|
||||
const height = this.scene.cameras.main.height;
|
||||
const width = this.scene.cameras.main.width;
|
||||
renderWeather(delta) {
|
||||
const overlay = this.getOverlay();
|
||||
if (!overlay) return;
|
||||
|
||||
// Update drop positions
|
||||
for (const drop of this.rainParticles) {
|
||||
drop.y += (drop.speed * delta) / 1000;
|
||||
const height = this.scene.scale.height;
|
||||
const width = this.scene.scale.width;
|
||||
|
||||
// Reset if off screen
|
||||
if (drop.y > height) {
|
||||
drop.y = -10;
|
||||
drop.x = Math.random() * width;
|
||||
}
|
||||
// FOG
|
||||
if (this.currentWeather === 'fog') {
|
||||
overlay.fillStyle(0xcccccc, 0.4);
|
||||
overlay.fillRect(0, 0, width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
// Render rain
|
||||
this.overlay.clear();
|
||||
// RAIN / STORM
|
||||
if (this.currentWeather === 'rain' || this.currentWeather === 'storm') {
|
||||
// Update physics
|
||||
for (const drop of this.rainParticles) {
|
||||
drop.y += (drop.speed * delta) / 1000;
|
||||
if (drop.y > height) {
|
||||
drop.y = -10;
|
||||
drop.x = Math.random() * width;
|
||||
}
|
||||
}
|
||||
|
||||
// Background darkening
|
||||
const isDark = this.currentWeather === 'storm' ? 0.3 : 0.2;
|
||||
this.overlay.fillStyle(0x000033, isDark);
|
||||
this.overlay.fillRect(0, 0, width, height);
|
||||
// Darken background for storm/rain (additive to DayNight)
|
||||
const isDark = this.currentWeather === 'storm' ? 0.3 : 0.2;
|
||||
overlay.fillStyle(0x000033, isDark);
|
||||
overlay.fillRect(0, 0, width, height);
|
||||
|
||||
// Draw drops
|
||||
this.overlay.lineStyle(1, 0x88aaff, 0.5);
|
||||
for (const drop of this.rainParticles) {
|
||||
this.overlay.beginPath();
|
||||
this.overlay.moveTo(drop.x, drop.y);
|
||||
this.overlay.lineTo(drop.x - 2, drop.y + drop.length);
|
||||
this.overlay.strokePath();
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user