mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-26 03:38:58 +00:00
Folder structure
This commit is contained in:
parent
5a98d691e1
commit
718d297318
@ -58,5 +58,13 @@
|
||||
"maxDiagonalProjectileUpgrades": 0,
|
||||
"maxHaloProjectileUpgrades": 5,
|
||||
"maxRegenerationUpgrades": 5
|
||||
},
|
||||
"enemyManager": {
|
||||
"waveEnemySpawner": {
|
||||
"cooldown": 5,
|
||||
"enemiesPerWave": 30,
|
||||
"waveLifetime": 20,
|
||||
"enemyType": "Basic"
|
||||
}
|
||||
}
|
||||
}
|
@ -2080,7 +2080,7 @@
|
||||
"_id": "936Vpv3ydL8JZMvakVgAP5"
|
||||
},
|
||||
{
|
||||
"__type__": "7914boZbMpO4oIxuuvZ61Wb",
|
||||
"__type__": "2260cGJEAdNlpJwzk5tNSzU",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
@ -2094,7 +2094,7 @@
|
||||
"__expectedType__": "cc.Prefab"
|
||||
}
|
||||
],
|
||||
"_id": "55UHuO7YRLaa/e/fP7FAK2"
|
||||
"_id": "ebqmDEqu5OGJivYBW47skm"
|
||||
},
|
||||
{
|
||||
"__type__": "839f4SZvHNBFaiDSpMi6pOJ",
|
||||
|
@ -1,6 +1,7 @@
|
||||
export class GameSettings {
|
||||
public player: PlayerSettings = new PlayerSettings();
|
||||
public upgrades: UpgradeSettings = new UpgradeSettings();
|
||||
public enemyManager: EnemyManagerSettings = new EnemyManagerSettings();
|
||||
}
|
||||
|
||||
export class PlayerSettings {
|
||||
@ -46,3 +47,14 @@ export class UpgradeSettings {
|
||||
public maxHaloProjectileUpgrades = 0;
|
||||
public maxRegenerationUpgrades = 0;
|
||||
}
|
||||
|
||||
export class EnemyManagerSettings {
|
||||
public waveEnemySpawner = new WaveEnemySpawnerSettings();
|
||||
}
|
||||
|
||||
export class WaveEnemySpawnerSettings {
|
||||
public cooldown = 0;
|
||||
public enemiesPerWave = 0;
|
||||
public waveLifetime = 0;
|
||||
public enemyType = "";
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ export class GameBootstrapper extends Component {
|
||||
this.playerCollisionSystem = new PlayerCollisionSystem(this.player, settings.player.collisionDelay);
|
||||
new WeaponCollisionSystem(this.player.Weapon);
|
||||
|
||||
this.enemyManager.init(this.player.node);
|
||||
this.enemyManager.init(this.player.node, settings.enemyManager);
|
||||
|
||||
this.haloProjectileLauncher = new HaloProjectileLauncher(
|
||||
this.haloProjectileLauncherComponent,
|
||||
|
@ -1,15 +1,17 @@
|
||||
import { Component, Node, _decorator } from "cc";
|
||||
import { EnemyManagerSettings } from "../../Data/GameSettings";
|
||||
import { XPSpawner } from "../../XP/XPSpawner";
|
||||
import { CircularEnemySpawner } from "./CircularEnemySpawner";
|
||||
import { Enemy } from "./Enemy";
|
||||
import { EnemyMovementType } from "./EnemyMovementType";
|
||||
import { EnemyMover } from "./EnemyMover";
|
||||
import { EnemySpawner } from "./EnemySpawner";
|
||||
import { EnemyMover } from "./EnemyMover/EnemyMover";
|
||||
import { FollowTargetEnemyMover } from "./EnemyMover/FollowTargetEnemyMover";
|
||||
import { WaveEnemyMover } from "./EnemyMover/WaveEnemyMover";
|
||||
import { CircularEnemySpawner } from "./EnemySpawner/CircularEnemySpawner";
|
||||
import { EnemySpawner } from "./EnemySpawner/EnemySpawner";
|
||||
import { IndividualEnemySpawner } from "./EnemySpawner/IndividualEnemySpawner";
|
||||
import { WaveEnemySpawner } from "./EnemySpawner/WaveEnemySpawner";
|
||||
import { EnemyType } from "./EnemyType";
|
||||
import { FollowTargetEnemyMover } from "./FollowTargetEnemyMover";
|
||||
import { InvididualEnemySpawner as IndividualEnemySpawner } from "./InvididualEnemySpawner";
|
||||
import { LaunchToTargetEnemyMover } from "./LaunchToTargetEnemyMover";
|
||||
import { WaveEnemySpawner } from "./WaveEnemySpawner";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("EnemyManager")
|
||||
@ -23,24 +25,24 @@ export class EnemyManager extends Component {
|
||||
private circularEnemySpawner: CircularEnemySpawner;
|
||||
private waveEnemySpawner: WaveEnemySpawner;
|
||||
|
||||
public init(targetNode: Node): void {
|
||||
public init(targetNode: Node, settings: EnemyManagerSettings): void {
|
||||
this.enemySpawner.init(targetNode);
|
||||
this.enemySpawner.EnemyAddedEvent.on(this.onEnemyAdded, this);
|
||||
this.enemySpawner.enemyRemovedEvent.on(this.onRemoveEnemy, this);
|
||||
|
||||
this.individualEnemySpawner = new IndividualEnemySpawner(this.enemySpawner, EnemyType.Basic);
|
||||
this.circularEnemySpawner = new CircularEnemySpawner(this.enemySpawner, 30, EnemyType.Basic);
|
||||
this.waveEnemySpawner = new WaveEnemySpawner(this.enemySpawner, 30, 10, EnemyType.Basic);
|
||||
this.waveEnemySpawner = new WaveEnemySpawner(this.enemySpawner, settings.waveEnemySpawner);
|
||||
|
||||
this.movementTypeToMover.set(EnemyMovementType.Follow, new FollowTargetEnemyMover(targetNode));
|
||||
this.movementTypeToMover.set(EnemyMovementType.Launch, new LaunchToTargetEnemyMover(targetNode));
|
||||
this.movementTypeToMover.set(EnemyMovementType.Launch, new WaveEnemyMover(targetNode));
|
||||
|
||||
this.xpSpawner.init();
|
||||
}
|
||||
|
||||
public gameTick(deltaTime: number): void {
|
||||
//this.individualEnemySpawner.gameTick(deltaTime);
|
||||
//this.circularEnemySpawner.gameTick(deltaTime);
|
||||
this.individualEnemySpawner.gameTick(deltaTime);
|
||||
this.circularEnemySpawner.gameTick(deltaTime);
|
||||
this.waveEnemySpawner.gameTick(deltaTime);
|
||||
|
||||
for (const kvp of this.movementTypeToMover) {
|
||||
|
12
assets/Scripts/Game/Unit/Enemy/EnemyMover.meta
Normal file
12
assets/Scripts/Game/Unit/Enemy/EnemyMover.meta
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "19a29ec1-9090-43e5-ab3f-8b7430e496ed",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import { Node } from "cc";
|
||||
import { Enemy } from "./Enemy";
|
||||
import { Enemy } from "../Enemy";
|
||||
|
||||
export abstract class EnemyMover {
|
||||
protected targetNode: Node;
|
@ -1,8 +1,8 @@
|
||||
import { Vec3 } from "cc";
|
||||
import { Enemy } from "./Enemy";
|
||||
import { Enemy } from "../Enemy";
|
||||
import { EnemyMover } from "./EnemyMover";
|
||||
|
||||
export class LaunchToTargetEnemyMover extends EnemyMover {
|
||||
export class WaveEnemyMover extends EnemyMover {
|
||||
private enemyToDirection: Map<Enemy, Vec3> = new Map<Enemy, Vec3>();
|
||||
private lastTargetPosition: Vec3 = new Vec3();
|
||||
private lastDirection: Vec3 = new Vec3();
|
@ -1,8 +1,8 @@
|
||||
import { GameTimer } from "../../../Services/GameTimer";
|
||||
import { roundToOneDecimal } from "../../../Services/Utils/MathUtils";
|
||||
import { EnemyMovementType } from "./EnemyMovementType";
|
||||
import { EnemySpawner } from "./EnemySpawner";
|
||||
import { EnemyType } from "./EnemyType";
|
||||
import { GameTimer } from "../../../../Services/GameTimer";
|
||||
import { roundToOneDecimal } from "../../../../Services/Utils/MathUtils";
|
||||
import { EnemyMovementType } from "../EnemyMovementType";
|
||||
import { EnemySpawner } from "../EnemySpawner";
|
||||
import { EnemyType } from "../EnemyType";
|
||||
|
||||
export class CircularEnemySpawner {
|
||||
private spawnTimer: GameTimer = new GameTimer(10);
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "c3d97e6e-d624-48f8-a337-7bc21688eb22",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
import { Component, Node, Prefab, Vec3, _decorator } from "cc";
|
||||
import { ISignal } from "../../../Services/EventSystem/ISignal";
|
||||
import { Signal } from "../../../Services/EventSystem/Signal";
|
||||
import { ObjectPool } from "../../../Services/ObjectPool";
|
||||
import { _decorator, Component, Prefab, Vec3, Node } from "cc";
|
||||
import { ISignal } from "../../../../Services/EventSystem/ISignal";
|
||||
import { Signal } from "../../../../Services/EventSystem/Signal";
|
||||
import { ObjectPool } from "../../../../Services/ObjectPool";
|
||||
import { Enemy } from "../Enemy";
|
||||
import { EnemyMovementType } from "../EnemyMovementType";
|
||||
|
||||
import { Enemy } from "./Enemy";
|
||||
import { EnemyMovementType } from "./EnemyMovementType";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("EnemySpawner")
|
@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "7914ba19-6cca-4ee2-8231-baebd9eb559b",
|
||||
"uuid": "2260c189-1007-4d96-9270-ce4e6d352cd4",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
@ -1,11 +1,11 @@
|
||||
import { randomRange } from "cc";
|
||||
import { GameTimer } from "../../../Services/GameTimer";
|
||||
import { randomPositiveOrNegative } from "../../../Services/Utils/MathUtils";
|
||||
import { EnemyMovementType } from "./EnemyMovementType";
|
||||
import { EnemySpawner } from "./EnemySpawner";
|
||||
import { EnemyType } from "./EnemyType";
|
||||
import { GameTimer } from "../../../../Services/GameTimer";
|
||||
import { randomPositiveOrNegative } from "../../../../Services/Utils/MathUtils";
|
||||
import { EnemyMovementType } from "../EnemyMovementType";
|
||||
import { EnemySpawner } from "../EnemySpawner";
|
||||
import { EnemyType } from "../EnemyType";
|
||||
|
||||
export class InvididualEnemySpawner {
|
||||
export class IndividualEnemySpawner {
|
||||
private spawnTimer: GameTimer = new GameTimer(1);
|
||||
|
||||
public constructor(private enemySpawner: EnemySpawner, private enemyType: EnemyType) {}
|
@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "46674857-f5ad-4112-8b5d-c19879117904",
|
||||
"uuid": "2deef32d-8a42-4617-8466-55c49b0a6439",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
@ -1,20 +1,26 @@
|
||||
import { randomRange } from "cc";
|
||||
import { GameTimer } from "../../../Services/GameTimer";
|
||||
import { randomPositiveOrNegative } from "../../../Services/Utils/MathUtils";
|
||||
import { Enemy } from "./Enemy";
|
||||
import { EnemyMovementType } from "./EnemyMovementType";
|
||||
import { EnemySpawner } from "./EnemySpawner";
|
||||
import { EnemyType } from "./EnemyType";
|
||||
import { GameTimer } from "../../../../Services/GameTimer";
|
||||
import { randomPositiveOrNegative } from "../../../../Services/Utils/MathUtils";
|
||||
import { WaveEnemySpawnerSettings } from "../../../Data/GameSettings";
|
||||
import { Enemy } from "../Enemy";
|
||||
import { EnemyMovementType } from "../EnemyMovementType";
|
||||
import { EnemySpawner } from "../EnemySpawner";
|
||||
import { EnemyType } from "../EnemyType";
|
||||
|
||||
export class WaveEnemySpawner {
|
||||
private spawnTimer: GameTimer = new GameTimer(5);
|
||||
private enemiesPerWave: number;
|
||||
private waveLifetime: number;
|
||||
private enemyType: EnemyType;
|
||||
|
||||
private spawnTimer: GameTimer;
|
||||
private waves: EnemyWave[] = [];
|
||||
public constructor(
|
||||
private enemySpawner: EnemySpawner,
|
||||
private enemiesToSpawn: number,
|
||||
private enemyLifeTime: number,
|
||||
private enemyType: EnemyType
|
||||
) {}
|
||||
|
||||
public constructor(private enemySpawner: EnemySpawner, settings: WaveEnemySpawnerSettings) {
|
||||
this.spawnTimer = new GameTimer(settings.cooldown);
|
||||
this.enemiesPerWave = settings.enemiesPerWave;
|
||||
this.waveLifetime = settings.waveLifetime;
|
||||
this.enemyType = <EnemyType>settings.enemyType;
|
||||
}
|
||||
|
||||
public gameTick(deltaTime: number): void {
|
||||
this.spawnTimer.gameTick(deltaTime);
|
||||
@ -27,9 +33,12 @@ export class WaveEnemySpawner {
|
||||
for (let i = this.waves.length - 1; 0 <= i; i--) {
|
||||
const wave: EnemyWave = this.waves[i];
|
||||
wave.lifeTimeLeft -= deltaTime;
|
||||
|
||||
if (wave.lifeTimeLeft <= 0) {
|
||||
for (const enemy of wave.enemies) {
|
||||
this.enemySpawner.returnEnemy(enemy);
|
||||
if (enemy.Health.IsAlive) {
|
||||
this.enemySpawner.returnEnemy(enemy);
|
||||
}
|
||||
}
|
||||
|
||||
this.waves.splice(i, 1);
|
||||
@ -43,8 +52,8 @@ export class WaveEnemySpawner {
|
||||
const defaultPosY: number = 200 * randomPositiveOrNegative();
|
||||
|
||||
const enemies: Enemy[] = [];
|
||||
const side: number = Math.ceil(Math.sqrt(this.enemiesToSpawn));
|
||||
for (let i = 0; i < this.enemiesToSpawn; i++) {
|
||||
const side: number = Math.ceil(Math.sqrt(this.enemiesPerWave));
|
||||
for (let i = 0; i < this.enemiesPerWave; i++) {
|
||||
const randomOffsetX: number = randomRange(-20, 20);
|
||||
const randomOffsetY: number = randomRange(-20, 20);
|
||||
const posX: number = defaultPosX + randomOffsetX + 50 * (i % side);
|
||||
@ -53,7 +62,7 @@ export class WaveEnemySpawner {
|
||||
enemies.push(enemy);
|
||||
}
|
||||
|
||||
this.waves.push({ enemies, lifeTimeLeft: this.enemyLifeTime });
|
||||
this.waves.push({ enemies, lifeTimeLeft: this.waveLifetime });
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user