FIX: All crash null checks - farm init + roads + water animation ready to test
This commit is contained in:
@@ -87,21 +87,33 @@ class GameScene extends Phaser.Scene {
|
|||||||
console.log('🛣️ Building Roads...');
|
console.log('🛣️ Building Roads...');
|
||||||
// Horizontalna cesta od farme
|
// Horizontalna cesta od farme
|
||||||
for (let x = 20; x <= 45; x++) {
|
for (let x = 20; x <= 45; x++) {
|
||||||
this.terrainSystem.tiles[22][x].type = 'pavement';
|
if (this.terrainSystem.tiles[22] && this.terrainSystem.tiles[22][x]) {
|
||||||
this.terrainSystem.tiles[22][x].sprite.setTexture('dirt'); // Uporablj dirt kot "cesto"
|
this.terrainSystem.tiles[22][x].type = 'pavement';
|
||||||
this.terrainSystem.tiles[22][x].sprite.setTint(0x808080); // Siva barva
|
if (this.terrainSystem.tiles[22][x].sprite) {
|
||||||
|
this.terrainSystem.tiles[22][x].sprite.setTexture('dirt');
|
||||||
|
this.terrainSystem.tiles[22][x].sprite.setTint(0x808080);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Vertikalna cesta do mesta
|
// Vertikalna cesta do mesta
|
||||||
for (let y = 22; y <= 65; y++) {
|
for (let y = 22; y <= 65; y++) {
|
||||||
this.terrainSystem.tiles[y][45].type = 'pavement';
|
if (this.terrainSystem.tiles[y] && this.terrainSystem.tiles[y][45]) {
|
||||||
this.terrainSystem.tiles[y][45].sprite.setTexture('dirt');
|
this.terrainSystem.tiles[y][45].type = 'pavement';
|
||||||
this.terrainSystem.tiles[y][45].sprite.setTint(0x808080);
|
if (this.terrainSystem.tiles[y][45].sprite) {
|
||||||
|
this.terrainSystem.tiles[y][45].sprite.setTexture('dirt');
|
||||||
|
this.terrainSystem.tiles[y][45].sprite.setTint(0x808080);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Horizontalna cesta do mesta
|
// Horizontalna cesta do mesta
|
||||||
for (let x = 45; x <= 65; x++) {
|
for (let x = 45; x <= 65; x++) {
|
||||||
this.terrainSystem.tiles[65][x].type = 'pavement';
|
if (this.terrainSystem.tiles[65] && this.terrainSystem.tiles[65][x]) {
|
||||||
this.terrainSystem.tiles[65][x].sprite.setTexture('dirt');
|
this.terrainSystem.tiles[65][x].type = 'pavement';
|
||||||
this.terrainSystem.tiles[65][x].sprite.setTint(0x808080);
|
if (this.terrainSystem.tiles[65][x].sprite) {
|
||||||
|
this.terrainSystem.tiles[65][x].sprite.setTexture('dirt');
|
||||||
|
this.terrainSystem.tiles[65][x].sprite.setTint(0x808080);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SIGNPOSTS - navigacijske table
|
// SIGNPOSTS - navigacijske table
|
||||||
@@ -740,10 +752,12 @@ class GameScene extends Phaser.Scene {
|
|||||||
this.terrainSystem.removeDecoration(x, y);
|
this.terrainSystem.removeDecoration(x, y);
|
||||||
}
|
}
|
||||||
// Make it grass or dirt - USE CORRECT TERRAIN TYPE OBJECT
|
// Make it grass or dirt - USE CORRECT TERRAIN TYPE OBJECT
|
||||||
this.terrainSystem.tiles[y][x].type = this.terrainSystem.terrainTypes.GRASS_FULL;
|
if (this.terrainSystem.tiles[y] && this.terrainSystem.tiles[y][x]) {
|
||||||
if (this.terrainSystem.tiles[y][x].sprite) {
|
this.terrainSystem.tiles[y][x].type = this.terrainSystem.terrainTypes.GRASS_FULL;
|
||||||
this.terrainSystem.tiles[y][x].sprite.setTexture('grass');
|
if (this.terrainSystem.tiles[y][x].sprite) {
|
||||||
this.terrainSystem.tiles[y][x].sprite.setTint(0xffffff); // Clear tint
|
this.terrainSystem.tiles[y][x].sprite.setTexture('grass');
|
||||||
|
this.terrainSystem.tiles[y][x].sprite.setTint(0xffffff); // Clear tint
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user