posodobitev
This commit is contained in:
@@ -105,8 +105,11 @@ class NPC {
|
||||
}
|
||||
}
|
||||
|
||||
// Check for animated sprites first
|
||||
if (this.type === 'zombie' && this.scene.textures.exists('zombie_walk')) {
|
||||
// Check for NEW isometric sprites first (zombie_worker)
|
||||
if (this.type === 'zombie' && this.scene.textures.exists('zombie_worker')) {
|
||||
texKey = 'zombie_worker'; // NEW: Isometric zombie sprite
|
||||
isAnimated = false;
|
||||
} else if (this.type === 'zombie' && this.scene.textures.exists('zombie_walk')) {
|
||||
texKey = 'zombie_walk';
|
||||
isAnimated = true;
|
||||
} else if (this.type === 'zombie' && this.scene.textures.exists('zombie_sprite')) {
|
||||
@@ -141,13 +144,16 @@ class NPC {
|
||||
this.sprite.setOrigin(0.5, 1);
|
||||
|
||||
if (isAnimated) {
|
||||
this.sprite.setScale(1.5);
|
||||
this.sprite.setScale(2.5); // MUCH larger (zombie worker)
|
||||
} else {
|
||||
// Scale po tipu
|
||||
let scale = 0.5; // Default
|
||||
let scale = 0.3; // Default smaller
|
||||
|
||||
// New NPCs - smaller scale
|
||||
if (this.type === 'cow') scale = 0.2;
|
||||
// NEW: Isometric sprites (MUCH larger!)
|
||||
if (texKey === 'zombie_worker') scale = 2.5;
|
||||
else if (texKey === 'player_dreadlocks') scale = 2.5;
|
||||
// New NPCs - SMALL scale
|
||||
else if (this.type === 'cow') scale = 0.2;
|
||||
else if (this.type === 'chicken') scale = 0.2;
|
||||
else if (this.type === 'troll') scale = 0.2;
|
||||
else if (this.type === 'elf') scale = 0.2;
|
||||
@@ -188,9 +194,15 @@ class NPC {
|
||||
|
||||
const targetScreen = this.iso.toScreen(targetX, targetY);
|
||||
|
||||
// Animation
|
||||
if (this.sprite.texture.key === 'zombie_walk') {
|
||||
this.sprite.play('zombie_walk_anim', true);
|
||||
// Animation - SAFE CHECK
|
||||
if (this.sprite.texture.key === 'zombie_worker') {
|
||||
if (this.scene.anims.exists('zombie_worker_walk')) {
|
||||
this.sprite.play('zombie_worker_walk', true);
|
||||
}
|
||||
} else if (this.sprite.texture.key === 'zombie_walk') {
|
||||
if (this.scene.anims.exists('zombie_walk_anim')) {
|
||||
this.sprite.play('zombie_walk_anim', true);
|
||||
}
|
||||
}
|
||||
|
||||
// Tween za smooth gibanje
|
||||
@@ -205,7 +217,10 @@ class NPC {
|
||||
this.updatePosition();
|
||||
|
||||
// Stop Animation
|
||||
if (this.sprite.texture.key === 'zombie_walk') {
|
||||
if (this.sprite.texture.key === 'zombie_worker') {
|
||||
this.sprite.stop();
|
||||
this.sprite.setFrame(0);
|
||||
} else if (this.sprite.texture.key === 'zombie_walk') {
|
||||
this.sprite.stop();
|
||||
this.sprite.setFrame(0);
|
||||
}
|
||||
|
||||
@@ -86,14 +86,17 @@ class Player {
|
||||
}
|
||||
|
||||
createSprite() {
|
||||
// Prefer animated sprite if available
|
||||
let texKey = 'player_walk'; // Spritesheet
|
||||
let isAnimated = this.scene.textures.exists(texKey);
|
||||
// NEW: Use player_dreadlocks sprite (isometric 2.5D)
|
||||
let texKey = 'player_dreadlocks';
|
||||
|
||||
if (!isAnimated) {
|
||||
texKey = this.scene.textures.exists('player_sprite') ? 'player_sprite' : 'player';
|
||||
// Fallback chain if new sprite not loaded
|
||||
if (!this.scene.textures.exists(texKey)) {
|
||||
texKey = this.scene.textures.exists('player_walk') ? 'player_walk' : 'player_sprite';
|
||||
if (!this.scene.textures.exists(texKey)) {
|
||||
TextureGenerator.createPlayerSprite(this.scene, texKey);
|
||||
texKey = 'player';
|
||||
if (!this.scene.textures.exists(texKey)) {
|
||||
TextureGenerator.createPlayerSprite(this.scene, texKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,13 +109,16 @@ class Player {
|
||||
);
|
||||
this.sprite.setOrigin(0.5, 1);
|
||||
|
||||
// Scale logic
|
||||
if (isAnimated) {
|
||||
this.sprite.setScale(1.5);
|
||||
// Scale based on sprite type
|
||||
if (texKey === 'player_dreadlocks') {
|
||||
this.sprite.setScale(2.5); // MUCH larger for better visibility
|
||||
} else if (texKey === 'player_walk') {
|
||||
this.sprite.setScale(2.5); // Old animated sprite
|
||||
} else {
|
||||
this.sprite.setScale(0.5); // Povečano
|
||||
this.sprite.setScale(1.2); // Old static sprite
|
||||
}
|
||||
|
||||
|
||||
// --- HAND / HELD ITEM SPRITE ---
|
||||
this.handSprite = this.scene.add.sprite(
|
||||
screenPos.x + this.offsetX + 10,
|
||||
@@ -224,6 +230,11 @@ class Player {
|
||||
}
|
||||
|
||||
this.updateHeldItem();
|
||||
|
||||
// SPACE KEY - Farming Action
|
||||
if (this.keys.space && Phaser.Input.Keyboard.JustDown(this.keys.space)) {
|
||||
this.handleFarmingAction();
|
||||
}
|
||||
}
|
||||
|
||||
updateHeldItem() {
|
||||
@@ -395,8 +406,15 @@ class Player {
|
||||
|
||||
const targetScreen = this.iso.toScreen(targetX, targetY);
|
||||
|
||||
if (this.sprite.texture.key === 'player_walk') {
|
||||
this.sprite.play('player_walk_anim', true);
|
||||
// Play walk animation - SAFE CHECK
|
||||
if (this.sprite.texture.key === 'player_dreadlocks') {
|
||||
if (this.scene.anims.exists('player_dreadlocks_walk')) {
|
||||
this.sprite.play('player_dreadlocks_walk', true);
|
||||
}
|
||||
} else if (this.sprite.texture.key === 'player_walk') {
|
||||
if (this.scene.anims.exists('player_walk_anim')) {
|
||||
this.sprite.play('player_walk_anim', true);
|
||||
}
|
||||
}
|
||||
|
||||
this.scene.tweens.add({
|
||||
@@ -409,7 +427,11 @@ class Player {
|
||||
this.isMoving = false;
|
||||
this.updatePosition();
|
||||
|
||||
if (this.sprite.texture.key === 'player_walk') {
|
||||
// Stop animation
|
||||
if (this.sprite.texture.key === 'player_dreadlocks') {
|
||||
this.sprite.stop();
|
||||
this.sprite.setFrame(0);
|
||||
} else if (this.sprite.texture.key === 'player_walk') {
|
||||
this.sprite.stop();
|
||||
this.sprite.setFrame(0);
|
||||
}
|
||||
@@ -479,4 +501,55 @@ class Player {
|
||||
this.sprite.clearTint();
|
||||
this.sprite.angle = 0;
|
||||
}
|
||||
|
||||
handleFarmingAction() {
|
||||
if (!this.scene.farmingSystem) return;
|
||||
|
||||
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];
|
||||
const itemType = slot ? slot.type : null;
|
||||
|
||||
// Get tile player is standing on
|
||||
const gridX = this.gridX;
|
||||
const gridY = this.gridY;
|
||||
|
||||
// HOE - Till soil
|
||||
if (itemType === 'hoe') {
|
||||
const success = this.scene.farmingSystem.tillSoil(gridX, gridY);
|
||||
if (success) {
|
||||
console.log('✅ Tilled soil!');
|
||||
// TODO: Play dig sound
|
||||
// TODO: Tool swing animation
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// SEEDS - Plant
|
||||
if (itemType === 'carrot' || itemType === 'wheat' || itemType === 'item_seeds') {
|
||||
const cropType = itemType === 'item_seeds' ? 'carrot' : itemType;
|
||||
const success = this.scene.farmingSystem.plantSeed(gridX, gridY, cropType);
|
||||
if (success) {
|
||||
invSys.removeItem(itemType, 1);
|
||||
console.log('🌱 Planted seed!');
|
||||
// TODO: Play plant sound
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// EMPTY HAND - Harvest
|
||||
if (!itemType) {
|
||||
const success = this.scene.farmingSystem.harvestCrop(gridX, gridY);
|
||||
if (success) {
|
||||
console.log('🌾 Harvested crop!');
|
||||
// TODO: Play harvest sound
|
||||
// TODO: Screen shake
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user