Add player controls (X/C keys) + generate 38 new assets (195 total)
- Implemented X key for chopping action (handleChoppingAction) - Implemented C key for mining action (handleMiningAction) - Added silver arrows to inventory (10x) - Generated 38 new PNG assets: * Trees: pine, oak, maple * Crops: carrot, tomato, pumpkin, pepper, cabbage * Buildings: silo, composter * Environment: rock, bush, daisy, log, pond, stump, berries * Tools: iron sword, scythe, fishing rod, shovel, boots, stone, wood * Food/Items: cheese, milk, egg, fertilizer, hay bale * Lighting: torch, lantern * Animals: hedgehog, horse, sheep, pig, bat, owl
This commit is contained in:
@@ -165,7 +165,9 @@ class Player {
|
||||
// Actions
|
||||
space: Phaser.Input.Keyboard.KeyCodes.SPACE,
|
||||
shift: Phaser.Input.Keyboard.KeyCodes.SHIFT,
|
||||
r: Phaser.Input.Keyboard.KeyCodes.R
|
||||
r: Phaser.Input.Keyboard.KeyCodes.R,
|
||||
x: Phaser.Input.Keyboard.KeyCodes.X, // 🪓 Chopping
|
||||
c: Phaser.Input.Keyboard.KeyCodes.C // ⛏️ Mining
|
||||
});
|
||||
|
||||
// Gamepad Events
|
||||
@@ -312,6 +314,16 @@ class Player {
|
||||
if (this.keys.r && Phaser.Input.Keyboard.JustDown(this.keys.r)) {
|
||||
this.useSelectedItem();
|
||||
}
|
||||
|
||||
// 🪓 X KEY - Chopping Action
|
||||
if (this.keys.x && Phaser.Input.Keyboard.JustDown(this.keys.x)) {
|
||||
this.handleChoppingAction();
|
||||
}
|
||||
|
||||
// ⛏️ C KEY - Mining Action
|
||||
if (this.keys.c && Phaser.Input.Keyboard.JustDown(this.keys.c)) {
|
||||
this.handleMiningAction();
|
||||
}
|
||||
}
|
||||
|
||||
updateHeldItem() {
|
||||
@@ -826,4 +838,74 @@ class Player {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleChoppingAction() {
|
||||
console.log('🪓 Chopping action!');
|
||||
|
||||
// Check if player has axe equipped
|
||||
const uiScene = this.scene.scene.get('UIScene');
|
||||
const invSys = this.scene.inventorySystem;
|
||||
|
||||
if (!uiScene || !invSys) return;
|
||||
|
||||
const selectedIdx = uiScene.selectedSlot;
|
||||
const slot = invSys.slots[selectedIdx];
|
||||
|
||||
if (!slot || slot.type !== 'axe') {
|
||||
console.log('⚠️ No axe equipped!');
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate target tile in front of player
|
||||
const targetX = this.gridX + Math.round(this.lastDir.x);
|
||||
const targetY = this.gridY + Math.round(this.lastDir.y);
|
||||
|
||||
// Trigger interaction system with chopping mode
|
||||
if (this.scene.interactionSystem) {
|
||||
this.scene.interactionSystem.handleInteraction(targetX, targetY, true);
|
||||
}
|
||||
|
||||
// Play chopping animation (swing tool)
|
||||
this.swingTool();
|
||||
|
||||
// Play sound
|
||||
if (this.scene.soundManager && this.scene.soundManager.playChop) {
|
||||
this.scene.soundManager.playChop();
|
||||
}
|
||||
}
|
||||
|
||||
handleMiningAction() {
|
||||
console.log('⛏️ Mining action!');
|
||||
|
||||
// Check if player has pickaxe equipped
|
||||
const uiScene = this.scene.scene.get('UIScene');
|
||||
const invSys = this.scene.inventorySystem;
|
||||
|
||||
if (!uiScene || !invSys) return;
|
||||
|
||||
const selectedIdx = uiScene.selectedSlot;
|
||||
const slot = invSys.slots[selectedIdx];
|
||||
|
||||
if (!slot || slot.type !== 'pickaxe') {
|
||||
console.log('⚠️ No pickaxe equipped!');
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate target tile in front of player
|
||||
const targetX = this.gridX + Math.round(this.lastDir.x);
|
||||
const targetY = this.gridY + Math.round(this.lastDir.y);
|
||||
|
||||
// Trigger interaction system with mining mode
|
||||
if (this.scene.interactionSystem) {
|
||||
this.scene.interactionSystem.handleInteraction(targetX, targetY, true);
|
||||
}
|
||||
|
||||
// Play mining animation (swing tool)
|
||||
this.swingTool();
|
||||
|
||||
// Play sound
|
||||
if (this.scene.soundManager && this.scene.soundManager.playMine) {
|
||||
this.scene.soundManager.playMine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user