Add in throwable items (dagger) from pixel dungeon
This commit is contained in:
@@ -6,7 +6,7 @@ export class QuickSlotComponent {
|
||||
private container!: Phaser.GameObjects.Container;
|
||||
private slots: Phaser.GameObjects.Container[] = [];
|
||||
private itemMap: (Item | null)[] = [null, null, null, null]; // 4 slots
|
||||
private assignedIds: string[] = ["health_potion", "", "", ""]; // Default slot 1 to HP pot
|
||||
private assignedIds: string[] = ["health_potion", "throwing_dagger", "", ""]; // Default slot 1 to HP pot, 2 to Dagger
|
||||
|
||||
constructor(scene: Phaser.Scene) {
|
||||
this.scene = scene;
|
||||
@@ -61,7 +61,6 @@ export class QuickSlotComponent {
|
||||
const desiredId = this.assignedIds[i];
|
||||
const slot = this.slots[i];
|
||||
|
||||
// Clear previous item icon if any (children > 2, since 0=bg, 1=text)
|
||||
// Clear previous item icon if any (children > 2, since 0=bg, 1=text)
|
||||
if (slot.list.length > 2) {
|
||||
slot.removeBetween(2, undefined, true);
|
||||
@@ -72,29 +71,11 @@ export class QuickSlotComponent {
|
||||
this.itemMap[i] = foundItem || null;
|
||||
|
||||
if (foundItem) {
|
||||
// Determine color based on item ID for now since we don't have real assets loaded for everything yet
|
||||
let color = 0xffffff;
|
||||
let label = "?";
|
||||
|
||||
if (foundItem.id === "health_potion") {
|
||||
color = 0xff3333;
|
||||
label = "HP";
|
||||
}
|
||||
// Draw simple icon representation
|
||||
const icon = this.scene.add.text(20, 20, label, {
|
||||
fontSize: "14px",
|
||||
color: "#ffffff",
|
||||
fontStyle: "bold"
|
||||
}).setOrigin(0.5);
|
||||
|
||||
// Add bg circle for color
|
||||
const circle = this.scene.add.graphics();
|
||||
circle.fillStyle(color, 1);
|
||||
circle.fillCircle(20, 20, 10);
|
||||
|
||||
// Move text to front
|
||||
slot.add(circle);
|
||||
slot.add(icon);
|
||||
const texture = foundItem.textureKey ?? "items";
|
||||
const sprite = this.scene.add.sprite(20, 20, texture, foundItem.spriteIndex);
|
||||
// PD items are 16x16, slot is 40x40. Scale it up?
|
||||
sprite.setScale(2);
|
||||
slot.add(sprite);
|
||||
|
||||
// Add count if stackable (future)
|
||||
const count = player.inventory.items.filter(it => it.id === desiredId).length;
|
||||
|
||||
Reference in New Issue
Block a user