seperate events into seperate file
This commit is contained in:
parent
d12d1e1d3c
commit
5adab98902
26
src/classes/Events.ts
Normal file
26
src/classes/Events.ts
Normal 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',
|
||||||
|
}
|
@ -4,13 +4,7 @@ import { Engine } from '../Bastion';
|
|||||||
import { CreepStatsDefinition, CreepType, PathDefinition } from '../Definitions';
|
import { CreepStatsDefinition, CreepType, PathDefinition } from '../Definitions';
|
||||||
import GameObject from '../GameObject';
|
import GameObject from '../GameObject';
|
||||||
import * as PIXI from 'pixi.js';
|
import * as PIXI from 'pixi.js';
|
||||||
|
import { CreepEvents } from '../Events';
|
||||||
export enum CreepEvents {
|
|
||||||
Died = 'died',
|
|
||||||
TakenDamage = 'takenDamage',
|
|
||||||
Escaped = 'escaped',
|
|
||||||
Moved = 'moved',
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class Creep extends GameObject {
|
export default class Creep extends GameObject {
|
||||||
public id: number;
|
public id: number;
|
||||||
|
@ -3,13 +3,8 @@ import GameObject from '../GameObject';
|
|||||||
import { GameMapDefinition, TerrainType } from '../Definitions';
|
import { GameMapDefinition, TerrainType } from '../Definitions';
|
||||||
import GameAssets from '../Assets';
|
import GameAssets from '../Assets';
|
||||||
import { Engine } from '../Bastion';
|
import { Engine } from '../Bastion';
|
||||||
import Creep, { CreepEvents } from './Creep';
|
import Creep from './Creep';
|
||||||
import { TowerEvents } from './Tower';
|
import { CreepEvents, TowerEvents, GridEvents } from '../Events';
|
||||||
|
|
||||||
export enum GridEvents {
|
|
||||||
CellMouseOver = 'cellmouseover',
|
|
||||||
CellMouseLeave = 'cellmouseleave',
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Cell extends GameObject {
|
export class Cell extends GameObject {
|
||||||
public type: TerrainType;
|
public type: TerrainType;
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
import GameObject from '../GameObject';
|
|
||||||
|
|
||||||
export default class Inventory extends GameObject {
|
|
||||||
public update() {}
|
|
||||||
}
|
|
@ -2,7 +2,7 @@ import Assets from '../Assets';
|
|||||||
import { Engine } from '../Bastion';
|
import { Engine } from '../Bastion';
|
||||||
import GameObject from '../GameObject';
|
import GameObject from '../GameObject';
|
||||||
import * as PIXI from 'pixi.js';
|
import * as PIXI from 'pixi.js';
|
||||||
import { WaveManagerEvents } from './WaveManager';
|
import { WaveManagerEvents, StatsEvents } from '../Events';
|
||||||
import Gem from './Gem';
|
import Gem from './Gem';
|
||||||
|
|
||||||
export default class MissionStats extends GameObject {
|
export default class MissionStats extends GameObject {
|
||||||
@ -51,7 +51,7 @@ export default class MissionStats extends GameObject {
|
|||||||
|
|
||||||
public giveGem(gem: Gem) {
|
public giveGem(gem: Gem) {
|
||||||
this.inventory.push(gem);
|
this.inventory.push(gem);
|
||||||
Engine.GameScene.events.emit('givegem', gem);
|
Engine.GameScene.events.emit(StatsEvents.GemGivenEvent, gem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getInventory() {
|
public getInventory() {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import * as PIXI from 'pixi.js';
|
import * as PIXI from 'pixi.js';
|
||||||
import GameObject from '../GameObject';
|
import GameObject from '../GameObject';
|
||||||
import { Engine } from '../Bastion';
|
import { Engine } from '../Bastion';
|
||||||
import Creep, { CreepEvents } from './Creep';
|
import Creep from './Creep';
|
||||||
|
import { CreepEvents } from '../Events';
|
||||||
|
|
||||||
export function calculateAngleToPoint(x, y, targetX, targetY) {
|
export function calculateAngleToPoint(x, y, targetX, targetY) {
|
||||||
const dx = targetX - x;
|
const dx = targetX - x;
|
||||||
|
@ -12,11 +12,6 @@ function distance(x1, y1, x2, y2) {
|
|||||||
return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum TowerEvents {
|
|
||||||
TowerPlacedEvent = 'towerPlacedEvent',
|
|
||||||
TowerSoldEvent = 'towerSoldEvent',
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Tower extends GameObject {
|
export class Tower extends GameObject {
|
||||||
public row: number;
|
public row: number;
|
||||||
public column: number;
|
public column: number;
|
||||||
|
@ -2,8 +2,9 @@ import * as PIXI from 'pixi.js';
|
|||||||
import { Engine } from '../Bastion';
|
import { Engine } from '../Bastion';
|
||||||
import { TerrainType, TowerDefinition } from '../Definitions';
|
import { TerrainType, TowerDefinition } from '../Definitions';
|
||||||
import GameAssets from '../Assets';
|
import GameAssets from '../Assets';
|
||||||
import { Tower, TowerEvents } from './Tower';
|
import { Tower } from './Tower';
|
||||||
import { Cell, GridEvents } from './Grid';
|
import { Cell } from './Grid';
|
||||||
|
import { GridEvents, TowerEvents } from '../Events';
|
||||||
|
|
||||||
export enum TowerBehaviours {
|
export enum TowerBehaviours {
|
||||||
BasicTowerBehaviour = 'BasicTowerBehaviour',
|
BasicTowerBehaviour = 'BasicTowerBehaviour',
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
import { CreepType, MissionRoundDefinition, PathDefinition } from '../Definitions';
|
import { CreepType, MissionRoundDefinition, PathDefinition } from '../Definitions';
|
||||||
import * as PIXI from 'pixi.js';
|
import Creep from './Creep';
|
||||||
import Creep, { CreepEvents } from './Creep';
|
|
||||||
import { Engine } from '../Bastion';
|
import { Engine } from '../Bastion';
|
||||||
|
import { WaveManagerEvents } from '../Events';
|
||||||
import GameObject from '../GameObject';
|
import GameObject from '../GameObject';
|
||||||
|
|
||||||
export enum WaveManagerEvents {
|
|
||||||
CreepSpawned = 'creepSpawned',
|
|
||||||
Finished = 'finished',
|
|
||||||
NewWave = 'newwave',
|
|
||||||
}
|
|
||||||
|
|
||||||
type CreepInstance = {
|
type CreepInstance = {
|
||||||
creep: Creep;
|
creep: Creep;
|
||||||
tickToSpawnAt: number;
|
tickToSpawnAt: number;
|
||||||
|
@ -2,7 +2,7 @@ import * as PIXI from 'pixi.js';
|
|||||||
import GuiObject from '../GuiObject';
|
import GuiObject from '../GuiObject';
|
||||||
import GameAssets from '../Assets';
|
import GameAssets from '../Assets';
|
||||||
import { Engine } from '../Bastion';
|
import { Engine } from '../Bastion';
|
||||||
import { TowerEvents } from '../game/Tower';
|
import { TowerEvents } from '../Events';
|
||||||
import { TowerDefinition } from '../Definitions';
|
import { TowerDefinition } from '../Definitions';
|
||||||
|
|
||||||
class TowerButton extends GuiObject {
|
class TowerButton extends GuiObject {
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import GameAssets from '../classes/Assets';
|
import GameAssets from '../classes/Assets';
|
||||||
import { Engine } from '../classes/Bastion';
|
import { Engine } from '../classes/Bastion';
|
||||||
import { MissionDefinition } from '../classes/Definitions';
|
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 { 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 Sidebar from '../classes/gui/Sidebar';
|
||||||
import Button, { ButtonTexture } from '../classes/gui/Button';
|
import Button, { ButtonTexture } from '../classes/gui/Button';
|
||||||
import Scene from './Scene';
|
import Scene from './Scene';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user