From bc5878b6d3783e0cdd2ff611ab83aed516f12f09 Mon Sep 17 00:00:00 2001 From: koneko <67551503+koneko@users.noreply.github.com> Date: Thu, 3 Oct 2024 22:01:55 +0200 Subject: [PATCH] updated mission_01 to match defintions.ts --- public/assets/missions/mission_01.json | 101 +++++++++++++------------ src/base/Definitions.ts | 1 + src/components/Creep.ts | 2 +- src/components/WaveManger.ts | 13 ++++ src/scenes/GameScene.ts | 3 + 5 files changed, 71 insertions(+), 49 deletions(-) create mode 100644 src/components/WaveManger.ts diff --git a/public/assets/missions/mission_01.json b/public/assets/missions/mission_01.json index c784932..ac67b3a 100644 --- a/public/assets/missions/mission_01.json +++ b/public/assets/missions/mission_01.json @@ -1,51 +1,56 @@ { - "name": "Mission 1", - "description": "This is the first mission", - "gameMap": { - "rows": 10, - "columns": 10, - "cells": [ - [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], - [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], - [1, 1, 1, 1, 1, 1, 1, 1, 0, 1], - [1, 1, 1, 1, 1, 0, 0, 0, 1, 1], - [1, 1, 1, 1, 1, 0, 0, 1, 1, 1], - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] - ], - "paths": [ - [ - [0, 2], - [1, 2], - [2, 2], - [3, 2], - [4, 2], - [5, 2], - [6, 2], - [7, 2], - [8, 2], - [9, 2] - ] - ], - "waves": [ - { - "firstCreepSpawnTick": 120, - "spawnIntervalTicks": 60, - "creeps": [0, 0, 0, 0, 0, 1, 1, 1, 0] - }, - { - "firstCreepSpawnTick": 480, - "spawnIntervalTicks": 60, - "creeps": [0, 0, 0, 0, 0, 1, 1, 1, 0] - }, - { - "firstCreepSpawnTick": 480, - "spawnIntervalTicks": 60, - "creeps": [0, 0, 0, 0, 0, 1, 1, 1, 0] - } + "name": "Mission 1", + "description": "This is the first mission", + "gameMap": { + "rows": 10, + "columns": 10, + "cells": [ + [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 0, 1], + [1, 1, 1, 1, 1, 0, 0, 0, 1, 1], + [1, 1, 1, 1, 1, 0, 0, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + ], + "paths": [ + [ + [0, 2], + [1, 2], + [2, 2], + [3, 2], + [4, 2], + [5, 2], + [6, 2], + [7, 2], + [8, 2], + [9, 2] + ] + ] + }, + "rounds": [ + { + "waves": [ + { + "firstCreepSpawnTick": 120, + "spawnIntervalTicks": 60, + "creeps": [0, 0, 0, 0, 0, 1, 1, 1, 0] + }, + { + "firstCreepSpawnTick": 480, + "spawnIntervalTicks": 60, + "creeps": [0, 0, 0, 0, 0, 1, 1, 1, 0] + }, + { + "firstCreepSpawnTick": 480, + "spawnIntervalTicks": 60, + "creeps": [0, 0, 0, 0, 0, 1, 1, 1, 0] + } + ], + "offeredGems": [0, 1, 2, 3] + } ] - } } diff --git a/src/base/Definitions.ts b/src/base/Definitions.ts index 698cbab..d49be9f 100644 --- a/src/base/Definitions.ts +++ b/src/base/Definitions.ts @@ -3,6 +3,7 @@ export type MissionDefinition = { description: string; mapImageUrl: string; gameMap: GameMapDefinition; + missionRounds: MissionRoundDefinition[]; }; export type GameMapDefinition = { diff --git a/src/components/Creep.ts b/src/components/Creep.ts index 0562917..cbc427c 100644 --- a/src/components/Creep.ts +++ b/src/components/Creep.ts @@ -1,7 +1,7 @@ import GameObject from '../base/GameObject'; import * as PIXI from 'pixi.js'; -export class Creep extends GameObject { +export default class Creep extends GameObject { constructor(bounds?: PIXI.Rectangle) { super(bounds); } diff --git a/src/components/WaveManger.ts b/src/components/WaveManger.ts new file mode 100644 index 0000000..c2d529d --- /dev/null +++ b/src/components/WaveManger.ts @@ -0,0 +1,13 @@ +import Creep from './Creep'; + +export default class WaveManager { + // Doesn't need to extend GameObject since it does not render + private totalWaves: number; + private currentWave: number; + private creeps: Creep[]; + private spawnIntervalTicks: number; + private firstCreepSpawnTick: number; + constructor(totalWaves) { + this.totalWaves = totalWaves; + } +} diff --git a/src/scenes/GameScene.ts b/src/scenes/GameScene.ts index 1da71dc..64d1d38 100644 --- a/src/scenes/GameScene.ts +++ b/src/scenes/GameScene.ts @@ -2,6 +2,7 @@ import Button from '../base/Button'; import { MissionDefinition } from '../base/Definitions'; import { Grid } from '../components/Grid'; import MissionStats from '../components/MissionStats'; +import WaveManager from '../components/WaveManger'; import SceneBase from './SceneBase'; import * as PIXI from 'pixi.js'; @@ -9,6 +10,7 @@ export default class GameScene extends SceneBase { private ticker: PIXI.Ticker; private stats: MissionStats; private grid: Grid; + private WaveManager: WaveManager; constructor(mission: MissionDefinition, bounds: PIXI.Rectangle) { super(bounds); @@ -20,6 +22,7 @@ export default class GameScene extends SceneBase { this.ticker.start(); this.stats = new MissionStats(100, 200); this.grid = new Grid(mission.gameMap); + this.WaveManager = new WaveManager(mission); this.draw(); }