feat: Add dark ages faction buildings and path configuration
- Added new building assets (PNG and PSD) for dark ages faction - Created building configuration with frame mappings for different structures - Implemented building placement system using path configuration - Integrated buildings into level scene with proper sprite loading - Added building placement logic for left side of the map - Updated faction system to include building rendering
This commit is contained in:
parent
a2d24d6fbb
commit
1868786cd1
Binary file not shown.
|
After Width: | Height: | Size: 181 KiB |
Binary file not shown.
|
|
@ -0,0 +1,16 @@
|
||||||
|
export const BUILDING_CONFIG = {
|
||||||
|
'dark-ages': {
|
||||||
|
barracks1: {
|
||||||
|
frame: 2
|
||||||
|
},
|
||||||
|
barracks2: {
|
||||||
|
frame: 2
|
||||||
|
},
|
||||||
|
hq: {
|
||||||
|
frame: 3
|
||||||
|
},
|
||||||
|
midBase: {
|
||||||
|
frame: 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,23 @@
|
||||||
export const PATH_CONFIG = {
|
export const PATH_CONFIG = {
|
||||||
'left': {
|
'left': {
|
||||||
|
buildings: {
|
||||||
|
barracks1: {
|
||||||
|
x: 2,
|
||||||
|
y: 4,
|
||||||
|
},
|
||||||
|
hq: {
|
||||||
|
x: 3,
|
||||||
|
y: 8.5,
|
||||||
|
},
|
||||||
|
barracks2: {
|
||||||
|
x: 2,
|
||||||
|
y: 13,
|
||||||
|
},
|
||||||
|
midBase: {
|
||||||
|
x: 16,
|
||||||
|
y: 8.5
|
||||||
|
}
|
||||||
|
},
|
||||||
1: {
|
1: {
|
||||||
0: {
|
0: {
|
||||||
'x': 4,
|
'x': 4,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { PATH_CONFIG } from "../config/night-woods-config.js";
|
||||||
|
import { BUILDING_CONFIG } from "../config/buildings.js";
|
||||||
|
|
||||||
|
export class Buildings {
|
||||||
|
constructor(scene, faction, side) {
|
||||||
|
this.scene = scene;
|
||||||
|
this.faction = faction;
|
||||||
|
this.side = side;
|
||||||
|
this.buildings = {};
|
||||||
|
|
||||||
|
this.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
create() {
|
||||||
|
Object.entries(PATH_CONFIG[this.side].buildings).forEach(([key, value]) => {
|
||||||
|
console.log('x',value.x,'y',value.y,'key',BUILDING_CONFIG[this.faction][key]);
|
||||||
|
this.scene.add.sprite(value.x * 64, value.y * 64, `${this.faction}-buildings`, BUILDING_CONFIG[this.faction][key].frame)
|
||||||
|
.setOrigin(0.5);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -215,6 +215,7 @@ export class Faction extends Phaser.GameObjects.Sprite {
|
||||||
const status = this.enemy.takeDamage('melee', Phaser.Math.Between(this.stats.attackMin, this.stats.attackMax));
|
const status = this.enemy.takeDamage('melee', Phaser.Math.Between(this.stats.attackMin, this.stats.attackMax));
|
||||||
if (status === 'dead') {
|
if (status === 'dead') {
|
||||||
this.enemy = false;
|
this.enemy = false;
|
||||||
|
this.play(this.animKey);
|
||||||
this.resumePath();
|
this.resumePath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { Buildings } from '../faction/buildings.js';
|
||||||
import { Faction } from '../faction/factions.js';
|
import { Faction } from '../faction/factions.js';
|
||||||
|
|
||||||
export class Level extends Phaser.Scene {
|
export class Level extends Phaser.Scene {
|
||||||
|
|
@ -26,6 +27,10 @@ export class Level extends Phaser.Scene {
|
||||||
frameWidth: 64,
|
frameWidth: 64,
|
||||||
frameHeight: 64
|
frameHeight: 64
|
||||||
});
|
});
|
||||||
|
this.load.spritesheet('dark-ages-buildings', '/assets/dark-ages-buildings.png', {
|
||||||
|
frameWidth: 192,
|
||||||
|
frameHeight: 192
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
|
|
@ -41,6 +46,11 @@ export class Level extends Phaser.Scene {
|
||||||
|
|
||||||
this.factionLeft = this.add.group();
|
this.factionLeft = this.add.group();
|
||||||
this.factionRight = this.add.group();
|
this.factionRight = this.add.group();
|
||||||
|
|
||||||
|
this.leftBuildings = new Buildings(this, 'dark-ages', 'left');
|
||||||
|
|
||||||
|
// Set camera bounds to map dimensions
|
||||||
|
this.cameras.main.setBounds(0, 0, this.mainLayer.width, this.mainLayer.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
update(time, delta) {
|
update(time, delta) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue