changing
This commit is contained in:
parent
a14cca27ac
commit
cd2c16f7f5
@ -6,25 +6,25 @@
|
||||
},
|
||||
"gameMap": {
|
||||
"rows": 17,
|
||||
"columns": 30,
|
||||
"columns": 25,
|
||||
"cells": [
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
||||
],
|
||||
"paths": [
|
||||
[
|
||||
@ -89,12 +89,7 @@
|
||||
[5, 21],
|
||||
[5, 22],
|
||||
[5, 23],
|
||||
[5, 24],
|
||||
[5, 25],
|
||||
[5, 26],
|
||||
[5, 27],
|
||||
[5, 28],
|
||||
[5, 29]
|
||||
[5, 24]
|
||||
]
|
||||
]
|
||||
},
|
||||
|
@ -41,7 +41,7 @@ export default class GameAssets {
|
||||
src: '/assets/gui/heart.png',
|
||||
});
|
||||
GameAssets.GoldTexture = await PIXI.Assets.load({
|
||||
src: '/assets/gui/star.png',
|
||||
src: '/assets/gui/money.png',
|
||||
});
|
||||
GameAssets.BasicCreepTexture = await PIXI.Assets.load({
|
||||
src: '/assets/creeps/basic.jpg',
|
||||
|
@ -19,6 +19,7 @@ export default class Creep extends GameObject {
|
||||
private pathIndex: number = 0;
|
||||
private speed: number;
|
||||
public health: number;
|
||||
public maxHealth: number;
|
||||
public escaped: boolean = false;
|
||||
public died: boolean = false;
|
||||
public x: number; // X and Y are local to the grid, not canvas
|
||||
@ -37,6 +38,7 @@ export default class Creep extends GameObject {
|
||||
this.sprite.height = 64;
|
||||
this.speed = this.stats.speed;
|
||||
this.health = this.stats.health;
|
||||
this.maxHealth = this.stats.health;
|
||||
this.path = path;
|
||||
this.x = path[0][1] * 64 + 32; // centered
|
||||
this.y = path[0][0] * 64 + 32;
|
||||
|
@ -38,7 +38,7 @@ export class Cell extends GameObject {
|
||||
this.container.addChild(g);
|
||||
this.container.x = this.bb.x;
|
||||
this.container.y = this.bb.y;
|
||||
if (!GameAssets.DebuggingEnabled) return;
|
||||
// if (!GameAssets.DebuggingEnabled) return;
|
||||
const text = new PIXI.Text({
|
||||
text: `${this.row}|${this.column}`,
|
||||
style: new PIXI.TextStyle({
|
||||
|
@ -6,6 +6,8 @@ import * as PIXI from 'pixi.js';
|
||||
export default class MissionStats extends GameObject {
|
||||
private hp: number = 100;
|
||||
private gold: number = 0;
|
||||
private goldText: PIXI.Text;
|
||||
private healthText: PIXI.Text;
|
||||
|
||||
public getHP() {
|
||||
return this.hp;
|
||||
@ -13,14 +15,17 @@ export default class MissionStats extends GameObject {
|
||||
|
||||
public setHP(hp: number) {
|
||||
this.hp = hp;
|
||||
this.healthText.text = 'HP: ' + this.hp;
|
||||
}
|
||||
|
||||
public takeDamage(damage: number) {
|
||||
this.hp -= damage;
|
||||
this.healthText.text = 'HP: ' + this.hp;
|
||||
}
|
||||
|
||||
public setGold(gold: number) {
|
||||
this.gold = gold;
|
||||
this.goldText.text = 'Gold: ' + this.gold;
|
||||
}
|
||||
|
||||
constructor(initialHP: number, initialGold: number) {
|
||||
@ -30,7 +35,7 @@ export default class MissionStats extends GameObject {
|
||||
this.container.x = 0;
|
||||
this.container.y = 20;
|
||||
Globals.app.stage.addChild(this.container);
|
||||
const healthText = new PIXI.Text({
|
||||
this.healthText = new PIXI.Text({
|
||||
text: `HP: ${this.hp}`,
|
||||
style: new PIXI.TextStyle({
|
||||
fill: 'white',
|
||||
@ -39,8 +44,8 @@ export default class MissionStats extends GameObject {
|
||||
dropShadow: true,
|
||||
}),
|
||||
});
|
||||
healthText.x = 200;
|
||||
const goldText = new PIXI.Text({
|
||||
this.healthText.x = 200;
|
||||
this.goldText = new PIXI.Text({
|
||||
text: `Gold: ${this.gold}`,
|
||||
style: new PIXI.TextStyle({
|
||||
fill: 'white',
|
||||
@ -49,8 +54,8 @@ export default class MissionStats extends GameObject {
|
||||
dropShadow: true,
|
||||
}),
|
||||
});
|
||||
goldText.x = 200;
|
||||
goldText.y = 30;
|
||||
this.goldText.x = 200;
|
||||
this.goldText.y = 30;
|
||||
|
||||
const healthSprite = new PIXI.Sprite(Assets.HealthTexture);
|
||||
healthSprite.x = 165;
|
||||
@ -63,8 +68,8 @@ export default class MissionStats extends GameObject {
|
||||
goldSprite.width = 30;
|
||||
goldSprite.height = 26;
|
||||
goldSprite.y = 30;
|
||||
this.container.addChild(healthText);
|
||||
this.container.addChild(goldText);
|
||||
this.container.addChild(this.healthText);
|
||||
this.container.addChild(this.goldText);
|
||||
this.container.addChild(healthSprite);
|
||||
this.container.addChild(goldSprite);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ export default class Sidebar extends GuiObject {
|
||||
this.sidebarSprite.x = 40;
|
||||
this.sidebarSprite.y = -40;
|
||||
this.sidebarSprite.width = this.bounds.width + 40;
|
||||
this.sidebarSprite.height = this.bounds.height + 80;
|
||||
this.sidebarSprite.height = this.bounds.height + 41;
|
||||
this.container.addChild(this.sidebarSprite);
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,13 @@ enum RoundMode {
|
||||
export class GameScene extends Scene {
|
||||
public mission: MissionDefinition;
|
||||
public missionIndex: number;
|
||||
public MissionStats: MissionStats;
|
||||
public roundMode: RoundMode;
|
||||
public ticker: PIXI.Ticker;
|
||||
public changeRoundButton: Button;
|
||||
public sidebar: Sidebar;
|
||||
public hideSidebarButton: Button;
|
||||
public sidebarHidden: boolean = false;
|
||||
private currentRound: number = 0;
|
||||
|
||||
constructor(name: string) {
|
||||
@ -39,8 +43,7 @@ export class GameScene extends Scene {
|
||||
this.ticker.add(() => this.update(this.ticker.elapsedMS)); // bruh
|
||||
this.ticker.start();
|
||||
const SidebarRect = new PIXI.Rectangle(64 * 30 - 350, 0, 350, Globals.app.canvas.height);
|
||||
const changeRoundButtonRect = new PIXI.Rectangle(64 * 30 - 200, Globals.app.canvas.height - 100, 200, 100);
|
||||
|
||||
const changeRoundButtonRect = new PIXI.Rectangle(50, Globals.app.canvas.height - 100, 300, 100);
|
||||
new Grid(this.mission.gameMap, this.missionIndex);
|
||||
new WaveManager(this.mission.rounds, this.mission.gameMap.paths);
|
||||
Globals.WaveManager.events.on(WaveManagerEvents.CreepSpawned, (creep: Creep) => {
|
||||
@ -49,8 +52,10 @@ export class GameScene extends Scene {
|
||||
this.onCreepEscaped(creep);
|
||||
});
|
||||
});
|
||||
new Sidebar(SidebarRect);
|
||||
this.sidebar = new Sidebar(SidebarRect);
|
||||
this.changeRoundButton = new Button(changeRoundButtonRect, 'Start', ButtonTexture.Button01, true);
|
||||
this.changeRoundButton.container.removeFromParent();
|
||||
this.sidebar.container.addChild(this.changeRoundButton.container);
|
||||
this.changeRoundButton.onClick = () => {
|
||||
console.log('clicked');
|
||||
this.changeRoundButton.setEnabled(false);
|
||||
@ -58,13 +63,15 @@ export class GameScene extends Scene {
|
||||
this.setRoundMode(RoundMode.Combat);
|
||||
};
|
||||
|
||||
new MissionStats(100, 200);
|
||||
this.MissionStats = new MissionStats(100, 200);
|
||||
}
|
||||
public update(elapsedMS) {
|
||||
Globals.WaveManager.update(elapsedMS);
|
||||
Globals.Grid.update(elapsedMS);
|
||||
}
|
||||
public onCreepEscaped(creep: Creep) {}
|
||||
public onCreepEscaped(creep: Creep) {
|
||||
this.MissionStats.takeDamage(creep.health);
|
||||
}
|
||||
|
||||
private setRoundMode(roundMode: RoundMode) {
|
||||
this.roundMode = roundMode;
|
||||
|
Loading…
x
Reference in New Issue
Block a user