updated mission_01 to match defintions.ts

This commit is contained in:
koneko 2024-10-03 22:01:55 +02:00
parent 1d2473dae8
commit bc5878b6d3
5 changed files with 71 additions and 49 deletions

View File

@ -1,51 +1,56 @@
{ {
"name": "Mission 1", "name": "Mission 1",
"description": "This is the first mission", "description": "This is the first mission",
"gameMap": { "gameMap": {
"rows": 10, "rows": 10,
"columns": 10, "columns": 10,
"cells": [ "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, 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, 1, 1, 1, 0, 1],
[1, 1, 1, 1, 1, 0, 0, 0, 1, 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, 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], [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": [ "paths": [
[ [
[0, 2], [0, 2],
[1, 2], [1, 2],
[2, 2], [2, 2],
[3, 2], [3, 2],
[4, 2], [4, 2],
[5, 2], [5, 2],
[6, 2], [6, 2],
[7, 2], [7, 2],
[8, 2], [8, 2],
[9, 2] [9, 2]
] ]
], ]
"waves": [ },
{ "rounds": [
"firstCreepSpawnTick": 120, {
"spawnIntervalTicks": 60, "waves": [
"creeps": [0, 0, 0, 0, 0, 1, 1, 1, 0] {
}, "firstCreepSpawnTick": 120,
{ "spawnIntervalTicks": 60,
"firstCreepSpawnTick": 480, "creeps": [0, 0, 0, 0, 0, 1, 1, 1, 0]
"spawnIntervalTicks": 60, },
"creeps": [0, 0, 0, 0, 0, 1, 1, 1, 0] {
}, "firstCreepSpawnTick": 480,
{ "spawnIntervalTicks": 60,
"firstCreepSpawnTick": 480, "creeps": [0, 0, 0, 0, 0, 1, 1, 1, 0]
"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]
}
] ]
}
} }

View File

@ -3,6 +3,7 @@ export type MissionDefinition = {
description: string; description: string;
mapImageUrl: string; mapImageUrl: string;
gameMap: GameMapDefinition; gameMap: GameMapDefinition;
missionRounds: MissionRoundDefinition[];
}; };
export type GameMapDefinition = { export type GameMapDefinition = {

View File

@ -1,7 +1,7 @@
import GameObject from '../base/GameObject'; import GameObject from '../base/GameObject';
import * as PIXI from 'pixi.js'; import * as PIXI from 'pixi.js';
export class Creep extends GameObject { export default class Creep extends GameObject {
constructor(bounds?: PIXI.Rectangle) { constructor(bounds?: PIXI.Rectangle) {
super(bounds); super(bounds);
} }

View File

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

View File

@ -2,6 +2,7 @@ import Button from '../base/Button';
import { MissionDefinition } from '../base/Definitions'; import { MissionDefinition } from '../base/Definitions';
import { Grid } from '../components/Grid'; import { Grid } from '../components/Grid';
import MissionStats from '../components/MissionStats'; import MissionStats from '../components/MissionStats';
import WaveManager from '../components/WaveManger';
import SceneBase from './SceneBase'; import SceneBase from './SceneBase';
import * as PIXI from 'pixi.js'; import * as PIXI from 'pixi.js';
@ -9,6 +10,7 @@ export default class GameScene extends SceneBase {
private ticker: PIXI.Ticker; private ticker: PIXI.Ticker;
private stats: MissionStats; private stats: MissionStats;
private grid: Grid; private grid: Grid;
private WaveManager: WaveManager;
constructor(mission: MissionDefinition, bounds: PIXI.Rectangle) { constructor(mission: MissionDefinition, bounds: PIXI.Rectangle) {
super(bounds); super(bounds);
@ -20,6 +22,7 @@ export default class GameScene extends SceneBase {
this.ticker.start(); this.ticker.start();
this.stats = new MissionStats(100, 200); this.stats = new MissionStats(100, 200);
this.grid = new Grid(mission.gameMap); this.grid = new Grid(mission.gameMap);
this.WaveManager = new WaveManager(mission);
this.draw(); this.draw();
} }