seperate events into seperate file

This commit is contained in:
koneko 2025-01-27 17:33:26 +01:00
parent d12d1e1d3c
commit 5adab98902
11 changed files with 42 additions and 40 deletions

26
src/classes/Events.ts Normal file
View File

@ -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',
}

View File

@ -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;

View File

@ -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;

View File

@ -1,5 +0,0 @@
import GameObject from '../GameObject';
export default class Inventory extends GameObject {
public update() {}
}

View File

@ -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() {

View File

@ -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;

View File

@ -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;

View File

@ -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',

View File

@ -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;

View File

@ -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 {

View File

@ -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';