novi trgovc
This commit is contained in:
BIN
assets/merchant_new.png
Normal file
BIN
assets/merchant_new.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 339 KiB |
@@ -6,6 +6,7 @@ class NPC {
|
|||||||
this.gridX = gridX;
|
this.gridX = gridX;
|
||||||
this.gridY = gridY;
|
this.gridY = gridY;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
console.log(`🎭 NPC Constructor called - Type: ${type} at (${gridX}, ${gridY})`);
|
||||||
|
|
||||||
// Terrain offset
|
// Terrain offset
|
||||||
this.offsetX = offsetX;
|
this.offsetX = offsetX;
|
||||||
@@ -119,8 +120,14 @@ class NPC {
|
|||||||
isAnimated = true;
|
isAnimated = true;
|
||||||
} else if (this.type === 'zombie' && this.scene.textures.exists('zombie_sprite')) {
|
} else if (this.type === 'zombie' && this.scene.textures.exists('zombie_sprite')) {
|
||||||
texKey = 'zombie_sprite';
|
texKey = 'zombie_sprite';
|
||||||
} else if (this.type === 'merchant' && this.scene.textures.exists('merchant_sprite')) {
|
} else if (this.type === 'merchant') {
|
||||||
texKey = 'merchant_sprite';
|
// Uporabi generirano sliko, če obstaja
|
||||||
|
if (this.scene.textures.exists('merchant_new')) {
|
||||||
|
texKey = 'merchant_new';
|
||||||
|
} else {
|
||||||
|
texKey = 'merchant_texture'; // Fallback na proceduralno
|
||||||
|
}
|
||||||
|
console.log('🏪 Creating MERCHANT NPC with texture:', texKey);
|
||||||
} else if (!this.scene.textures.exists(texKey)) {
|
} else if (!this.scene.textures.exists(texKey)) {
|
||||||
TextureGenerator.createNPCSprite(this.scene, texKey, this.type);
|
TextureGenerator.createNPCSprite(this.scene, texKey, this.type);
|
||||||
}
|
}
|
||||||
@@ -137,7 +144,9 @@ class NPC {
|
|||||||
if (isAnimated) {
|
if (isAnimated) {
|
||||||
this.sprite.setScale(1.5);
|
this.sprite.setScale(1.5);
|
||||||
} else {
|
} else {
|
||||||
this.sprite.setScale(0.3);
|
// Merchant manjši, ostali večji
|
||||||
|
const scale = (this.type === 'merchant') ? 0.2 : 0.5;
|
||||||
|
this.sprite.setScale(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// HEALTH BAR
|
// HEALTH BAR
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ class Player {
|
|||||||
if (isAnimated) {
|
if (isAnimated) {
|
||||||
this.sprite.setScale(1.5);
|
this.sprite.setScale(1.5);
|
||||||
} else {
|
} else {
|
||||||
this.sprite.setScale(0.3);
|
this.sprite.setScale(0.5); // Povečano
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- HAND / HELD ITEM SPRITE ---
|
// --- HAND / HELD ITEM SPRITE ---
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ class GameScene extends Phaser.Scene {
|
|||||||
for (let i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i++) {
|
||||||
const randomX = Phaser.Math.Between(40, 60); // Closer to center
|
const randomX = Phaser.Math.Between(40, 60); // Closer to center
|
||||||
const randomY = Phaser.Math.Between(40, 60);
|
const randomY = Phaser.Math.Between(40, 60);
|
||||||
|
console.log(`👤 Spawning NPC type: ${npcTypes[i]} at (${randomX}, ${randomY})`);
|
||||||
const npc = new NPC(this, randomX, randomY, this.terrainOffsetX, this.terrainOffsetY, npcTypes[i]);
|
const npc = new NPC(this, randomX, randomY, this.terrainOffsetX, this.terrainOffsetY, npcTypes[i]);
|
||||||
this.npcs.push(npc);
|
this.npcs.push(npc);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class PreloadScene extends Phaser.Scene {
|
|||||||
this.load.image('rock_small', 'assets/rock_small.png');
|
this.load.image('rock_small', 'assets/rock_small.png');
|
||||||
this.load.image('tree_dead_new', 'assets/tree_dead_new.png');
|
this.load.image('tree_dead_new', 'assets/tree_dead_new.png');
|
||||||
this.load.image('flowers_new', 'assets/flowers_new.png');
|
this.load.image('flowers_new', 'assets/flowers_new.png');
|
||||||
|
this.load.image('merchant_new', 'assets/merchant_new.png');
|
||||||
this.load.image('hill_sprite', 'assets/hill_sprite.png');
|
this.load.image('hill_sprite', 'assets/hill_sprite.png');
|
||||||
this.load.image('fence', 'assets/fence.png');
|
this.load.image('fence', 'assets/fence.png');
|
||||||
this.load.image('gravestone', 'assets/gravestone.png');
|
this.load.image('gravestone', 'assets/gravestone.png');
|
||||||
@@ -121,6 +122,7 @@ class PreloadScene extends Phaser.Scene {
|
|||||||
'rock_1',
|
'rock_1',
|
||||||
'rock_2',
|
'rock_2',
|
||||||
'rock_small',
|
'rock_small',
|
||||||
|
'merchant_new',
|
||||||
'tree_dead_new',
|
'tree_dead_new',
|
||||||
'flowers_new',
|
'flowers_new',
|
||||||
'hill_sprite',
|
'hill_sprite',
|
||||||
|
|||||||
@@ -202,11 +202,14 @@ class SaveSystem {
|
|||||||
this.scene.statsSystem.thirst = saveData.stats.thirst;
|
this.scene.statsSystem.thirst = saveData.stats.thirst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3. Load NPCs
|
||||||
// 3. Load NPCs
|
// 3. Load NPCs
|
||||||
// Pobriši trenutne
|
// Pobriši trenutne
|
||||||
this.scene.npcs.forEach(npc => npc.destroy());
|
this.scene.npcs.forEach(npc => npc.destroy());
|
||||||
this.scene.npcs = [];
|
this.scene.npcs = [];
|
||||||
|
|
||||||
|
let hasMerchant = false;
|
||||||
|
|
||||||
// Ustvari shranjene
|
// Ustvari shranjene
|
||||||
if (saveData.npcs) {
|
if (saveData.npcs) {
|
||||||
saveData.npcs.forEach(npcData => {
|
saveData.npcs.forEach(npcData => {
|
||||||
@@ -219,9 +222,23 @@ class SaveSystem {
|
|||||||
npcData.type
|
npcData.type
|
||||||
);
|
);
|
||||||
this.scene.npcs.push(npc);
|
this.scene.npcs.push(npc);
|
||||||
|
if (npcData.type === 'merchant') hasMerchant = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force Spawn Merchant if missing
|
||||||
|
if (!hasMerchant) {
|
||||||
|
// Spawn near current player position so user can find him
|
||||||
|
const px = saveData.player ? saveData.player.x : 50;
|
||||||
|
const py = saveData.player ? saveData.player.y : 50;
|
||||||
|
const mX = Math.max(0, Math.min(99, Math.floor(px) + 3));
|
||||||
|
const mY = Math.max(0, Math.min(99, Math.floor(py) + 3));
|
||||||
|
|
||||||
|
const merchant = new NPC(this.scene, mX, mY, this.scene.terrainOffsetX, this.scene.terrainOffsetY, 'merchant');
|
||||||
|
this.scene.npcs.push(merchant);
|
||||||
|
console.log("🏪 FORCE SPAWNED MERCHANT at", mX, mY);
|
||||||
|
}
|
||||||
|
|
||||||
// 4. Camera
|
// 4. Camera
|
||||||
if (saveData.camera) {
|
if (saveData.camera) {
|
||||||
this.scene.cameras.main.setZoom(saveData.camera.zoom);
|
this.scene.cameras.main.setZoom(saveData.camera.zoom);
|
||||||
|
|||||||
@@ -64,6 +64,54 @@ class TextureGenerator {
|
|||||||
canvas.refresh();
|
canvas.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static createMerchantSprite(scene, key = 'merchant_texture') {
|
||||||
|
if (scene.textures.exists(key)) return;
|
||||||
|
console.log('🧙♂️ Creating Merchant Sprite Texture...');
|
||||||
|
try {
|
||||||
|
const canvas = scene.textures.createCanvas(key, 32, 32);
|
||||||
|
const ctx = canvas.getContext();
|
||||||
|
ctx.clearRect(0, 0, 32, 32);
|
||||||
|
|
||||||
|
// Body (BRIGHT GOLD robe - zelo viden!)
|
||||||
|
ctx.fillStyle = '#FFD700'; // Gold
|
||||||
|
ctx.fillRect(8, 6, 16, 26);
|
||||||
|
|
||||||
|
// Head
|
||||||
|
ctx.fillStyle = '#FFE4C4'; // Bisque skin
|
||||||
|
ctx.fillRect(10, 4, 12, 12);
|
||||||
|
|
||||||
|
// Hat (Red Merchants Hat)
|
||||||
|
ctx.fillStyle = '#8B0000'; // DarkRed
|
||||||
|
ctx.fillRect(8, 2, 16, 4);
|
||||||
|
ctx.fillRect(10, 0, 12, 2); // Hat Top
|
||||||
|
|
||||||
|
// Backpack (Brown - visible on sides)
|
||||||
|
ctx.fillStyle = '#8B4513';
|
||||||
|
ctx.fillRect(4, 10, 4, 14); // Left side pack
|
||||||
|
ctx.fillRect(24, 10, 4, 14); // Right side pack
|
||||||
|
|
||||||
|
// Straps
|
||||||
|
ctx.fillStyle = '#A0522D';
|
||||||
|
ctx.fillRect(8, 10, 16, 2);
|
||||||
|
|
||||||
|
// Eyes
|
||||||
|
ctx.fillStyle = '#000000';
|
||||||
|
ctx.fillRect(13, 8, 2, 2);
|
||||||
|
ctx.fillRect(17, 8, 2, 2);
|
||||||
|
|
||||||
|
// Beard (White)
|
||||||
|
ctx.fillStyle = '#F5F5F5';
|
||||||
|
ctx.fillRect(10, 12, 12, 4);
|
||||||
|
ctx.fillRect(12, 16, 8, 2);
|
||||||
|
|
||||||
|
canvas.refresh();
|
||||||
|
console.log('✅ Merchant Sprite Created!');
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.error('❌ ERROR creating merchant sprite:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static createCloudSprite(scene, key = 'cloud') {
|
static createCloudSprite(scene, key = 'cloud') {
|
||||||
if (scene.textures.exists(key)) return;
|
if (scene.textures.exists(key)) return;
|
||||||
const canvas = scene.textures.createCanvas(key, 64, 32);
|
const canvas = scene.textures.createCanvas(key, 64, 32);
|
||||||
@@ -336,6 +384,7 @@ class TextureGenerator {
|
|||||||
TextureGenerator.createPlayerSprite(this.scene);
|
TextureGenerator.createPlayerSprite(this.scene);
|
||||||
TextureGenerator.createPlayerWalkSprite(this.scene);
|
TextureGenerator.createPlayerWalkSprite(this.scene);
|
||||||
TextureGenerator.createNPCSprite(this.scene, 'npc', 'zombie');
|
TextureGenerator.createNPCSprite(this.scene, 'npc', 'zombie');
|
||||||
|
TextureGenerator.createMerchantSprite(this.scene, 'merchant_texture');
|
||||||
|
|
||||||
TextureGenerator.createFlowerSprite(this.scene);
|
TextureGenerator.createFlowerSprite(this.scene);
|
||||||
TextureGenerator.createBushSprite(this.scene);
|
TextureGenerator.createBushSprite(this.scene);
|
||||||
|
|||||||
Reference in New Issue
Block a user