mapa
This commit is contained in:
105
src/systems/ParticleEffects.js
Normal file
105
src/systems/ParticleEffects.js
Normal file
@@ -0,0 +1,105 @@
|
||||
// ParticleEffects System
|
||||
// Proceduralno generiranje particle efektov
|
||||
class ParticleEffects {
|
||||
constructor(scene) {
|
||||
this.scene = scene;
|
||||
this.createParticleTextures();
|
||||
}
|
||||
|
||||
createParticleTextures() {
|
||||
// Blood particle
|
||||
if (!this.scene.textures.exists('blood_particle')) {
|
||||
const graphics = this.scene.make.graphics({ x: 0, y: 0, add: false });
|
||||
graphics.fillStyle(0xff0000, 1);
|
||||
graphics.fillCircle(2, 2, 2);
|
||||
graphics.generateTexture('blood_particle', 4, 4);
|
||||
graphics.destroy();
|
||||
}
|
||||
|
||||
// Leaf particle
|
||||
if (!this.scene.textures.exists('leaf_particle')) {
|
||||
const graphics = this.scene.make.graphics({ x: 0, y: 0, add: false });
|
||||
graphics.fillStyle(0x44aa44, 1);
|
||||
graphics.fillRect(0, 0, 4, 6);
|
||||
graphics.generateTexture('leaf_particle', 4, 6);
|
||||
graphics.destroy();
|
||||
}
|
||||
|
||||
// Sparkle particle
|
||||
if (!this.scene.textures.exists('sparkle_particle')) {
|
||||
const graphics = this.scene.make.graphics({ x: 0, y: 0, add: false });
|
||||
graphics.fillStyle(0xffff00, 1);
|
||||
graphics.fillCircle(2, 2, 2);
|
||||
graphics.generateTexture('sparkle_particle', 4, 4);
|
||||
graphics.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
// Blood Splash on damage
|
||||
bloodSplash(x, y) {
|
||||
const emitter = this.scene.add.particles(x, y, 'blood_particle', {
|
||||
speed: { min: 50, max: 150 },
|
||||
angle: { min: 0, max: 360 },
|
||||
scale: { start: 1, end: 0 },
|
||||
lifespan: 500,
|
||||
quantity: 8,
|
||||
emitting: false
|
||||
});
|
||||
|
||||
emitter.setDepth(10000);
|
||||
emitter.explode();
|
||||
|
||||
this.scene.time.delayedCall(600, () => emitter.destroy());
|
||||
}
|
||||
|
||||
// Falling Leaves ambient effect
|
||||
createFallingLeaves() {
|
||||
if (!this.scene.settings || this.scene.settings.particles === 'NONE') return;
|
||||
|
||||
const width = this.scene.scale.width;
|
||||
const quantity = this.scene.settings.particles === 'LOW' ? 1 : 2;
|
||||
|
||||
const leavesEmitter = this.scene.add.particles(0, -20, 'leaf_particle', {
|
||||
x: { min: 0, max: width },
|
||||
y: -20,
|
||||
speedY: { min: 30, max: 80 },
|
||||
speedX: { min: -20, max: 20 },
|
||||
quantity: quantity,
|
||||
frequency: 2000, // Every 2 seconds
|
||||
lifespan: 8000,
|
||||
scale: { min: 0.5, max: 1.0 },
|
||||
rotation: { min: 0, max: 360 },
|
||||
angle: { min: -10, max: 10 },
|
||||
alpha: { start: 0.8, end: 0 }
|
||||
});
|
||||
|
||||
leavesEmitter.setDepth(-980); // Below UI, above world
|
||||
this.leavesEmitter = leavesEmitter;
|
||||
|
||||
return leavesEmitter;
|
||||
}
|
||||
|
||||
// Sparkles on item pickup
|
||||
sparkle(x, y) {
|
||||
const emitter = this.scene.add.particles(x, y, 'sparkle_particle', {
|
||||
speed: { min: 20, max: 80 },
|
||||
angle: { min: 0, max: 360 },
|
||||
scale: { start: 1.5, end: 0 },
|
||||
lifespan: 800,
|
||||
quantity: 5,
|
||||
emitting: false
|
||||
});
|
||||
|
||||
emitter.setDepth(10000);
|
||||
emitter.explode();
|
||||
|
||||
this.scene.time.delayedCall(900, () => emitter.destroy());
|
||||
}
|
||||
|
||||
// Destroy all effects
|
||||
destroy() {
|
||||
if (this.leavesEmitter) {
|
||||
this.leavesEmitter.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user