migrate from perforce
This commit is contained in:
2
dist/Simulation/Actions/ISimAction.js
vendored
Normal file
2
dist/Simulation/Actions/ISimAction.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=ISimAction.js.map
|
||||
1
dist/Simulation/Actions/ISimAction.js.map
vendored
Normal file
1
dist/Simulation/Actions/ISimAction.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ISimAction.js","sourceRoot":"","sources":["../../../src/Simulation/Actions/ISimAction.ts"],"names":[],"mappings":""}
|
||||
11
dist/Simulation/Actions/SimActionFireTowers.js
vendored
Normal file
11
dist/Simulation/Actions/SimActionFireTowers.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export class SimActionFireTowers {
|
||||
execute(simMain) {
|
||||
const level = simMain.currentLevel;
|
||||
level.simCells.forEach((simCell) => {
|
||||
if (simCell.simTower != null) {
|
||||
simCell.simTower.fireIfAble();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SimActionFireTowers.js.map
|
||||
1
dist/Simulation/Actions/SimActionFireTowers.js.map
vendored
Normal file
1
dist/Simulation/Actions/SimActionFireTowers.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SimActionFireTowers.js","sourceRoot":"","sources":["../../../src/Simulation/Actions/SimActionFireTowers.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,mBAAmB;IACrB,OAAO,CAAC,OAAgB;QAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC;QACnC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAgB,EAAE,EAAE;YACxC,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;gBAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;YAClC,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
||||
33
dist/Simulation/Actions/SimActionMoveEnemies.js
vendored
Normal file
33
dist/Simulation/Actions/SimActionMoveEnemies.js
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Hex, Vector2 } from "../../Util/index.js";
|
||||
export class SimActionMoveEnemies {
|
||||
execute(simMain) {
|
||||
const simLevel = simMain.currentLevel;
|
||||
const deadEnemies = [];
|
||||
simLevel.simEnemies.forEach((simEnemy, idx) => {
|
||||
if (simEnemy.dead)
|
||||
deadEnemies.push(idx);
|
||||
});
|
||||
for (const idx of deadEnemies) {
|
||||
simLevel.simEnemies.splice(idx, 1);
|
||||
}
|
||||
for (const simEnemy of simLevel.simEnemies) {
|
||||
const duration = simEnemy.speed / simMain.gdRoot.simulation.stepsPerSecond;
|
||||
const t = (simLevel.currentStep - simEnemy.currentPathStep) * duration;
|
||||
const path2 = simLevel.simCells[simEnemy.path[simEnemy.currentPathIndex + 1]];
|
||||
if (!path2) {
|
||||
simEnemy.dead = true;
|
||||
return;
|
||||
}
|
||||
const hex2 = path2.hex;
|
||||
const pos1 = simEnemy.currentPathPosition;
|
||||
const pos2 = Hex.toWorld(hex2);
|
||||
simEnemy.position = Vector2.lerp(pos1, pos2, t);
|
||||
if (t >= 1) {
|
||||
simEnemy.currentPathIndex += 1;
|
||||
simEnemy.currentPathStep = simLevel.currentStep;
|
||||
simEnemy.onPathUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SimActionMoveEnemies.js.map
|
||||
1
dist/Simulation/Actions/SimActionMoveEnemies.js.map
vendored
Normal file
1
dist/Simulation/Actions/SimActionMoveEnemies.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SimActionMoveEnemies.js","sourceRoot":"","sources":["../../../src/Simulation/Actions/SimActionMoveEnemies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,MAAM,OAAO,oBAAoB;IACtB,OAAO,CAAC,OAAgB;QAC3B,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AI,CAAC,CAAC;gBAC/B,QAAQ,CAAC,eAAe,GAAG,QAAQ,CAAC,WAAW,CAAC;gBAChD,QAAQ,CAAC,aAAa,EAAE,CAAC;YAC7B,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}
|
||||
32
dist/Simulation/Actions/SimActionMoveProjectiles.js
vendored
Normal file
32
dist/Simulation/Actions/SimActionMoveProjectiles.js
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
export class SimActionMoveProjectiles {
|
||||
execute(simMain) {
|
||||
const simLevel = simMain.currentLevel;
|
||||
const deadProjectiles = [];
|
||||
simLevel.simProjectiles.forEach((simProjectile, idx) => {
|
||||
if (simProjectile.dead)
|
||||
deadProjectiles.push(idx);
|
||||
});
|
||||
for (const idx of deadProjectiles) {
|
||||
simLevel.simProjectiles.splice(idx, 1);
|
||||
}
|
||||
simLevel.simProjectiles.forEach((simProjectile) => {
|
||||
const target = simLevel.simEnemies[simProjectile.targetEnemyIdx];
|
||||
if (!target || target.dead) {
|
||||
simProjectile.dead = true;
|
||||
return;
|
||||
}
|
||||
const pos1 = simProjectile.position;
|
||||
const pos2 = target.position;
|
||||
const dir = pos2.subtract(pos1);
|
||||
const len = dir.magnitude();
|
||||
let duration = simProjectile.speed / simMain.gdRoot.simulation.stepsPerSecond;
|
||||
if (len < duration) {
|
||||
duration = len;
|
||||
simProjectile.dead = true;
|
||||
target.suffer(simProjectile.gdEffect);
|
||||
}
|
||||
simProjectile.position = pos1.add(dir.normalized().multiplyScalar(duration));
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SimActionMoveProjectiles.js.map
|
||||
1
dist/Simulation/Actions/SimActionMoveProjectiles.js.map
vendored
Normal file
1
dist/Simulation/Actions/SimActionMoveProjectiles.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SimActionMoveProjectiles.js","sourceRoot":"","sources":["../../../src/Simulation/Actions/SimActionMoveProjectiles.ts"],"names":[],"mappings":"AAEA,MAAM,O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,CAAC;YACD,aAAa,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
||||
31
dist/Simulation/Actions/SimActionSpawnEnemies.js
vendored
Normal file
31
dist/Simulation/Actions/SimActionSpawnEnemies.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { EEnemySize } from "../../GameData/index.js";
|
||||
import { SimCommandStartNextWave, SimEnemy } from "../index.js";
|
||||
export class SimActionSpawnEnemies {
|
||||
execute(simMain) {
|
||||
const simLevel = simMain.currentLevel;
|
||||
const gdLevel = simLevel.gdLevel;
|
||||
const step = simLevel.currentStep;
|
||||
const wave = gdLevel.waves[simLevel.currentWave];
|
||||
let spawnDelay = simMain.gdRoot.simulation.spawnDelay;
|
||||
switch (wave.size) {
|
||||
case EEnemySize.Huge:
|
||||
spawnDelay *= 2;
|
||||
break;
|
||||
case EEnemySize.Tiny:
|
||||
spawnDelay *= 0.5;
|
||||
break;
|
||||
}
|
||||
if (simLevel.enemiesLeftToSpawn > 0 && simLevel.lastEnemySpawnStep + spawnDelay * simMain.gdRoot.simulation.stepsPerSecond <= simLevel.currentStep) {
|
||||
simLevel.enemiesLeftToSpawn -= 1;
|
||||
simLevel.lastEnemySpawnStep = step;
|
||||
const route = Math.floor(Math.random() * gdLevel.enemyRoutes.length);
|
||||
const enemy = new SimEnemy(simMain.gdRoot, wave, route, simLevel);
|
||||
enemy.onPathUpdated();
|
||||
simLevel.simEnemies.push(enemy);
|
||||
}
|
||||
if (simLevel.nextWaveStep == step && !!gdLevel.waves[simLevel.currentWave + 1]) {
|
||||
simMain.addCommand(new SimCommandStartNextWave(simMain.gdRoot, simLevel));
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SimActionSpawnEnemies.js.map
|
||||
1
dist/Simulation/Actions/SimActionSpawnEnemies.js.map
vendored
Normal file
1
dist/Simulation/Actions/SimActionSpawnEnemies.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SimActionSpawnEnemies.js","sourceRoot":"","sources":["../../../src/Simulation/Actions/SimActionSpawnEnemies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAc,uBAAuB,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AAE/F,MAAM,OAAO,qBAAqB;IACvB,OAAO,CAAC,OAAgB;QAC3B,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAwB,CAAC;QAClD,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QACjC,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,CAAC;QAClC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACjD,IAAI,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC;QACtD,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;YAChB,KAAK,UAAU,CAAC,IAAI;gBAChB,UAAU,IAAI,CAAC,CAAC;gBAChB,MAAM;YACV,KAAK,UAAU,CAAC,IAAI;gBAChB,UAAU,IAAI,GAAG,CAAC;gBAClB,MAAM;QACd,CAAC;QAED,IAAI,QAAQ,CAAC,kBAAkB,GAAG,CAAC,IAAI,QAAQ,CAAC,kBAAkB,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,cAAc,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;YACjJ,QAAQ,CAAC,kBAAkB,IAAI,CAAC,CAAC;YACjC,QAAQ,CAAC,kBAAkB,GAAG,IAAI,CAAC;YAEnC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACrE,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YAClE,KAAK,CAAC,aAAa,EAAE,CAAC;YACtB,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;QAED,IAAI,QAAQ,CAAC,YAAY,IAAI,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,GAAG,CAAC,CAAC,EAAE,CAAC;YAC7E,OAAO,CAAC,UAAU,CAAC,IAAI,uBAAuB,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC9E,CAAC;IACL,CAAC;CACJ"}
|
||||
2
dist/Simulation/Commands/ISimCommand.js
vendored
Normal file
2
dist/Simulation/Commands/ISimCommand.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=ISimCommand.js.map
|
||||
1
dist/Simulation/Commands/ISimCommand.js.map
vendored
Normal file
1
dist/Simulation/Commands/ISimCommand.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ISimCommand.js","sourceRoot":"","sources":["../../../src/Simulation/Commands/ISimCommand.ts"],"names":[],"mappings":""}
|
||||
27
dist/Simulation/Commands/SimCommandBlockTerrain.js
vendored
Normal file
27
dist/Simulation/Commands/SimCommandBlockTerrain.js
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Hex } from "../../Util/index.js";
|
||||
import { ECellType } from "../index.js";
|
||||
export class SimCommandBlockTerrain {
|
||||
_hex;
|
||||
_simLevel;
|
||||
constructor(level, hex) {
|
||||
this._hex = hex;
|
||||
this._simLevel = level;
|
||||
}
|
||||
execute() {
|
||||
const simLevel = this._simLevel;
|
||||
const cellIndex = simLevel.getCellIndex(this._hex);
|
||||
const cell = simLevel.simCells[cellIndex];
|
||||
if (cell.type != ECellType.Free || cell.simTower != null || !simLevel.reservePaths(this._hex)) {
|
||||
return;
|
||||
}
|
||||
cell.type = ECellType.Blocked;
|
||||
simLevel.updateBlockedType(cell);
|
||||
for (let i = 0; i < 6; ++i) {
|
||||
const neighbourHex = Hex.neighbour(cell.hex, i);
|
||||
const neighbourIndex = simLevel.getCellIndex(neighbourHex);
|
||||
simLevel.updateBlockedType(simLevel.simCells[neighbourIndex]);
|
||||
}
|
||||
simLevel.updatePaths();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SimCommandBlockTerrain.js.map
|
||||
1
dist/Simulation/Commands/SimCommandBlockTerrain.js.map
vendored
Normal file
1
dist/Simulation/Commands/SimCommandBlockTerrain.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SimCommandBlockTerrain.js","sourceRoot":"","sources":["../../../src/Simulation/Commands/SimCommandBlockTerrain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAyB,MAAM,aAAa,CAAC;AAE/D,MAAM,OAAO,sBAAsB;IACvB,IAAI,CAAM;IACV,SAAS,CAAW;IAE5B,YAAY,KAAe,EAAE,GAAQ;QACjC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IAEM,OAAO;QACV,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5F,OAAO;QACX,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC;QAC9B,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;YACzB,MAAM,YAAY,GAAG,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAChD,MAAM,cAAc,GAAG,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;YAC3D,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC;QAClE,CAAC;QACD,QAAQ,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC;CACJ"}
|
||||
42
dist/Simulation/Commands/SimCommandCreateTower.js
vendored
Normal file
42
dist/Simulation/Commands/SimCommandCreateTower.js
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Hex } from "../../Util/index.js";
|
||||
import { ECellType, SimTower } from "../index.js";
|
||||
export class SimCommandCreateTower {
|
||||
_hex;
|
||||
_simLevel;
|
||||
_index;
|
||||
_gdRoot;
|
||||
constructor(game, level, hex, index) {
|
||||
this._gdRoot = game;
|
||||
this._hex = hex;
|
||||
this._simLevel = level;
|
||||
this._index = index;
|
||||
}
|
||||
execute() {
|
||||
const level = this._simLevel;
|
||||
const cellIndex = level.getCellIndex(this._hex);
|
||||
const cell = level.simCells[cellIndex];
|
||||
const towerData = this._gdRoot.towers[this._index];
|
||||
if (cell.type != ECellType.Free) {
|
||||
return;
|
||||
}
|
||||
if (cell.simTower != null) {
|
||||
return;
|
||||
}
|
||||
level.simEnemies.forEach((enemy) => {
|
||||
const hex = Hex.fromWorld(enemy.position);
|
||||
const enemyCellIndex = level.getCellIndex(hex);
|
||||
if (cellIndex == enemyCellIndex) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
if (level.currency < towerData.cost) {
|
||||
return;
|
||||
}
|
||||
if (level.reservePaths(this._hex)) {
|
||||
level.currency -= towerData.cost;
|
||||
cell.simTower = new SimTower(this._gdRoot, level, this._index, this._hex);
|
||||
level.updatePaths();
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SimCommandCreateTower.js.map
|
||||
1
dist/Simulation/Commands/SimCommandCreateTower.js.map
vendored
Normal file
1
dist/Simulation/Commands/SimCommandCreateTower.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SimCommandCreateTower.js","sourceRoot":"","sources":["../../../src/Simulation/Commands/SimCommandCreateTower.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAmC,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnF,MAAM,OAAO,qBAAqB;IACtB,IAAI,CAAM;IACV,SAAS,CAAW;IACpB,MAAM,CAAS;IACf,OAAO,CAAS;IAExB,YAAY,IAAY,EAAE,KAAe,EAAE,GAAQ,EAAE,KAAa;QAC9D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAED,OAAO;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC;QAC7B,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACvC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEnD,IAAI,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;YAC9B,OAAO;QACX,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YACxB,OAAO;QACX,CAAC;QAED,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,KAAe,EAAE,EAAE;YACzC,MAAM,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC1C,MAAM,cAAc,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YAC/C,IAAI,SAAS,IAAI,cAAc,EAAE,CAAC;gBAC9B,OAAO;YACX,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO;QACX,CAAC;QAED,IAAI,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,KAAK,CAAC,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1E,KAAK,CAAC,WAAW,EAAE,CAAC;QACxB,CAAC;IACL,CAAC;CACJ"}
|
||||
21
dist/Simulation/Commands/SimCommandStartNextWave.js
vendored
Normal file
21
dist/Simulation/Commands/SimCommandStartNextWave.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export class SimCommandStartNextWave {
|
||||
_simLevel;
|
||||
_gdRoot;
|
||||
constructor(gdRoot, level) {
|
||||
this._gdRoot = gdRoot;
|
||||
this._simLevel = level;
|
||||
}
|
||||
execute() {
|
||||
const level = this._simLevel;
|
||||
const data = level.gdLevel;
|
||||
level.currentWave += 1;
|
||||
if (!data.waves[level.currentWave]) {
|
||||
level.paused = true;
|
||||
return;
|
||||
}
|
||||
level.nextWaveStep = level.currentStep + this._gdRoot.simulation.waveDuration * this._gdRoot.simulation.stepsPerSecond - 1;
|
||||
level.lastEnemySpawnStep = level.currentStep;
|
||||
level.enemiesLeftToSpawn = data.waves[level.currentWave].amount;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SimCommandStartNextWave.js.map
|
||||
1
dist/Simulation/Commands/SimCommandStartNextWave.js.map
vendored
Normal file
1
dist/Simulation/Commands/SimCommandStartNextWave.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SimCommandStartNextWave.js","sourceRoot":"","sources":["../../../src/Simulation/Commands/SimCommandStartNextWave.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,uBAAuB;IACxB,SAAS,CAAW;IACpB,OAAO,CAAS;IAExB,YAAY,MAAc,EAAE,KAAe;QACvC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,OAAO;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC;QAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC;QAC3B,KAAK,CAAC,WAAW,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;YACjC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;YACpB,OAAO;QACX,CAAC;QACD,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,cAAc,GAAG,CAAC,CAAC;QAC3H,KAAK,CAAC,kBAAkB,GAAG,KAAK,CAAC,WAAW,CAAC;QAC7C,KAAK,CAAC,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;IACpE,CAAC;CACJ"}
|
||||
9
dist/Simulation/Models/ECellType.js
vendored
Normal file
9
dist/Simulation/Models/ECellType.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export var ECellType;
|
||||
(function (ECellType) {
|
||||
ECellType[ECellType["Free"] = 0] = "Free";
|
||||
ECellType[ECellType["Blocked"] = 1] = "Blocked";
|
||||
ECellType[ECellType["Entry"] = 2] = "Entry";
|
||||
ECellType[ECellType["Reserved"] = 3] = "Reserved";
|
||||
})(ECellType || (ECellType = {}));
|
||||
;
|
||||
//# sourceMappingURL=ECellType.js.map
|
||||
1
dist/Simulation/Models/ECellType.js.map
vendored
Normal file
1
dist/Simulation/Models/ECellType.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ECellType.js","sourceRoot":"","sources":["../../../src/Simulation/Models/ECellType.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACjB,yCAAQ,CAAA;IACR,+CAAW,CAAA;IACX,2CAAS,CAAA;IACT,iDAAQ,CAAA;AACZ,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AAAA,CAAC"}
|
||||
50
dist/Simulation/Models/SimCell.js
vendored
Normal file
50
dist/Simulation/Models/SimCell.js
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
export class SimCell {
|
||||
_hex;
|
||||
_distance;
|
||||
_type;
|
||||
_blockedType = -1;
|
||||
_index;
|
||||
_simTower = null;
|
||||
_pathsToTarget = [];
|
||||
constructor(hex, distance, type, index) {
|
||||
this._hex = hex;
|
||||
this._distance = distance;
|
||||
this._type = type;
|
||||
this._index = index;
|
||||
}
|
||||
;
|
||||
get hex() {
|
||||
return this._hex;
|
||||
}
|
||||
get distance() {
|
||||
return this._distance;
|
||||
}
|
||||
get type() {
|
||||
return this._type;
|
||||
}
|
||||
set type(value) {
|
||||
this._type = value;
|
||||
}
|
||||
get blockedType() {
|
||||
return this._blockedType;
|
||||
}
|
||||
set blockedType(value) {
|
||||
this._blockedType = value;
|
||||
}
|
||||
get index() {
|
||||
return this._index;
|
||||
}
|
||||
get simTower() {
|
||||
return this._simTower;
|
||||
}
|
||||
set simTower(value) {
|
||||
this._simTower = value;
|
||||
}
|
||||
get pathsToTarget() {
|
||||
return this._pathsToTarget;
|
||||
}
|
||||
set pathsToTarget(value) {
|
||||
this._pathsToTarget = value;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SimCell.js.map
|
||||
1
dist/Simulation/Models/SimCell.js.map
vendored
Normal file
1
dist/Simulation/Models/SimCell.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SimCell.js","sourceRoot":"","sources":["../../../src/Simulation/Models/SimCell.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,OAAO;IACR,IAAI,CAAM;IACV,SAAS,CAAS;IAClB,KAAK,CAAY;IACjB,YAAY,GAAW,CAAC,CAAC,CAAC;IAC1B,MAAM,CAAS;IACf,SAAS,GAAoB,IAAI,CAAC;IAClC,cAAc,GAAe,EAAE,CAAC;IAExC,YAAY,GAAQ,EAAE,QAAgB,EAAE,IAAe,EAAE,KAAa;QAClE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAAA,CAAC;IAEF,IAAW,GAAG;QACV,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAW,IAAI,CAAC,KAAgB;QAC5B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,IAAW,WAAW,CAAC,KAAa;QAChC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAW,QAAQ,CAAC,KAAe;QAC/B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED,IAAW,aAAa,CAAC,KAAiB;QACtC,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;IAChC,CAAC;CACJ"}
|
||||
136
dist/Simulation/Models/SimEnemy.js
vendored
Normal file
136
dist/Simulation/Models/SimEnemy.js
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
import { EEnemySize, EProjectileEffectType } from "../../GameData/index.js";
|
||||
export class SimEnemy {
|
||||
_index;
|
||||
_routeIdx;
|
||||
_startHex;
|
||||
_endHex;
|
||||
_path;
|
||||
_position;
|
||||
_direction;
|
||||
_currentPathIndex;
|
||||
_currentPathStep;
|
||||
_currentPathPosition;
|
||||
_dead = false;
|
||||
_simLevel;
|
||||
_gdEnemy;
|
||||
_hitPonts;
|
||||
_size;
|
||||
_speed;
|
||||
_gain;
|
||||
_gdRoot;
|
||||
constructor(gdRoot, wave, routeIdx, level) {
|
||||
const gdLevel = level.gdLevel;
|
||||
const route = gdLevel.enemyRoutes[routeIdx];
|
||||
this._gdRoot = gdRoot;
|
||||
this._index = wave.enemy;
|
||||
this._simLevel = level;
|
||||
this._hitPonts = wave.hitpoints;
|
||||
this._size = wave.size;
|
||||
this._gain = wave.gain;
|
||||
this._startHex = gdLevel.enemySpawns[route[0]];
|
||||
this._endHex = gdLevel.enemyTargets[route[1]];
|
||||
this._gdEnemy = this._gdRoot.enemies[this._index];
|
||||
this._currentPathIndex = 0;
|
||||
this._currentPathStep = level.currentStep;
|
||||
this._dead = false;
|
||||
this._routeIdx = routeIdx;
|
||||
this._path = level.simCells[level.getCellIndex(this._startHex)].pathsToTarget[routeIdx];
|
||||
this._position = level.simCells[this._path[0]].hex.toWorld();
|
||||
this._direction = level.simCells[this._path[1]].hex.toWorld().subtract(this._position).normalized();
|
||||
this._currentPathPosition = this._position;
|
||||
this._speed = this._gdEnemy.speed;
|
||||
switch (wave.size) {
|
||||
case EEnemySize.Tiny:
|
||||
this._speed *= 2;
|
||||
break;
|
||||
case EEnemySize.Huge:
|
||||
this._speed *= 0.5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
get path() {
|
||||
return this._path;
|
||||
}
|
||||
set path(value) {
|
||||
this._path = value;
|
||||
}
|
||||
get position() {
|
||||
return this._position;
|
||||
}
|
||||
set position(value) {
|
||||
this._position = value;
|
||||
}
|
||||
get direction() {
|
||||
return this._direction;
|
||||
}
|
||||
get endHex() {
|
||||
return this._endHex;
|
||||
}
|
||||
get currentPathIndex() {
|
||||
return this._currentPathIndex;
|
||||
}
|
||||
set currentPathIndex(value) {
|
||||
this._currentPathIndex = value;
|
||||
}
|
||||
get currentPathStep() {
|
||||
return this._currentPathStep;
|
||||
}
|
||||
set currentPathStep(value) {
|
||||
this._currentPathStep = value;
|
||||
}
|
||||
get currentPathPosition() {
|
||||
return this._currentPathPosition;
|
||||
}
|
||||
get dead() {
|
||||
return this._dead;
|
||||
}
|
||||
set dead(value) {
|
||||
this._dead = value;
|
||||
}
|
||||
get speed() {
|
||||
return this._speed;
|
||||
}
|
||||
get size() {
|
||||
return this._size;
|
||||
}
|
||||
get index() {
|
||||
return this._index;
|
||||
}
|
||||
suffer = (effect) => {
|
||||
switch (effect.type) {
|
||||
case EProjectileEffectType.Damage:
|
||||
{
|
||||
this._hitPonts -= effect.amount;
|
||||
if (this._hitPonts <= 0) {
|
||||
this._simLevel.currency += this._gain;
|
||||
this._dead = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
onPathUpdated = () => {
|
||||
const myPos = this._position;
|
||||
this._currentPathPosition = myPos;
|
||||
if (this._path == null) {
|
||||
return;
|
||||
}
|
||||
const current = this._path[this._currentPathIndex];
|
||||
const next = this._path[this._currentPathIndex + 1];
|
||||
if (!next) {
|
||||
return;
|
||||
}
|
||||
const cells = this._simLevel.simCells;
|
||||
const pos1 = cells[current].hex.toWorld();
|
||||
const pos2 = cells[next].hex.toWorld();
|
||||
const myDir = pos2.subtract(myPos);
|
||||
const myLen = myDir.magnitude();
|
||||
const hexDir = pos2.subtract(pos1);
|
||||
const hexLen = hexDir.magnitude();
|
||||
if (myLen > hexLen) {
|
||||
this._path.unshift(this._path[0]);
|
||||
}
|
||||
this._direction = myDir.multiplyScalar(1 / myLen);
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=SimEnemy.js.map
|
||||
1
dist/Simulation/Models/SimEnemy.js.map
vendored
Normal file
1
dist/Simulation/Models/SimEnemy.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SimEnemy.js","sourceRoot":"","sources":["../../../src/Simulation/Models/SimEnemy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAA+C,MAAM,yBAAyB,CAAC;AAIzH,MAAM,OAAO,QAAQ;IACT,MAAM,CAAS;IACf,SAAS,CAAS;IAClB,SAAS,CAAM;IACf,OAAO,CAAM;IACb,KAAK,CAAW;IAChB,SAAS,CAAU;IACnB,UAAU,CAAU;IACpB,iBAAiB,CAAS;IAC1B,gBAAgB,CAAS;IACzB,oBAAoB,CAAU;IAC9B,KAAK,GAAY,KAAK,CAAC;IACvB,SAAS,CAAW;IACpB,QAAQ,CAAU;IAClB,SAAS,CAAS;IAClB,KAAK,CAAa;IAClB,MAAM,CAAS;IACf,KAAK,CAAS;IACd,OAAO,CAAS;IAExB,YAAY,MAAc,EAAE,IAAY,EAAE,QAAgB,EAAE,KAAe;QACvE,MAAM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AAC;YACR,OAAO;QACX,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACnC,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;QAClC,IAAI,KAAK,GAAG,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;IACtD,CAAC,CAAA;CACJ"}
|
||||
262
dist/Simulation/Models/SimLevel.js
vendored
Normal file
262
dist/Simulation/Models/SimLevel.js
vendored
Normal file
@@ -0,0 +1,262 @@
|
||||
import { Hex, PathFinding } from "../../Util/index.js";
|
||||
import { ECellType, SimCell } from "../index.js";
|
||||
export class SimLevel {
|
||||
static version = 2;
|
||||
_paused = true;
|
||||
_currentStep = -1;
|
||||
_gdLevel;
|
||||
_highlightedIndex = -1;
|
||||
_currency = -1;
|
||||
_stride = -1;
|
||||
_simCells;
|
||||
_simEnemies;
|
||||
_simProjectiles;
|
||||
_nextWaveStep = -1;
|
||||
_lastEnemySpawnStep = 0;
|
||||
_currentWave;
|
||||
_enemiesLeftToSpawn;
|
||||
_levelIdx;
|
||||
_gdRoot;
|
||||
constructor(gdRoot, levelIdx) {
|
||||
this._levelIdx = levelIdx;
|
||||
this._gdRoot = gdRoot;
|
||||
this._gdLevel = gdRoot.levels[levelIdx];
|
||||
this._simCells = [];
|
||||
this._simEnemies = [];
|
||||
this._simProjectiles = [];
|
||||
this._currentStep = 0;
|
||||
this._currency = this._gdLevel.currency;
|
||||
this._currentWave = 0;
|
||||
this._enemiesLeftToSpawn = this._gdLevel.waves[0].amount;
|
||||
const radius = this._gdLevel.radius;
|
||||
this._stride = 2 * radius + 1;
|
||||
const h0 = new Hex(0, 0);
|
||||
for (let y = -radius; y <= radius; ++y) {
|
||||
for (let x = -radius; x <= radius; ++x) {
|
||||
const hex = new Hex(x, y);
|
||||
const distance = Hex.distance(hex, h0);
|
||||
const type = distance >= radius ? ECellType.Blocked : ECellType.Free;
|
||||
const cellIndex = this.getCellIndex(hex);
|
||||
this._simCells[cellIndex] = new SimCell(hex, distance, type, cellIndex);
|
||||
}
|
||||
}
|
||||
this._gdLevel.walls.forEach((wall) => {
|
||||
const cellIndex = this.getCellIndex(wall);
|
||||
this._simCells[cellIndex].type = ECellType.Blocked;
|
||||
});
|
||||
this._gdLevel.enemySpawns.forEach((hex) => {
|
||||
const cellIndex = this.getCellIndex(hex);
|
||||
this._simCells[cellIndex].type = ECellType.Entry;
|
||||
});
|
||||
this._gdLevel.enemyTargets.forEach((hex) => {
|
||||
const cellIndex = this.getCellIndex(hex);
|
||||
this._simCells[cellIndex].type = ECellType.Entry;
|
||||
});
|
||||
this._simCells.forEach((cell) => {
|
||||
this.updateBlockedType(cell);
|
||||
});
|
||||
this.updatePaths();
|
||||
}
|
||||
;
|
||||
get gdLevel() {
|
||||
return this._gdLevel;
|
||||
}
|
||||
get simCells() {
|
||||
return this._simCells;
|
||||
}
|
||||
get simEnemies() {
|
||||
return this._simEnemies;
|
||||
}
|
||||
get simProjectiles() {
|
||||
return this._simProjectiles;
|
||||
}
|
||||
get currentStep() {
|
||||
return this._currentStep;
|
||||
}
|
||||
set currentStep(value) {
|
||||
this._currentStep = value;
|
||||
}
|
||||
get currency() {
|
||||
return this._currency;
|
||||
}
|
||||
set currency(value) {
|
||||
this._currency = value;
|
||||
}
|
||||
get highlightedIndex() {
|
||||
return this._highlightedIndex;
|
||||
}
|
||||
set highlightedIndex(value) {
|
||||
this._highlightedIndex = value;
|
||||
}
|
||||
get paused() {
|
||||
return this._paused;
|
||||
}
|
||||
set paused(value) {
|
||||
this._paused = value;
|
||||
}
|
||||
get currentWave() {
|
||||
return this._currentWave;
|
||||
}
|
||||
set currentWave(value) {
|
||||
this._currentWave = value;
|
||||
}
|
||||
get nextWaveStep() {
|
||||
return this._nextWaveStep;
|
||||
}
|
||||
set nextWaveStep(value) {
|
||||
this._nextWaveStep = value;
|
||||
}
|
||||
get lastEnemySpawnStep() {
|
||||
return this._lastEnemySpawnStep;
|
||||
}
|
||||
set lastEnemySpawnStep(value) {
|
||||
this._lastEnemySpawnStep = value;
|
||||
}
|
||||
get enemiesLeftToSpawn() {
|
||||
return this._enemiesLeftToSpawn;
|
||||
}
|
||||
set enemiesLeftToSpawn(value) {
|
||||
this._enemiesLeftToSpawn = value;
|
||||
}
|
||||
serialize() {
|
||||
const data = {
|
||||
version: SimLevel.version,
|
||||
levelIdx: this._levelIdx,
|
||||
paused: this._paused,
|
||||
gdLevel: this._gdLevel,
|
||||
currentStep: this._currentStep,
|
||||
highlightedIndex: this._highlightedIndex,
|
||||
currency: this._currency,
|
||||
stride: this._stride,
|
||||
cells: this._simCells,
|
||||
enemies: this._simEnemies,
|
||||
projectiles: this._simProjectiles,
|
||||
nextWaveStep: this._nextWaveStep,
|
||||
lastEnemySpawnStep: this._lastEnemySpawnStep,
|
||||
currentWave: this._currentWave,
|
||||
enemiesLeftToSpawn: this._enemiesLeftToSpawn
|
||||
};
|
||||
return btoa(JSON.stringify(data));
|
||||
}
|
||||
static deserialize(gdRoot, data) {
|
||||
const parsedData = JSON.parse(atob(data));
|
||||
if (parsedData.version != SimLevel.version) {
|
||||
console.warn('Unsupported version:', parsedData.version);
|
||||
return null;
|
||||
}
|
||||
let level = new SimLevel(gdRoot, parsedData.levelIdx);
|
||||
level._paused = parsedData.paused;
|
||||
level._gdLevel = parsedData.gdLevel;
|
||||
level._currentStep = parsedData.currentStep;
|
||||
level._highlightedIndex = parsedData.highlightedIndex;
|
||||
level._currency = parsedData.currency;
|
||||
level._stride = parsedData.stride;
|
||||
level._simCells = parsedData.cells;
|
||||
level._simEnemies = parsedData.enemies;
|
||||
level._simProjectiles = parsedData.projectiles;
|
||||
level._nextWaveStep = parsedData.nextWaveStep;
|
||||
level._lastEnemySpawnStep = parsedData.lastEnemySpawnStep;
|
||||
level._currentWave = parsedData.currentWave;
|
||||
level._enemiesLeftToSpawn = parsedData.enemiesLeftToSpawn;
|
||||
return level;
|
||||
}
|
||||
getCellIndex(hex) {
|
||||
const x = hex.col + this._gdLevel.radius;
|
||||
const y = hex.row + this._gdLevel.radius;
|
||||
if (x < 0 || x >= this._stride || y < 0 || y >= this._stride) {
|
||||
return -1;
|
||||
}
|
||||
return y * this._stride + x;
|
||||
}
|
||||
getNeighbourCell(cell, direction) {
|
||||
const hex = cell.hex;
|
||||
const neighbourHex = Hex.neighbour(hex, direction);
|
||||
const neighbourIndex = this.getCellIndex(neighbourHex);
|
||||
return this._simCells[neighbourIndex];
|
||||
}
|
||||
updateBlockedType(cell) {
|
||||
if (cell.type == ECellType.Free) {
|
||||
cell.blockedType = -1;
|
||||
return;
|
||||
}
|
||||
if (cell.type == ECellType.Entry && cell.blockedType != -1) {
|
||||
return;
|
||||
}
|
||||
let blockedType = 0;
|
||||
for (let direction = 0; direction < 6; ++direction) {
|
||||
const neighbourCell = this.getNeighbourCell(cell, direction);
|
||||
if (!!neighbourCell && neighbourCell.type == ECellType.Free) {
|
||||
blockedType |= 1 << direction;
|
||||
}
|
||||
}
|
||||
cell.blockedType = blockedType;
|
||||
}
|
||||
reservePaths(hexToBlock) {
|
||||
try {
|
||||
if (!!hexToBlock) {
|
||||
const reservedCell = this._simCells[this.getCellIndex(hexToBlock)];
|
||||
if (reservedCell.type != ECellType.Free || !!reservedCell.simTower)
|
||||
return false;
|
||||
reservedCell.type = ECellType.Reserved;
|
||||
}
|
||||
return this.updatePaths();
|
||||
}
|
||||
finally {
|
||||
if (!!hexToBlock) {
|
||||
const reservedCell = this._simCells[this.getCellIndex(hexToBlock)];
|
||||
if (reservedCell.type == ECellType.Reserved)
|
||||
reservedCell.type = ECellType.Free;
|
||||
}
|
||||
}
|
||||
}
|
||||
updatePaths() {
|
||||
const level = this._gdLevel;
|
||||
const newRoutePaths = [];
|
||||
const newEnemyPaths = [];
|
||||
let invalid = false;
|
||||
for (const routeIdx in level.enemyRoutes) {
|
||||
const route = level.enemyRoutes[routeIdx];
|
||||
const enemySpawnHex = level.enemySpawns[route[0]];
|
||||
const enemySpawnCell = this._simCells[this.getCellIndex(enemySpawnHex)];
|
||||
const enemyTargetHex = level.enemyTargets[route[1]];
|
||||
const enemyTargetCell = this._simCells[this.getCellIndex(enemyTargetHex)];
|
||||
const path = PathFinding.bfs(this, enemySpawnCell.index, enemyTargetCell.index);
|
||||
if (path == null) {
|
||||
invalid = true;
|
||||
break;
|
||||
}
|
||||
newRoutePaths[routeIdx] = path;
|
||||
}
|
||||
if (invalid) {
|
||||
return false;
|
||||
}
|
||||
for (let idx in this._simEnemies) {
|
||||
const simEnemy = this._simEnemies[idx];
|
||||
const hex = Hex.fromWorld(simEnemy.position);
|
||||
const startIndex = this.getCellIndex(hex);
|
||||
const endIndex = this.getCellIndex(simEnemy.endHex);
|
||||
const path = PathFinding.bfs(this, startIndex, endIndex);
|
||||
if (path == null) {
|
||||
invalid = true;
|
||||
break;
|
||||
}
|
||||
newEnemyPaths[idx] = path;
|
||||
}
|
||||
if (invalid) {
|
||||
return false;
|
||||
}
|
||||
for (const routeIdx in level.enemyRoutes) {
|
||||
const route = level.enemyRoutes[routeIdx];
|
||||
const enemySpawnHex = level.enemySpawns[route[0]];
|
||||
const enemySpawnCell = this._simCells[this.getCellIndex(enemySpawnHex)];
|
||||
enemySpawnCell.pathsToTarget[routeIdx] = newRoutePaths[routeIdx];
|
||||
}
|
||||
this._simEnemies.forEach((simEnemy, idx) => {
|
||||
simEnemy.path = newEnemyPaths[idx];
|
||||
simEnemy.currentPathIndex = 0;
|
||||
simEnemy.onPathUpdated();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SimLevel.js.map
|
||||
1
dist/Simulation/Models/SimLevel.js.map
vendored
Normal file
1
dist/Simulation/Models/SimLevel.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
46
dist/Simulation/Models/SimProjectile.js
vendored
Normal file
46
dist/Simulation/Models/SimProjectile.js
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
export class SimProjectile {
|
||||
_gdEffect;
|
||||
_position;
|
||||
_targetEnemyIdx = -1;
|
||||
_spawnStep = -1;
|
||||
_speed = -1;
|
||||
_size = -1;
|
||||
_dead = false;
|
||||
constructor(level, effect, position, targetEnemyIdx, size) {
|
||||
this._gdEffect = effect;
|
||||
this._speed = effect.speed;
|
||||
this._position = position;
|
||||
this._size = size;
|
||||
this._targetEnemyIdx = targetEnemyIdx;
|
||||
this._spawnStep = level.currentStep;
|
||||
}
|
||||
;
|
||||
get gdEffect() {
|
||||
return this._gdEffect;
|
||||
}
|
||||
get position() {
|
||||
return this._position;
|
||||
}
|
||||
set position(value) {
|
||||
this._position = value;
|
||||
}
|
||||
get targetEnemyIdx() {
|
||||
return this._targetEnemyIdx;
|
||||
}
|
||||
get spawnStep() {
|
||||
return this._spawnStep;
|
||||
}
|
||||
get speed() {
|
||||
return this._speed;
|
||||
}
|
||||
get size() {
|
||||
return this._size;
|
||||
}
|
||||
get dead() {
|
||||
return this._dead;
|
||||
}
|
||||
set dead(value) {
|
||||
this._dead = value;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SimProjectile.js.map
|
||||
1
dist/Simulation/Models/SimProjectile.js.map
vendored
Normal file
1
dist/Simulation/Models/SimProjectile.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SimProjectile.js","sourceRoot":"","sources":["../../../src/Simulation/Models/SimProjectile.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,aAAa;IACd,SAAS,CAAqB;IAC9B,SAAS,CAAU;IACnB,eAAe,GAAW,CAAC,CAAC,CAAC;IAC7B,UAAU,GAAW,CAAC,CAAC,CAAC;IACxB,MAAM,GAAW,CAAC,CAAC,CAAC;IACpB,KAAK,GAAW,CAAC,CAAC,CAAC;IACnB,KAAK,GAAY,KAAK,CAAC;IAE/B,YAAY,KAAe,EAAE,MAA0B,EAAE,QAAiB,EAAE,cAAsB,EAAE,IAAY;QAC5G,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC;IACxC,CAAC;IAAA,CAAC;IAEF,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAW,QAAQ,CAAC,KAAc;QAC9B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAW,IAAI,CAAC,KAAc;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ"}
|
||||
100
dist/Simulation/Models/SimTower.js
vendored
Normal file
100
dist/Simulation/Models/SimTower.js
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
import { Hex } from "../../Util/index.js";
|
||||
import { SimProjectile } from "../index.js";
|
||||
export class SimTower {
|
||||
_lastProjectileStep = -1;
|
||||
_lastAoeStep = -1;
|
||||
_gdProjectileEffect;
|
||||
_projectileRange = -1;
|
||||
_projectileRate = -1;
|
||||
_projectileSize = -1;
|
||||
_gdAoeEffect;
|
||||
_aoeRange = -1;
|
||||
_aoeRate = -1;
|
||||
_gdTower;
|
||||
_position;
|
||||
_currentProjectileTarget = -1;
|
||||
_simLevel;
|
||||
_index;
|
||||
_gdRoot;
|
||||
constructor(gdRoot, level, index, hex) {
|
||||
this._gdRoot = gdRoot;
|
||||
this._simLevel = level;
|
||||
this._position = Hex.toWorld(hex);
|
||||
this._index = index;
|
||||
const data = this._gdRoot.towers[index];
|
||||
this._gdProjectileEffect = data.projectileEffect;
|
||||
this._projectileRange = data.projectileRange;
|
||||
this._projectileRate = data.projectileRate;
|
||||
this._projectileSize = data.projectileSize;
|
||||
this._gdAoeEffect = data.aoeEffect;
|
||||
this._aoeRange = data.aoeRange;
|
||||
this._aoeRate = data.aoeRate;
|
||||
this._gdTower = data;
|
||||
}
|
||||
get index() {
|
||||
return this._index;
|
||||
}
|
||||
fireIfAble() {
|
||||
const level = this._simLevel;
|
||||
const currentStep = this._simLevel.currentStep;
|
||||
if (this.canFireProjectile() && this._gdProjectileEffect != null) {
|
||||
level.simProjectiles.push(new SimProjectile(level, this._gdProjectileEffect, this._position, this.pickProjectileTarget(), this._projectileSize));
|
||||
this._lastProjectileStep = currentStep;
|
||||
}
|
||||
if (this.canFireAoe()) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
canFireProjectile() {
|
||||
if (this._gdProjectileEffect == null)
|
||||
return false;
|
||||
const currentStep = this._simLevel.currentStep;
|
||||
if (this._lastProjectileStep == -1 || this._lastProjectileStep + this._projectileRate < currentStep) {
|
||||
return this.isEnemyInRange(this._projectileRange);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
canFireAoe() {
|
||||
const level = this._simLevel;
|
||||
const currentStep = level.currentStep;
|
||||
if (this._gdAoeEffect != null) {
|
||||
if (this._lastAoeStep == -1 || this._lastAoeStep + this._aoeRate < currentStep) {
|
||||
return this.isEnemyInRange(this._aoeRange);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
pickProjectileTarget() {
|
||||
if (this._currentProjectileTarget != -1) {
|
||||
return this._currentProjectileTarget;
|
||||
}
|
||||
let minLength = -1;
|
||||
let candidate = -1;
|
||||
const level = this._simLevel;
|
||||
for (let idx = 0; idx < level.simEnemies.length; idx++) {
|
||||
const enemy = level.simEnemies[idx];
|
||||
const delta = enemy.currentPathPosition.subtract(this._position);
|
||||
const length = delta.magnitude();
|
||||
if (enemy.path != null && length < this._projectileRange) {
|
||||
const pathLength = enemy.path.length - enemy.currentPathIndex;
|
||||
if (minLength == -1 || pathLength < minLength) {
|
||||
candidate = idx;
|
||||
minLength = pathLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
return candidate;
|
||||
}
|
||||
isEnemyInRange(range) {
|
||||
const level = this._simLevel;
|
||||
for (const idx in level.simEnemies) {
|
||||
const enemy = level.simEnemies[idx];
|
||||
const delta = enemy.currentPathPosition.subtract(this._position);
|
||||
const length = delta.magnitude();
|
||||
if (length < range) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SimTower.js.map
|
||||
1
dist/Simulation/Models/SimTower.js.map
vendored
Normal file
1
dist/Simulation/Models/SimTower.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SimTower.js","sour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AAU,CAAC;gBAC3B,CAAC;YACL,CAAC;QACL,CAAC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAEO,cAAc,CAAC,KAAa;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC;QAC7B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;YACjC,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACpC,MAAM,KAAK,GAAG,KAAK,CAAC,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACjE,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YACjC,IAAI,MAAM,GAAG,KAAK,EAAE,CAAC;gBACjB,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}
|
||||
68
dist/Simulation/SimMain.js
vendored
Normal file
68
dist/Simulation/SimMain.js
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import { SimActionFireTowers, SimActionMoveEnemies, SimActionMoveProjectiles, SimActionSpawnEnemies, SimCommandStartNextWave, SimLevel } from "./index.js";
|
||||
export class SimMain {
|
||||
_currentLevel;
|
||||
_commands = [];
|
||||
_actions = [];
|
||||
_gdRoot;
|
||||
constructor(gdRoot, level) {
|
||||
this._gdRoot = gdRoot;
|
||||
this._currentLevel = new SimLevel(gdRoot, level);
|
||||
this._actions.push(new SimActionMoveEnemies());
|
||||
this._actions.push(new SimActionSpawnEnemies());
|
||||
this._actions.push(new SimActionFireTowers());
|
||||
this._actions.push(new SimActionMoveProjectiles());
|
||||
if (true || !this.loadModel()) {
|
||||
this.reload();
|
||||
}
|
||||
this._currentLevel.paused = true;
|
||||
}
|
||||
get gdRoot() {
|
||||
return this._gdRoot;
|
||||
}
|
||||
get currentLevel() {
|
||||
return this._currentLevel;
|
||||
}
|
||||
executeUntilStep(targetStep) {
|
||||
this.executeCommands();
|
||||
while (this._currentLevel.currentStep < targetStep) {
|
||||
this.executeOneStep();
|
||||
this._currentLevel.currentStep += 1;
|
||||
}
|
||||
}
|
||||
executeCommands() {
|
||||
const saveModel = false && this._commands.length != 0;
|
||||
this._commands.forEach((command) => {
|
||||
command.execute();
|
||||
});
|
||||
this._commands = [];
|
||||
if (saveModel) {
|
||||
this.saveModel();
|
||||
}
|
||||
}
|
||||
executeOneStep() {
|
||||
for (const action of this._actions)
|
||||
action.execute(this);
|
||||
}
|
||||
addCommand(command) {
|
||||
this._commands[this._commands.length] = command;
|
||||
}
|
||||
reload() {
|
||||
this._currentLevel = new SimLevel(this._gdRoot, 0);
|
||||
this.saveModel();
|
||||
this.addCommand(new SimCommandStartNextWave(this._gdRoot, this._currentLevel));
|
||||
}
|
||||
loadModel() {
|
||||
if (!!localStorage.htd) {
|
||||
const savedLevel = SimLevel.deserialize(this._gdRoot, localStorage.htd);
|
||||
if (!savedLevel)
|
||||
return false;
|
||||
this._currentLevel = savedLevel;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
saveModel() {
|
||||
localStorage.htd = this._currentLevel.serialize();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SimMain.js.map
|
||||
1
dist/Simulation/SimMain.js.map
vendored
Normal file
1
dist/Simulation/SimMain.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SimMain.js","sourceRoot":"","sources":["../../src/Simulation/SimMain.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,mBAAmB,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEpL,MAAM,OAAO,OAAO;IACR,aAAa,CAAW;IACxB,SAAS,GAAkB,EAAE,CAAC;IAC9B,QAAQ,GAAiB,EAAE,CAAC;IAC5B,OAAO,CAAS;IAExB,YAAY,MAAc,EAAE,KAAa;QACrC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,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,CAAC,SAAS,EAAE,CAAC;QACrB,CAAC;IACL,CAAC;IAEO,cAAc;QAClB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ;YAC9B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAEM,UAAU,CAAC,OAAoB;QAClC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;IACpD,CAAC;IAEM,MAAM;QACT,IAAI,CAAC,aAAa,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI,CAAC,UAAU,CAAC,IAAI,uBAAuB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IACnF,CAAC;IAEO,SAAS;QACb,IAAI,CAAC,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;YACrB,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;YACxE,IAAI,CAAC,UAAU;gBACX,OAAO,KAAK,CAAC;YAEjB,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC;YAChC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAEO,SAAS;QACb,YAAY,CAAC,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;IACtD,CAAC;CACJ"}
|
||||
19
dist/Simulation/index.js
vendored
Normal file
19
dist/Simulation/index.js
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { SimActionFireTowers } from "./Actions/SimActionFireTowers.js";
|
||||
import { SimActionMoveEnemies } from "./Actions/SimActionMoveEnemies.js";
|
||||
import { SimActionMoveProjectiles } from "./Actions/SimActionMoveProjectiles.js";
|
||||
import { SimActionSpawnEnemies } from "./Actions/SimActionSpawnEnemies.js";
|
||||
import { SimCommandBlockTerrain } from "./Commands/SimCommandBlockTerrain.js";
|
||||
import { SimCommandCreateTower } from "./Commands/SimCommandCreateTower.js";
|
||||
import { SimCommandStartNextWave } from "./Commands/SimCommandStartNextWave.js";
|
||||
import { ECellType } from "./Models/ECellType.js";
|
||||
import { SimCell } from "./Models/SimCell.js";
|
||||
import { SimEnemy } from "./Models/SimEnemy.js";
|
||||
import { SimLevel } from "./Models/SimLevel.js";
|
||||
import { SimProjectile } from "./Models/SimProjectile.js";
|
||||
import { SimTower } from "./Models/SimTower.js";
|
||||
import { SimMain } from "./SimMain.js";
|
||||
export { SimActionFireTowers, SimActionMoveEnemies, SimActionMoveProjectiles, SimActionSpawnEnemies };
|
||||
export { SimCommandBlockTerrain, SimCommandCreateTower, SimCommandStartNextWave };
|
||||
export { ECellType, SimCell, SimEnemy, SimLevel, SimProjectile, SimTower };
|
||||
export { SimMain };
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
dist/Simulation/index.js.map
vendored
Normal file
1
dist/Simulation/index.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Simulation/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAc,mBAAmB,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,CAAA;AACjH,OAAO,EAAe,sBAAsB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,CAAA;AAC9F,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AAC1E,OAAO,EAAE,OAAO,EAAE,CAAA"}
|
||||
Reference in New Issue
Block a user