Added flamethrower with buring effects
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import Phaser from "phaser";
|
||||
import { type World, type EntityId, type Vec2, type ActorType } from "../core/types";
|
||||
import { TileType } from "../core/terrain";
|
||||
import { TILE_SIZE } from "../core/constants";
|
||||
import { idx, isWall } from "../engine/world/world-logic";
|
||||
import { GAME_CONFIG } from "../core/config/GameConfig";
|
||||
@@ -167,6 +168,18 @@ export class DungeonRenderer {
|
||||
const seen = this.fovManager.seenArray;
|
||||
const visible = this.fovManager.visibleArray;
|
||||
|
||||
// Pre-collect fire positions for efficient tile tinting
|
||||
const firePositions = new Set<string>();
|
||||
if (this.ecsWorld) {
|
||||
const fires = this.ecsWorld.getEntitiesWith("position", "name");
|
||||
for (const fid of fires) {
|
||||
if (this.ecsWorld.getComponent(fid, "name")?.name === "Fire") {
|
||||
const pos = this.ecsWorld.getComponent(fid, "position")!;
|
||||
firePositions.add(`${pos.x},${pos.y}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update Tiles
|
||||
this.layer.forEachTile(tile => {
|
||||
const i = idx(this.world, tile.x, tile.y);
|
||||
@@ -189,6 +202,13 @@ export class DungeonRenderer {
|
||||
if (isVis) {
|
||||
tile.alpha = 1.0;
|
||||
tile.tint = 0xffffff;
|
||||
|
||||
// Special effect for burning grass
|
||||
if (firePositions.has(`${tile.x},${tile.y}`) && worldTile === TileType.GRASS) {
|
||||
const flicker = 0.8 + Math.sin(this.scene.time.now / 120) * 0.2;
|
||||
tile.tint = 0xff3333; // Bright red
|
||||
tile.alpha = flicker;
|
||||
}
|
||||
} else {
|
||||
tile.alpha = isWall(this.world, tile.x, tile.y) ? 0.4 : 0.2;
|
||||
tile.tint = 0x888888;
|
||||
@@ -219,8 +239,33 @@ export class DungeonRenderer {
|
||||
sprite.setAlpha(0.4);
|
||||
sprite.setTint(0x888888);
|
||||
} else {
|
||||
sprite.setAlpha(1);
|
||||
sprite.clearTint();
|
||||
// Flickering effect for Fire
|
||||
const name = this.ecsWorld.getComponent(trapId, "name");
|
||||
if (name?.name === "Fire") {
|
||||
const flicker = 0.8 + Math.sin(this.scene.time.now / 100) * 0.2;
|
||||
sprite.setAlpha(flicker);
|
||||
sprite.setScale(0.9 + Math.sin(this.scene.time.now / 150) * 0.1);
|
||||
|
||||
// Tint based on underlying tile
|
||||
const tileIdx = idx(this.world, pos.x, pos.y);
|
||||
const worldTile = this.world.tiles[tileIdx];
|
||||
|
||||
if (worldTile === TileType.GRASS) {
|
||||
sprite.setTint(0xff3300); // Bright red-orange for burning grass
|
||||
} else if (worldTile === TileType.DOOR_CLOSED || worldTile === TileType.DOOR_OPEN) {
|
||||
// Pulse between yellow and red for doors
|
||||
const pulse = (Math.sin(this.scene.time.now / 150) + 1) / 2;
|
||||
const r = 255;
|
||||
const g = Math.floor(200 * (1 - pulse));
|
||||
const b = 0;
|
||||
sprite.setTint((r << 16) | (g << 8) | b);
|
||||
} else {
|
||||
sprite.setTint(0xffaa44); // Default orange
|
||||
}
|
||||
} else {
|
||||
sprite.setAlpha(1);
|
||||
sprite.clearTint();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -253,6 +298,14 @@ export class DungeonRenderer {
|
||||
});
|
||||
}
|
||||
this.playerSprite.setVisible(true);
|
||||
|
||||
// Burning status effect
|
||||
const statusEffects = this.ecsWorld.getComponent(this.entityAccessor.playerId, "statusEffects");
|
||||
if (statusEffects?.effects.some(e => e.type === "burning")) {
|
||||
this.playerSprite.setTint(0xff6600);
|
||||
} else {
|
||||
this.playerSprite.clearTint();
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -292,6 +345,14 @@ export class DungeonRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
// Burning status effect
|
||||
const statusEffects = this.ecsWorld.getComponent(a.id, "statusEffects");
|
||||
if (statusEffects?.effects.some(e => e.type === "burning")) {
|
||||
sprite.setTint(0xff6600);
|
||||
} else if (sprite) {
|
||||
sprite.clearTint();
|
||||
}
|
||||
|
||||
} else if (a.category === "collectible") {
|
||||
if (a.type === "exp_orb") {
|
||||
if (!isVis) continue;
|
||||
|
||||
Reference in New Issue
Block a user