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(Fp^hFhGhG
z)z{BGL9FEF(ic4cpW5nk9{y|~xN_Yn_n%)R<4Se)B?E4$BtP|zD|dbPQ@7mf{^*fo
z+G@x8z7W>U*(2v?UaVNZM8m}D>a5z7uwcbXb&P9PAQXZ9j+9FJ{pQ%SPg^k0$z|>H
zGQQ~Rx!){xLR;&()I{wCy=OztE9AXT{o(KL{Lp>JrrZY(p4THIdE49Pi&`VJ2Ts0t
z;h%&2OAoQKG-7pOvYNraYU;f+q)lG
z{^e!)RRF-s9^42aELdx;@DXw+j(!I72O;Ki4dJG>8^vHxKaL~uJrCdWjOTecQX+*w
zU=T(TMIm7r5=Rk992ygbmTrWI0#urk3ha;+*_opE%+Y4_=le4_;aJsRwRNNr{cDQ$
zjvr6|N^<-rT4$d#)#tY0nx7MP{;K2c`}=6>lE7Mh~k(i3W?*GG>%p(RDuW*
zg(#KcNbcHg?K6d<AYT*
literal 0
HcmV?d00001
diff --git a/src/classes/Assets.ts b/src/classes/Assets.ts
index c25519b..33ada65 100644
--- a/src/classes/Assets.ts
+++ b/src/classes/Assets.ts
@@ -158,6 +158,7 @@ export default class GameAssets {
await this.LoadMission('./assets/missions/04_crossroads.json');
await this.LoadMission('./assets/missions/05_the_maze.json');
await this.LoadMission('./assets/missions/06_multiple_fronts.json');
+ await this.LoadMission('./assets/missions/07_final_stretch.json');
}
private static async LoadTowers() {
diff --git a/src/classes/Bastion.ts b/src/classes/Bastion.ts
index b8fc872..179cf49 100644
--- a/src/classes/Bastion.ts
+++ b/src/classes/Bastion.ts
@@ -22,6 +22,7 @@ export class Engine {
public static NotificationManager: NotificationManager;
public static GameScene: GameScene;
public static latestCommit: string;
+ public static latestGemId = 0;
public static GridCellSize: number = 64;
public static GridColumns: number = 25;
diff --git a/src/classes/game/Gem.ts b/src/classes/game/Gem.ts
index b699dbc..8f0bc07 100644
--- a/src/classes/game/Gem.ts
+++ b/src/classes/game/Gem.ts
@@ -1,8 +1,7 @@
import * as PIXI from 'pixi.js';
import { GemType, GemDefinition, GenericGemImprovement } from '../Definitions';
import GameAssets from '../Assets';
-
-let latestGemId = 0;
+import { Engine } from '../Bastion';
export default class Gem {
public texture: PIXI.Texture;
@@ -14,8 +13,8 @@ export default class Gem {
this.texture = this.definition.textures[0];
if (!doNotIncrement) {
- this.id = latestGemId + 1;
- latestGemId++;
+ this.id = Engine.latestGemId + 1;
+ Engine.latestGemId++;
} else this.id = '';
}
public currentGemImprovement() {
diff --git a/src/classes/game/Grid.ts b/src/classes/game/Grid.ts
index dd3c1a4..3416bb0 100644
--- a/src/classes/game/Grid.ts
+++ b/src/classes/game/Grid.ts
@@ -6,6 +6,8 @@ import { Engine } from '../Bastion';
import Creep from './Creep';
import { CreepEvents, TowerEvents, GridEvents } from '../Events';
+let genPath = [];
+
export class Cell extends GameObject {
public type: TerrainType;
public row: number;
@@ -55,6 +57,7 @@ export class Cell extends GameObject {
Engine.GameScene.events.emit(GridEvents.CellMouseLeave, this);
Engine.Grid.rangePreview.clear();
});
+
Engine.GameScene.events.on(TowerEvents.TowerPlacedEvent, (_, row, col) => {
if (row == this.row && col == this.column) {
this.hasTowerPlaced = true;
@@ -68,11 +71,13 @@ export class Cell extends GameObject {
});
// Disable this if you want to add new maps.
- // if(true) return;
+ if (true) return;
+
const text = new PIXI.Text({
text: `${this.column}|${this.row}`,
style: new PIXI.TextStyle({
fill: 0xffffff,
+ fontSize: 16,
stroke: {
color: 0x000000,
width: 2,
@@ -87,6 +92,18 @@ export class Cell extends GameObject {
text.style.fill = 'pink';
text.style.fontWeight = 'bold';
}
+ this.clickDetector.on('pointerup', () => {
+ const cellIndex = genPath.findIndex(([col, row]) => col === this.column && row === this.row);
+ if (cellIndex !== -1) {
+ text.style.fill = 0xffffff;
+ genPath.splice(cellIndex, 1);
+ } else {
+ text.style.fill = 0xff0000;
+ genPath.push([this.column, this.row]);
+ }
+ console.log('updated gen path');
+ console.log(JSON.stringify(genPath));
+ });
}
public showRangePreview(invalid, range) {
let color = 0xffffff;
diff --git a/src/classes/game/NotificationManager.ts b/src/classes/game/NotificationManager.ts
index 737be4e..547155b 100644
--- a/src/classes/game/NotificationManager.ts
+++ b/src/classes/game/NotificationManager.ts
@@ -3,7 +3,7 @@ import GameObject from '../GameObject';
import * as PIXI from 'pixi.js';
import { FadeInOut } from './AnimationManager';
-export type NotificationType = 'info' | 'warn' | 'danger' | 'reward' | 'gemaward';
+export type NotificationType = 'info' | 'warn' | 'danger' | 'reward' | 'gemaward' | 'green';
class Notification {
public textObj: PIXI.Text;
@@ -22,6 +22,8 @@ class Notification {
fill = 0xd65afc;
} else if (type == 'gemaward') {
fill = 0xffffff;
+ } else if (type == 'green') {
+ fill = 0x00ff00;
}
this.ticksToFadeAway = ticksToFadeAway;
this.textObj = new PIXI.Text({
diff --git a/src/classes/game/WaveManager.ts b/src/classes/game/WaveManager.ts
index 0adbf9d..4c73a1e 100644
--- a/src/classes/game/WaveManager.ts
+++ b/src/classes/game/WaveManager.ts
@@ -17,31 +17,38 @@ export default class WaveManager extends GameObject {
private paths: PathDefinition[];
private ticks: number = 0;
private started: boolean = false;
- public finished: boolean = false;
private internalCreepId: number = 0;
+ private pathsIndex: number;
+ public finished: boolean = false;
+
constructor(rounds: MissionRoundDefinition[], paths: PathDefinition[]) {
super();
Engine.WaveManager = this;
this.rounds = rounds;
this.paths = paths;
+ this.pathsIndex = 0;
}
public start(roundIndex) {
this.started = true;
this.ticks = 0;
this.creeps = [];
this.finished = false;
+ if (this.pathsIndex + 1 == this.paths.length) {
+ this.pathsIndex = 0;
+ } else {
+ this.pathsIndex++;
+ }
let tickToSpawnAt = 0;
this.rounds[roundIndex].waves.forEach((wave) => {
tickToSpawnAt += wave.firstCreepSpawnTick;
wave.creeps.forEach((creep) => {
- const creepObj = new Creep(creep, this.paths[0], this.internalCreepId);
+ const creepObj = new Creep(creep, this.paths[this.pathsIndex], this.internalCreepId);
this.internalCreepId++;
const creepInstance = {
creep: creepObj,
tickToSpawnAt,
spawned: false,
};
- console.log('CREAWTASEDASD');
tickToSpawnAt += wave.spawnIntervalTicks;
this.creeps.push(creepInstance);
});
@@ -58,10 +65,8 @@ export default class WaveManager extends GameObject {
if (!creep.spawned && creep.tickToSpawnAt <= this.ticks) {
creep.spawned = true;
this.events.emit(WaveManagerEvents.CreepSpawned, creep.creep);
- console.log('Wave manager creep spawned, ', creep, this.ticks);
if (!this.finished && this.creeps.every((creep) => creep.spawned)) {
this.finished = true;
- console.log('wave manager finished');
this.events.emit(WaveManagerEvents.Finished);
}
} else if (creep.spawned) {
diff --git a/src/main.ts b/src/main.ts
index dcb047e..6311fad 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -6,8 +6,8 @@ import { GameScene } from './scenes/Game';
import { AnimationManager } from './classes/game/AnimationManager';
import NotificationManager from './classes/game/NotificationManager';
import GameUIConstants from './classes/GameUIConstants';
-import MessageBox from './classes/gui/MessageBox';
import KeyboardManager from './classes/game/KeyboardManager';
+import { GemType } from './classes/Definitions';
(async () => {
const app = new PIXI.Application();
diff --git a/src/scenes/Game.ts b/src/scenes/Game.ts
index 3ad74e3..8ed5ebf 100644
--- a/src/scenes/Game.ts
+++ b/src/scenes/Game.ts
@@ -59,6 +59,7 @@ export class GameScene extends Scene {
});
}
public init() {
+ Engine.latestGemId = 0;
new Grid(this.mission.gameMap, this.missionIndex);
new TowerManager();
new WaveManager(this.mission.rounds, this.mission.gameMap.paths);
@@ -257,10 +258,14 @@ export class GameScene extends Scene {
this.ReturnToMain();
} else if (result === HighScoreDialogButtons.NextMission) {
this.destroy();
+ Engine.GameMaster.changeScene(new MissionPickerScene());
Engine.GameMaster.changeScene(new GameScene(GameAssets.Missions[this.missionIndex + 1].name));
+ Engine.NotificationManager.Notify('Loading next mission. Good luck.', 'green');
} else if (result === HighScoreDialogButtons.Retry) {
this.destroy();
+ Engine.GameMaster.changeScene(new MissionPickerScene());
Engine.GameMaster.changeScene(new GameScene(this.mission.name));
+ Engine.NotificationManager.Notify('Retrying mission.', 'green');
}
}
diff --git a/src/scenes/Scene.ts b/src/scenes/Scene.ts
index 0e2d9d6..0686908 100644
--- a/src/scenes/Scene.ts
+++ b/src/scenes/Scene.ts
@@ -12,6 +12,7 @@ export default class Scene {
}
public destroy() {
this.stage.destroy();
+ this._events.removeAllListeners();
this.gui.forEach((element) => {
element.destroy();
});