This commit is contained in:
koneko 2025-02-07 19:51:51 +01:00
parent 8b0a65a205
commit 7f27f3aef7
16 changed files with 555 additions and 285 deletions

View File

@ -2,11 +2,10 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" /> <link rel="stylesheet" href="style.css" />
<link href="https://fonts.googleapis.com/css?family=Aclonica" rel="stylesheet" /> <link href="https://fonts.googleapis.com/css?family=Aclonica" rel="stylesheet" />
<title>Bastion App</title> <title>Bastion: The Watcher's Lament</title>
</head> </head>
<body> <body>
<script type="module" src="/src/main.ts"></script> <script type="module" src="/src/main.ts"></script>

View File

@ -28,101 +28,79 @@
], ],
"paths": [ "paths": [
[ [
[0, 4], [0, 13],
[1, 4], [1, 13],
[2, 4], [2, 13],
[3, 4], [3, 13],
[4, 4],
[5, 4],
[6, 4],
[7, 4],
[8, 4],
[9, 4],
[10, 4],
[11, 4],
[12, 4],
[13, 4],
[14, 4],
[15, 4],
[16, 4],
[16, 5],
[16, 6],
[16, 7],
[16, 8],
[16, 9],
[16, 10],
[16, 11],
[16, 12],
[16, 13],
[16, 14],
[16, 15],
[16, 16],
[16, 17],
[16, 18],
[16, 19],
[16, 20],
[16, 21],
[16, 22],
[16, 23],
[16, 24]
],
[
[4, 0],
[4, 1],
[4, 2],
[4, 3],
[4, 4],
[4, 5],
[4, 6],
[4, 7],
[4, 8],
[4, 9],
[4, 10],
[4, 11],
[4, 12],
[4, 13], [4, 13],
[4, 14], [5, 13],
[4, 15], [6, 13],
[4, 16], [7, 13],
[4, 17], [8, 13],
[4, 18], [9, 13],
[4, 19], [10, 13],
[4, 20], [11, 13],
[4, 21], [12, 13],
[4, 22], [13, 13],
[4, 23], [14, 13],
[4, 24] [15, 13],
[15, 12],
[15, 11],
[15, 10],
[16, 10],
[17, 10],
[18, 10],
[19, 10],
[20, 10],
[20, 9],
[20, 8],
[20, 7],
[20, 6],
[21, 6],
[22, 6],
[23, 6],
[24, 6]
], ],
[ [
[0, 12], [14, 0],
[1, 12], [14, 1],
[2, 12], [14, 2],
[3, 12], [13, 2],
[4, 12], [12, 2],
[5, 12], [11, 2],
[6, 12], [10, 2],
[7, 12], [9, 2],
[8, 12], [8, 2],
[9, 12], [7, 2],
[10, 12], [7, 3],
[11, 12], [7, 4],
[12, 12], [7, 5],
[13, 12], [8, 5],
[14, 12], [9, 5],
[15, 12], [10, 5],
[16, 12], [11, 5],
[16, 13], [12, 5],
[16, 14], [12, 6],
[16, 15], [12, 7],
[16, 16], [12, 8],
[16, 17], [12, 9],
[16, 18], [12, 10],
[16, 19], [13, 10],
[16, 20], [14, 10],
[16, 21], [15, 10],
[16, 22], [16, 10],
[16, 23], [17, 10],
[16, 24] [18, 10],
[19, 10],
[20, 10],
[20, 9],
[20, 8],
[20, 7],
[20, 6],
[21, 6],
[22, 6],
[23, 6],
[24, 6]
] ]
] ]
}, },
@ -140,7 +118,7 @@
"creeps": [1, 1, 2, 1, 1] "creeps": [1, 1, 2, 1, 1]
} }
], ],
"offeredGems": [0, 1, 2] "offeredGems": [0, 1, 2, 0]
}, },
{ {
"waves": [ "waves": [

View File

@ -28,97 +28,158 @@
], ],
"paths": [ "paths": [
[ [
[0, 3], [0, 1],
[1, 3], [1, 1],
[2, 3], [2, 1],
[3, 3], [3, 1],
[4, 3], [4, 1],
[4, 4], [5, 1],
[4, 5], [6, 1],
[4, 6], [7, 1],
[4, 7], [8, 1],
[4, 8], [9, 1],
[4, 9], [10, 1],
[4, 10], [11, 1],
[4, 11], [12, 1],
[4, 12], [13, 1],
[5, 12], [14, 1],
[6, 12], [15, 1],
[7, 12], [16, 1],
[8, 12], [17, 1],
[8, 13], [17, 2],
[8, 14], [17, 3],
[8, 15], [17, 4],
[8, 16], [17, 5],
[8, 17], [17, 6],
[8, 18], [17, 7],
[8, 19], [17, 8],
[8, 20], [17, 9],
[8, 21], [17, 10],
[8, 22], [17, 11],
[8, 23], [17, 12],
[8, 24] [17, 13],
], [17, 14],
[ [16, 14],
[0, 8], [15, 14],
[1, 8], [14, 14],
[2, 8], [13, 14],
[3, 8],
[4, 8],
[5, 8],
[6, 8],
[7, 8],
[8, 8],
[9, 8],
[10, 8],
[11, 8],
[12, 8],
[12, 9],
[12, 10],
[12, 11],
[12, 12],
[12, 13],
[12, 14], [12, 14],
[12, 15], [11, 14],
[12, 16], [10, 14],
[12, 17], [9, 14],
[12, 18], [8, 14],
[12, 19], [7, 14],
[12, 20], [6, 14],
[12, 21], [5, 14],
[12, 22], [5, 13],
[12, 23], [5, 12],
[12, 24] [5, 11],
[5, 10],
[5, 9],
[6, 9],
[7, 9],
[8, 9],
[9, 9],
[10, 9],
[10, 10],
[10, 11],
[11, 11],
[12, 11],
[13, 11],
[14, 11],
[14, 10],
[14, 9],
[14, 8],
[14, 7],
[15, 7],
[16, 7],
[17, 7],
[18, 7],
[19, 7],
[20, 7],
[21, 7],
[22, 7],
[22, 8],
[23, 8],
[24, 8]
], ],
[ [
[0, 13], [0, 15],
[1, 13], [1, 15],
[2, 15],
[2, 14],
[2, 13], [2, 13],
[3, 13], [2, 12],
[4, 13], [2, 11],
[4, 14], [2, 10],
[4, 15], [2, 9],
[4, 16], [2, 8],
[4, 17], [2, 7],
[4, 18], [2, 6],
[4, 19], [2, 5],
[4, 20], [2, 4],
[5, 20], [3, 4],
[6, 20], [4, 4],
[7, 20], [5, 4],
[8, 20], [6, 4],
[9, 20], [7, 4],
[10, 20], [8, 4],
[11, 20], [9, 4],
[12, 20], [10, 4],
[13, 20], [11, 4],
[14, 20], [12, 4],
[15, 20], [13, 4],
[16, 20], [14, 4],
[16, 21], [14, 5],
[16, 22], [14, 6],
[16, 23], [14, 7],
[16, 24] [14, 8],
[14, 9],
[14, 10],
[14, 11],
[13, 11],
[12, 11],
[11, 11],
[10, 11],
[10, 10],
[10, 9],
[9, 9],
[8, 9],
[7, 9],
[6, 9],
[5, 9],
[5, 10],
[5, 11],
[5, 12],
[5, 13],
[5, 14],
[6, 14],
[7, 14],
[8, 14],
[9, 14],
[10, 14],
[11, 14],
[12, 14],
[13, 14],
[14, 14],
[15, 14],
[16, 14],
[17, 14],
[17, 13],
[17, 12],
[17, 11],
[17, 10],
[17, 9],
[17, 8],
[17, 7],
[18, 7],
[19, 7],
[20, 7],
[21, 7],
[22, 7],
[22, 8],
[23, 8],
[24, 8]
] ]
] ]
}, },

View File

@ -28,101 +28,79 @@
], ],
"paths": [ "paths": [
[ [
[8, 0], [5, 0],
[8, 1], [5, 1],
[8, 2], [5, 2],
[8, 3], [4, 2],
[8, 4], [3, 2],
[2, 2],
[2, 3],
[2, 4],
[2, 5],
[3, 5],
[4, 5],
[5, 5],
[6, 5],
[7, 5],
[8, 5], [8, 5],
[8, 6], [9, 5],
[8, 7], [10, 5],
[8, 8], [11, 5],
[7, 8], [12, 5],
[6, 8], [13, 5],
[5, 8], [13, 4],
[4, 8], [13, 3],
[4, 9], [13, 2],
[4, 10], [14, 2],
[4, 11], [15, 2],
[4, 12], [16, 2],
[4, 13], [17, 2],
[4, 14], [18, 2],
[19, 2],
[20, 2],
[21, 2],
[21, 3],
[21, 4],
[21, 5],
[22, 5],
[23, 5],
[24, 5]
],
[
[0, 9],
[1, 9],
[2, 9],
[2, 10],
[2, 11],
[2, 12],
[2, 13],
[2, 14],
[2, 15],
[3, 15],
[4, 15], [4, 15],
[4, 16], [5, 15],
[4, 17], [6, 15],
[4, 18], [7, 15],
[4, 19], [8, 15],
[4, 20], [9, 15],
[4, 21], [10, 15],
[4, 22], [11, 15],
[4, 23], [11, 14],
[4, 24] [11, 13],
],
[
[8, 0],
[8, 1],
[8, 2],
[8, 3],
[8, 4],
[8, 5],
[8, 6],
[8, 7],
[8, 8],
[9, 8],
[10, 8],
[11, 8],
[12, 8],
[12, 9],
[12, 10],
[12, 11],
[12, 12],
[12, 13], [12, 13],
[12, 14], [13, 13],
[12, 15], [14, 13],
[12, 16], [15, 13],
[12, 17],
[12, 18],
[12, 19],
[12, 20],
[12, 21],
[12, 22],
[12, 23],
[12, 24]
],
[
[0, 8],
[1, 8],
[2, 8],
[3, 8],
[4, 8],
[5, 8],
[6, 8],
[7, 8],
[8, 8],
[9, 8],
[10, 8],
[11, 8],
[12, 8],
[13, 8],
[14, 8],
[15, 8],
[16, 8],
[16, 9],
[16, 10],
[16, 11],
[16, 12],
[16, 13], [16, 13],
[16, 14], [17, 13],
[16, 15], [17, 14],
[16, 16], [18, 14],
[16, 17], [19, 14],
[16, 18], [20, 14],
[16, 19], [21, 14],
[16, 20], [22, 14],
[16, 21], [23, 14],
[16, 22], [24, 14]
[16, 23],
[16, 24]
] ]
] ]
}, },

View File

@ -0,0 +1,223 @@
{
"name": "Final Stretch",
"description": "The final map, the longest map, the 7th map.",
"mapImage": {
"url": "/assets/maps/07_final_stretch.png"
},
"gameMap": {
"rows": 17,
"columns": 25,
"cells": [
[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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
],
"paths": [
[
[2, 0],
[2, 1],
[2, 2],
[2, 3],
[2, 4],
[2, 5],
[2, 6],
[2, 7],
[2, 8],
[2, 9],
[2, 10],
[2, 11],
[2, 12],
[2, 13],
[2, 14],
[3, 14],
[4, 14],
[5, 14],
[6, 14],
[6, 13],
[6, 12],
[6, 11],
[6, 10],
[6, 9],
[6, 8],
[6, 7],
[6, 6],
[6, 5],
[6, 4],
[6, 3],
[6, 2],
[7, 2],
[8, 2],
[9, 2],
[10, 2],
[10, 3],
[10, 4],
[10, 5],
[10, 6],
[10, 7],
[10, 8],
[10, 9],
[10, 10],
[10, 11],
[10, 12],
[10, 13],
[10, 14],
[11, 14],
[12, 14],
[13, 14],
[14, 14],
[14, 13],
[14, 12],
[14, 11],
[14, 10],
[14, 9],
[14, 8],
[14, 7],
[14, 6],
[14, 5],
[14, 4],
[14, 3],
[14, 2],
[15, 2],
[16, 2],
[17, 2],
[18, 2],
[18, 3],
[18, 4],
[18, 5],
[18, 6],
[18, 7],
[18, 8],
[18, 9],
[18, 10],
[18, 11],
[18, 12],
[18, 13],
[18, 14],
[19, 14],
[20, 14],
[21, 14],
[22, 14],
[22, 13],
[22, 12],
[22, 11],
[22, 10],
[22, 9],
[22, 8],
[22, 7],
[22, 6],
[22, 5],
[22, 4],
[22, 3],
[22, 2],
[22, 1],
[22, 0]
]
]
},
"rounds": [
{
"waves": [
{
"firstCreepSpawnTick": 500,
"spawnIntervalTicks": 700,
"creeps": [0, 1, 0, 1, 0, 1, 0]
},
{
"firstCreepSpawnTick": 5000,
"spawnIntervalTicks": 500,
"creeps": [1, 1, 2, 1, 1, 2, 1]
}
],
"offeredGems": [0, 1, 2, 3]
},
{
"waves": [
{
"firstCreepSpawnTick": 500,
"spawnIntervalTicks": 600,
"creeps": [2, 1, 2, 1, 2, 1, 2, 1]
},
{
"firstCreepSpawnTick": 6000,
"spawnIntervalTicks": 400,
"creeps": [2, 2, 1, 1, 2, 2, 1, 1]
}
],
"offeredGems": [0, 1, 2, 3]
},
{
"waves": [
{
"firstCreepSpawnTick": 500,
"spawnIntervalTicks": 500,
"creeps": [2, 2, 1, 1, 2, 2, 1, 1, 2]
},
{
"firstCreepSpawnTick": 6000,
"spawnIntervalTicks": 300,
"creeps": [2, 2, 2, 1, 1, 1, 2, 2, 2]
}
],
"offeredGems": [0, 1, 2, 3]
},
{
"waves": [
{
"firstCreepSpawnTick": 500,
"spawnIntervalTicks": 400,
"creeps": [2, 2, 2, 1, 1, 1, 2, 2, 2, 1]
},
{
"firstCreepSpawnTick": 7000,
"spawnIntervalTicks": 250,
"creeps": [2, 2, 2, 2, 1, 1, 1, 1, 2, 2]
}
],
"offeredGems": [0, 1, 2, 3]
},
{
"waves": [
{
"firstCreepSpawnTick": 500,
"spawnIntervalTicks": 300,
"creeps": [2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2]
},
{
"firstCreepSpawnTick": 7000,
"spawnIntervalTicks": 200,
"creeps": [2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2]
}
],
"offeredGems": [0, 1, 2, 3]
},
{
"waves": [
{
"firstCreepSpawnTick": 500,
"spawnIntervalTicks": 250,
"creeps": [2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2]
},
{
"firstCreepSpawnTick": 8000,
"spawnIntervalTicks": 150,
"creeps": [2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]
}
],
"offeredGems": [0, 1, 2, 3]
}
]
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
public/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

@ -158,6 +158,7 @@ export default class GameAssets {
await this.LoadMission('./assets/missions/04_crossroads.json'); await this.LoadMission('./assets/missions/04_crossroads.json');
await this.LoadMission('./assets/missions/05_the_maze.json'); await this.LoadMission('./assets/missions/05_the_maze.json');
await this.LoadMission('./assets/missions/06_multiple_fronts.json'); await this.LoadMission('./assets/missions/06_multiple_fronts.json');
await this.LoadMission('./assets/missions/07_final_stretch.json');
} }
private static async LoadTowers() { private static async LoadTowers() {

View File

@ -22,6 +22,7 @@ export class Engine {
public static NotificationManager: NotificationManager; public static NotificationManager: NotificationManager;
public static GameScene: GameScene; public static GameScene: GameScene;
public static latestCommit: string; public static latestCommit: string;
public static latestGemId = 0;
public static GridCellSize: number = 64; public static GridCellSize: number = 64;
public static GridColumns: number = 25; public static GridColumns: number = 25;

View File

@ -1,8 +1,7 @@
import * as PIXI from 'pixi.js'; import * as PIXI from 'pixi.js';
import { GemType, GemDefinition, GenericGemImprovement } from '../Definitions'; import { GemType, GemDefinition, GenericGemImprovement } from '../Definitions';
import GameAssets from '../Assets'; import GameAssets from '../Assets';
import { Engine } from '../Bastion';
let latestGemId = 0;
export default class Gem { export default class Gem {
public texture: PIXI.Texture; public texture: PIXI.Texture;
@ -14,8 +13,8 @@ export default class Gem {
this.texture = this.definition.textures[0]; this.texture = this.definition.textures[0];
if (!doNotIncrement) { if (!doNotIncrement) {
this.id = latestGemId + 1; this.id = Engine.latestGemId + 1;
latestGemId++; Engine.latestGemId++;
} else this.id = ''; } else this.id = '';
} }
public currentGemImprovement() { public currentGemImprovement() {

View File

@ -6,6 +6,8 @@ import { Engine } from '../Bastion';
import Creep from './Creep'; import Creep from './Creep';
import { CreepEvents, TowerEvents, GridEvents } from '../Events'; import { CreepEvents, TowerEvents, GridEvents } from '../Events';
let genPath = [];
export class Cell extends GameObject { export class Cell extends GameObject {
public type: TerrainType; public type: TerrainType;
public row: number; public row: number;
@ -55,6 +57,7 @@ export class Cell extends GameObject {
Engine.GameScene.events.emit(GridEvents.CellMouseLeave, this); Engine.GameScene.events.emit(GridEvents.CellMouseLeave, this);
Engine.Grid.rangePreview.clear(); Engine.Grid.rangePreview.clear();
}); });
Engine.GameScene.events.on(TowerEvents.TowerPlacedEvent, (_, row, col) => { Engine.GameScene.events.on(TowerEvents.TowerPlacedEvent, (_, row, col) => {
if (row == this.row && col == this.column) { if (row == this.row && col == this.column) {
this.hasTowerPlaced = true; this.hasTowerPlaced = true;
@ -68,11 +71,13 @@ export class Cell extends GameObject {
}); });
// Disable this if you want to add new maps. // Disable this if you want to add new maps.
// if(true) return; if (true) return;
const text = new PIXI.Text({ const text = new PIXI.Text({
text: `${this.column}|${this.row}`, text: `${this.column}|${this.row}`,
style: new PIXI.TextStyle({ style: new PIXI.TextStyle({
fill: 0xffffff, fill: 0xffffff,
fontSize: 16,
stroke: { stroke: {
color: 0x000000, color: 0x000000,
width: 2, width: 2,
@ -87,6 +92,18 @@ export class Cell extends GameObject {
text.style.fill = 'pink'; text.style.fill = 'pink';
text.style.fontWeight = 'bold'; text.style.fontWeight = 'bold';
} }
this.clickDetector.on('pointerup', () => {
const cellIndex = genPath.findIndex(([col, row]) => col === this.column && row === this.row);
if (cellIndex !== -1) {
text.style.fill = 0xffffff;
genPath.splice(cellIndex, 1);
} else {
text.style.fill = 0xff0000;
genPath.push([this.column, this.row]);
}
console.log('updated gen path');
console.log(JSON.stringify(genPath));
});
} }
public showRangePreview(invalid, range) { public showRangePreview(invalid, range) {
let color = 0xffffff; let color = 0xffffff;

View File

@ -3,7 +3,7 @@ import GameObject from '../GameObject';
import * as PIXI from 'pixi.js'; import * as PIXI from 'pixi.js';
import { FadeInOut } from './AnimationManager'; import { FadeInOut } from './AnimationManager';
export type NotificationType = 'info' | 'warn' | 'danger' | 'reward' | 'gemaward'; export type NotificationType = 'info' | 'warn' | 'danger' | 'reward' | 'gemaward' | 'green';
class Notification { class Notification {
public textObj: PIXI.Text; public textObj: PIXI.Text;
@ -22,6 +22,8 @@ class Notification {
fill = 0xd65afc; fill = 0xd65afc;
} else if (type == 'gemaward') { } else if (type == 'gemaward') {
fill = 0xffffff; fill = 0xffffff;
} else if (type == 'green') {
fill = 0x00ff00;
} }
this.ticksToFadeAway = ticksToFadeAway; this.ticksToFadeAway = ticksToFadeAway;
this.textObj = new PIXI.Text({ this.textObj = new PIXI.Text({

View File

@ -17,31 +17,38 @@ export default class WaveManager extends GameObject {
private paths: PathDefinition[]; private paths: PathDefinition[];
private ticks: number = 0; private ticks: number = 0;
private started: boolean = false; private started: boolean = false;
public finished: boolean = false;
private internalCreepId: number = 0; private internalCreepId: number = 0;
private pathsIndex: number;
public finished: boolean = false;
constructor(rounds: MissionRoundDefinition[], paths: PathDefinition[]) { constructor(rounds: MissionRoundDefinition[], paths: PathDefinition[]) {
super(); super();
Engine.WaveManager = this; Engine.WaveManager = this;
this.rounds = rounds; this.rounds = rounds;
this.paths = paths; this.paths = paths;
this.pathsIndex = 0;
} }
public start(roundIndex) { public start(roundIndex) {
this.started = true; this.started = true;
this.ticks = 0; this.ticks = 0;
this.creeps = []; this.creeps = [];
this.finished = false; this.finished = false;
if (this.pathsIndex + 1 == this.paths.length) {
this.pathsIndex = 0;
} else {
this.pathsIndex++;
}
let tickToSpawnAt = 0; let tickToSpawnAt = 0;
this.rounds[roundIndex].waves.forEach((wave) => { this.rounds[roundIndex].waves.forEach((wave) => {
tickToSpawnAt += wave.firstCreepSpawnTick; tickToSpawnAt += wave.firstCreepSpawnTick;
wave.creeps.forEach((creep) => { wave.creeps.forEach((creep) => {
const creepObj = new Creep(creep, this.paths[0], this.internalCreepId); const creepObj = new Creep(creep, this.paths[this.pathsIndex], this.internalCreepId);
this.internalCreepId++; this.internalCreepId++;
const creepInstance = { const creepInstance = {
creep: creepObj, creep: creepObj,
tickToSpawnAt, tickToSpawnAt,
spawned: false, spawned: false,
}; };
console.log('CREAWTASEDASD');
tickToSpawnAt += wave.spawnIntervalTicks; tickToSpawnAt += wave.spawnIntervalTicks;
this.creeps.push(creepInstance); this.creeps.push(creepInstance);
}); });
@ -58,10 +65,8 @@ export default class WaveManager extends GameObject {
if (!creep.spawned && creep.tickToSpawnAt <= this.ticks) { if (!creep.spawned && creep.tickToSpawnAt <= this.ticks) {
creep.spawned = true; creep.spawned = true;
this.events.emit(WaveManagerEvents.CreepSpawned, creep.creep); this.events.emit(WaveManagerEvents.CreepSpawned, creep.creep);
console.log('Wave manager creep spawned, ', creep, this.ticks);
if (!this.finished && this.creeps.every((creep) => creep.spawned)) { if (!this.finished && this.creeps.every((creep) => creep.spawned)) {
this.finished = true; this.finished = true;
console.log('wave manager finished');
this.events.emit(WaveManagerEvents.Finished); this.events.emit(WaveManagerEvents.Finished);
} }
} else if (creep.spawned) { } else if (creep.spawned) {

View File

@ -6,8 +6,8 @@ import { GameScene } from './scenes/Game';
import { AnimationManager } from './classes/game/AnimationManager'; import { AnimationManager } from './classes/game/AnimationManager';
import NotificationManager from './classes/game/NotificationManager'; import NotificationManager from './classes/game/NotificationManager';
import GameUIConstants from './classes/GameUIConstants'; import GameUIConstants from './classes/GameUIConstants';
import MessageBox from './classes/gui/MessageBox';
import KeyboardManager from './classes/game/KeyboardManager'; import KeyboardManager from './classes/game/KeyboardManager';
import { GemType } from './classes/Definitions';
(async () => { (async () => {
const app = new PIXI.Application(); const app = new PIXI.Application();

View File

@ -59,6 +59,7 @@ export class GameScene extends Scene {
}); });
} }
public init() { public init() {
Engine.latestGemId = 0;
new Grid(this.mission.gameMap, this.missionIndex); new Grid(this.mission.gameMap, this.missionIndex);
new TowerManager(); new TowerManager();
new WaveManager(this.mission.rounds, this.mission.gameMap.paths); new WaveManager(this.mission.rounds, this.mission.gameMap.paths);
@ -257,10 +258,14 @@ export class GameScene extends Scene {
this.ReturnToMain(); this.ReturnToMain();
} else if (result === HighScoreDialogButtons.NextMission) { } else if (result === HighScoreDialogButtons.NextMission) {
this.destroy(); this.destroy();
Engine.GameMaster.changeScene(new MissionPickerScene());
Engine.GameMaster.changeScene(new GameScene(GameAssets.Missions[this.missionIndex + 1].name)); Engine.GameMaster.changeScene(new GameScene(GameAssets.Missions[this.missionIndex + 1].name));
Engine.NotificationManager.Notify('Loading next mission. Good luck.', 'green');
} else if (result === HighScoreDialogButtons.Retry) { } else if (result === HighScoreDialogButtons.Retry) {
this.destroy(); this.destroy();
Engine.GameMaster.changeScene(new MissionPickerScene());
Engine.GameMaster.changeScene(new GameScene(this.mission.name)); Engine.GameMaster.changeScene(new GameScene(this.mission.name));
Engine.NotificationManager.Notify('Retrying mission.', 'green');
} }
} }

View File

@ -12,6 +12,7 @@ export default class Scene {
} }
public destroy() { public destroy() {
this.stage.destroy(); this.stage.destroy();
this._events.removeAllListeners();
this.gui.forEach((element) => { this.gui.forEach((element) => {
element.destroy(); element.destroy();
}); });