diff --git a/src/classes/Events.ts b/src/classes/Events.ts new file mode 100644 index 0000000..cafe257 --- /dev/null +++ b/src/classes/Events.ts @@ -0,0 +1,26 @@ +export enum WaveManagerEvents { + CreepSpawned = 'creepSpawned', + Finished = 'finished', + NewWave = 'newwave', +} + +export enum CreepEvents { + Died = 'died', + TakenDamage = 'takenDamage', + Escaped = 'escaped', + Moved = 'moved', +} + +export enum GridEvents { + CellMouseOver = 'cellmouseover', + CellMouseLeave = 'cellmouseleave', +} + +export enum TowerEvents { + TowerPlacedEvent = 'towerPlacedEvent', + TowerSoldEvent = 'towerSoldEvent', +} + +export enum StatsEvents { + GemGivenEvent = 'gemGivenEvent', +} diff --git a/src/classes/game/Creep.ts b/src/classes/game/Creep.ts index 6eb0d06..af4f4e1 100644 --- a/src/classes/game/Creep.ts +++ b/src/classes/game/Creep.ts @@ -4,13 +4,7 @@ import { Engine } from '../Bastion'; import { CreepStatsDefinition, CreepType, PathDefinition } from '../Definitions'; import GameObject from '../GameObject'; import * as PIXI from 'pixi.js'; - -export enum CreepEvents { - Died = 'died', - TakenDamage = 'takenDamage', - Escaped = 'escaped', - Moved = 'moved', -} +import { CreepEvents } from '../Events'; export default class Creep extends GameObject { public id: number; diff --git a/src/classes/game/Grid.ts b/src/classes/game/Grid.ts index 2cb94f5..8479512 100644 --- a/src/classes/game/Grid.ts +++ b/src/classes/game/Grid.ts @@ -3,13 +3,8 @@ import GameObject from '../GameObject'; import { GameMapDefinition, TerrainType } from '../Definitions'; import GameAssets from '../Assets'; import { Engine } from '../Bastion'; -import Creep, { CreepEvents } from './Creep'; -import { TowerEvents } from './Tower'; - -export enum GridEvents { - CellMouseOver = 'cellmouseover', - CellMouseLeave = 'cellmouseleave', -} +import Creep from './Creep'; +import { CreepEvents, TowerEvents, GridEvents } from '../Events'; export class Cell extends GameObject { public type: TerrainType; diff --git a/src/classes/game/Inventory.ts b/src/classes/game/Inventory.ts deleted file mode 100644 index d360f8e..0000000 --- a/src/classes/game/Inventory.ts +++ /dev/null @@ -1,5 +0,0 @@ -import GameObject from '../GameObject'; - -export default class Inventory extends GameObject { - public update() {} -} diff --git a/src/classes/game/MissionStats.ts b/src/classes/game/MissionStats.ts index 98ea993..a5a6ee8 100644 --- a/src/classes/game/MissionStats.ts +++ b/src/classes/game/MissionStats.ts @@ -2,7 +2,7 @@ import Assets from '../Assets'; import { Engine } from '../Bastion'; import GameObject from '../GameObject'; import * as PIXI from 'pixi.js'; -import { WaveManagerEvents } from './WaveManager'; +import { WaveManagerEvents, StatsEvents } from '../Events'; import Gem from './Gem'; export default class MissionStats extends GameObject { @@ -51,7 +51,7 @@ export default class MissionStats extends GameObject { public giveGem(gem: Gem) { this.inventory.push(gem); - Engine.GameScene.events.emit('givegem', gem); + Engine.GameScene.events.emit(StatsEvents.GemGivenEvent, gem); } public getInventory() { diff --git a/src/classes/game/Projectile.ts b/src/classes/game/Projectile.ts index b9e6904..9ce0327 100644 --- a/src/classes/game/Projectile.ts +++ b/src/classes/game/Projectile.ts @@ -1,7 +1,8 @@ import * as PIXI from 'pixi.js'; import GameObject from '../GameObject'; import { Engine } from '../Bastion'; -import Creep, { CreepEvents } from './Creep'; +import Creep from './Creep'; +import { CreepEvents } from '../Events'; export function calculateAngleToPoint(x, y, targetX, targetY) { const dx = targetX - x; diff --git a/src/classes/game/Tower.ts b/src/classes/game/Tower.ts index dbe1237..a8fc19a 100644 --- a/src/classes/game/Tower.ts +++ b/src/classes/game/Tower.ts @@ -12,11 +12,6 @@ function distance(x1, y1, x2, y2) { return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); } -export enum TowerEvents { - TowerPlacedEvent = 'towerPlacedEvent', - TowerSoldEvent = 'towerSoldEvent', -} - export class Tower extends GameObject { public row: number; public column: number; diff --git a/src/classes/game/TowerManager.ts b/src/classes/game/TowerManager.ts index d58ff41..1082e62 100644 --- a/src/classes/game/TowerManager.ts +++ b/src/classes/game/TowerManager.ts @@ -2,8 +2,9 @@ import * as PIXI from 'pixi.js'; import { Engine } from '../Bastion'; import { TerrainType, TowerDefinition } from '../Definitions'; import GameAssets from '../Assets'; -import { Tower, TowerEvents } from './Tower'; -import { Cell, GridEvents } from './Grid'; +import { Tower } from './Tower'; +import { Cell } from './Grid'; +import { GridEvents, TowerEvents } from '../Events'; export enum TowerBehaviours { BasicTowerBehaviour = 'BasicTowerBehaviour', diff --git a/src/classes/game/WaveManager.ts b/src/classes/game/WaveManager.ts index 4d61c5b..6bc94b6 100644 --- a/src/classes/game/WaveManager.ts +++ b/src/classes/game/WaveManager.ts @@ -1,15 +1,9 @@ import { CreepType, MissionRoundDefinition, PathDefinition } from '../Definitions'; -import * as PIXI from 'pixi.js'; -import Creep, { CreepEvents } from './Creep'; +import Creep from './Creep'; import { Engine } from '../Bastion'; +import { WaveManagerEvents } from '../Events'; import GameObject from '../GameObject'; -export enum WaveManagerEvents { - CreepSpawned = 'creepSpawned', - Finished = 'finished', - NewWave = 'newwave', -} - type CreepInstance = { creep: Creep; tickToSpawnAt: number; diff --git a/src/classes/gui/TowerTab.ts b/src/classes/gui/TowerTab.ts index 2c131ff..fefd096 100644 --- a/src/classes/gui/TowerTab.ts +++ b/src/classes/gui/TowerTab.ts @@ -2,7 +2,7 @@ import * as PIXI from 'pixi.js'; import GuiObject from '../GuiObject'; import GameAssets from '../Assets'; import { Engine } from '../Bastion'; -import { TowerEvents } from '../game/Tower'; +import { TowerEvents } from '../Events'; import { TowerDefinition } from '../Definitions'; class TowerButton extends GuiObject { diff --git a/src/scenes/Game.ts b/src/scenes/Game.ts index f48a66a..ed00434 100644 --- a/src/scenes/Game.ts +++ b/src/scenes/Game.ts @@ -1,9 +1,10 @@ import GameAssets from '../classes/Assets'; import { Engine } from '../classes/Bastion'; import { MissionDefinition } from '../classes/Definitions'; -import Creep, { CreepEvents } from '../classes/game/Creep'; +import Creep from '../classes/game/Creep'; import { Grid } from '../classes/game/Grid'; -import WaveManager, { WaveManagerEvents } from '../classes/game/WaveManager'; +import WaveManager from '../classes/game/WaveManager'; +import { WaveManagerEvents, CreepEvents } from '../classes/Events'; import Sidebar from '../classes/gui/Sidebar'; import Button, { ButtonTexture } from '../classes/gui/Button'; import Scene from './Scene';