acesesibiliti
This commit is contained in:
257
src/systems/VisualEnhancementSystem.js
Normal file
257
src/systems/VisualEnhancementSystem.js
Normal file
@@ -0,0 +1,257 @@
|
||||
/**
|
||||
* VISUAL ENHANCEMENT SYSTEM
|
||||
* Central system for managing visual effects, animations, and polish
|
||||
*/
|
||||
class VisualEnhancementSystem {
|
||||
constructor(scene) {
|
||||
this.scene = scene;
|
||||
this.enabled = true;
|
||||
|
||||
// Sub-systems
|
||||
this.animatedTextures = null;
|
||||
this.weatherEffects = null;
|
||||
this.lightingSystem = null;
|
||||
this.shadowSystem = null;
|
||||
this.fogOfWar = null;
|
||||
|
||||
// Settings
|
||||
this.settings = {
|
||||
animatedTextures: true,
|
||||
weatherEffects: true,
|
||||
dynamicLighting: true,
|
||||
shadows: true,
|
||||
fogOfWar: false,
|
||||
particleQuality: 'high', // low, medium, high, ultra
|
||||
animationQuality: 'high'
|
||||
};
|
||||
|
||||
this.loadSettings();
|
||||
this.init();
|
||||
|
||||
console.log('✅ Visual Enhancement System initialized');
|
||||
}
|
||||
|
||||
init() {
|
||||
// Initialize sub-systems
|
||||
this.initAnimatedTextures();
|
||||
this.initWeatherEffects();
|
||||
this.initLightingSystem();
|
||||
this.initShadowSystem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize animated textures
|
||||
*/
|
||||
initAnimatedTextures() {
|
||||
if (!this.settings.animatedTextures) return;
|
||||
|
||||
// Crop growth animations
|
||||
this.createCropAnimations();
|
||||
|
||||
// Water flow
|
||||
this.createWaterAnimation();
|
||||
|
||||
// Tree leaves
|
||||
this.createTreeAnimations();
|
||||
|
||||
// Fire effects
|
||||
this.createFireAnimations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create crop growth animations
|
||||
*/
|
||||
createCropAnimations() {
|
||||
// Smooth transitions between growth stages
|
||||
console.log('🌱 Creating crop animations...');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create water animation
|
||||
*/
|
||||
createWaterAnimation() {
|
||||
// Flowing water effect
|
||||
console.log('💧 Creating water animation...');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create tree animations
|
||||
*/
|
||||
createTreeAnimations() {
|
||||
// Leaf rustling
|
||||
console.log('🌳 Creating tree animations...');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create fire animations
|
||||
*/
|
||||
createFireAnimations() {
|
||||
// Flickering flames
|
||||
console.log('🔥 Creating fire animations...');
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize weather effects
|
||||
*/
|
||||
initWeatherEffects() {
|
||||
if (!this.settings.weatherEffects) return;
|
||||
|
||||
console.log('🌦️ Initializing weather effects...');
|
||||
|
||||
// Snow accumulation
|
||||
// Rain splashes
|
||||
// Wind indicators
|
||||
// Lightning
|
||||
// Fog
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize lighting system
|
||||
*/
|
||||
initLightingSystem() {
|
||||
if (!this.settings.dynamicLighting) return;
|
||||
|
||||
console.log('💡 Initializing lighting system...');
|
||||
|
||||
// Create lighting layer
|
||||
this.lightingLayer = this.scene.add.layer();
|
||||
this.lightingLayer.setDepth(5000);
|
||||
|
||||
// Light sources
|
||||
this.lightSources = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add light source
|
||||
*/
|
||||
addLight(x, y, radius, color, intensity) {
|
||||
const light = {
|
||||
x, y, radius, color, intensity,
|
||||
sprite: null
|
||||
};
|
||||
|
||||
// Create light sprite
|
||||
const graphics = this.scene.add.graphics();
|
||||
graphics.fillStyle(color, intensity);
|
||||
graphics.fillCircle(0, 0, radius);
|
||||
graphics.generateTexture('light_' + this.lightSources.length, radius * 2, radius * 2);
|
||||
graphics.destroy();
|
||||
|
||||
light.sprite = this.scene.add.sprite(x, y, 'light_' + this.lightSources.length);
|
||||
light.sprite.setBlendMode(Phaser.BlendModes.ADD);
|
||||
light.sprite.setAlpha(intensity);
|
||||
|
||||
this.lightSources.push(light);
|
||||
return light;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize shadow system
|
||||
*/
|
||||
initShadowSystem() {
|
||||
if (!this.settings.shadows) return;
|
||||
|
||||
console.log('🌑 Initializing shadow system...');
|
||||
|
||||
this.shadows = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shadow to entity
|
||||
*/
|
||||
addShadow(entity, offsetX = 0, offsetY = 10) {
|
||||
const shadow = this.scene.add.ellipse(
|
||||
entity.x + offsetX,
|
||||
entity.y + offsetY,
|
||||
entity.width * 0.8,
|
||||
entity.height * 0.3,
|
||||
0x000000,
|
||||
0.3
|
||||
);
|
||||
shadow.setDepth(entity.depth - 1);
|
||||
|
||||
this.shadows.push({ entity, shadow, offsetX, offsetY });
|
||||
return shadow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update shadows based on time of day
|
||||
*/
|
||||
updateShadows() {
|
||||
if (!this.settings.shadows) return;
|
||||
|
||||
// Get time of day
|
||||
const timeOfDay = this.scene.weatherSystem ? this.scene.weatherSystem.gameTime : 12;
|
||||
|
||||
// Calculate shadow opacity (darker at noon, lighter at dawn/dusk)
|
||||
const opacity = Math.abs(Math.sin((timeOfDay / 24) * Math.PI)) * 0.5;
|
||||
|
||||
// Update all shadows
|
||||
for (const { entity, shadow, offsetX, offsetY } of this.shadows) {
|
||||
if (entity.sprite) {
|
||||
shadow.x = entity.sprite.x + offsetX;
|
||||
shadow.y = entity.sprite.y + offsetY;
|
||||
shadow.setAlpha(opacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create screen shake effect
|
||||
*/
|
||||
screenShake(intensity = 10, duration = 300) {
|
||||
this.scene.cameras.main.shake(duration, intensity / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create fade transition
|
||||
*/
|
||||
fadeOut(duration = 500, callback) {
|
||||
this.scene.cameras.main.fadeOut(duration, 0, 0, 0);
|
||||
this.scene.cameras.main.once('camerafadeoutcomplete', callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fade in
|
||||
*/
|
||||
fadeIn(duration = 500) {
|
||||
this.scene.cameras.main.fadeIn(duration, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update (called every frame)
|
||||
*/
|
||||
update(delta) {
|
||||
if (this.settings.shadows) {
|
||||
this.updateShadows();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings
|
||||
*/
|
||||
saveSettings() {
|
||||
localStorage.setItem('novafarma_visual_enhancements', JSON.stringify(this.settings));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load settings
|
||||
*/
|
||||
loadSettings() {
|
||||
const saved = localStorage.getItem('novafarma_visual_enhancements');
|
||||
if (saved) {
|
||||
this.settings = { ...this.settings, ...JSON.parse(saved) };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy system
|
||||
*/
|
||||
destroy() {
|
||||
if (this.lightingLayer) this.lightingLayer.destroy();
|
||||
for (const { shadow } of this.shadows) {
|
||||
shadow.destroy();
|
||||
}
|
||||
console.log('✨ Visual Enhancement System destroyed');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user