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,
|
"maxDiagonalProjectileUpgrades": 0,
|
||||||
"maxHaloProjectileUpgrades": 5,
|
"maxHaloProjectileUpgrades": 5,
|
||||||
"maxRegenerationUpgrades": 5
|
"maxRegenerationUpgrades": 5
|
||||||
|
},
|
||||||
|
"enemyManager": {
|
||||||
|
"waveEnemySpawner": {
|
||||||
|
"cooldown": 5,
|
||||||
|
"enemiesPerWave": 30,
|
||||||
|
"waveLifetime": 20,
|
||||||
|
"enemyType": "Basic"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2080,7 +2080,7 @@
|
|||||||
"_id": "936Vpv3ydL8JZMvakVgAP5"
|
"_id": "936Vpv3ydL8JZMvakVgAP5"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "7914boZbMpO4oIxuuvZ61Wb",
|
"__type__": "2260cGJEAdNlpJwzk5tNSzU",
|
||||||
"_name": "",
|
"_name": "",
|
||||||
"_objFlags": 0,
|
"_objFlags": 0,
|
||||||
"node": {
|
"node": {
|
||||||
@ -2094,7 +2094,7 @@
|
|||||||
"__expectedType__": "cc.Prefab"
|
"__expectedType__": "cc.Prefab"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_id": "55UHuO7YRLaa/e/fP7FAK2"
|
"_id": "ebqmDEqu5OGJivYBW47skm"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "839f4SZvHNBFaiDSpMi6pOJ",
|
"__type__": "839f4SZvHNBFaiDSpMi6pOJ",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
export class GameSettings {
|
export class GameSettings {
|
||||||
public player: PlayerSettings = new PlayerSettings();
|
public player: PlayerSettings = new PlayerSettings();
|
||||||
public upgrades: UpgradeSettings = new UpgradeSettings();
|
public upgrades: UpgradeSettings = new UpgradeSettings();
|
||||||
|
public enemyManager: EnemyManagerSettings = new EnemyManagerSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PlayerSettings {
|
export class PlayerSettings {
|
||||||
@ -46,3 +47,14 @@ export class UpgradeSettings {
|
|||||||
public maxHaloProjectileUpgrades = 0;
|
public maxHaloProjectileUpgrades = 0;
|
||||||
public maxRegenerationUpgrades = 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);
|
this.playerCollisionSystem = new PlayerCollisionSystem(this.player, settings.player.collisionDelay);
|
||||||
new WeaponCollisionSystem(this.player.Weapon);
|
new WeaponCollisionSystem(this.player.Weapon);
|
||||||
|
|
||||||
this.enemyManager.init(this.player.node);
|
this.enemyManager.init(this.player.node, settings.enemyManager);
|
||||||
|
|
||||||
this.haloProjectileLauncher = new HaloProjectileLauncher(
|
this.haloProjectileLauncher = new HaloProjectileLauncher(
|
||||||
this.haloProjectileLauncherComponent,
|
this.haloProjectileLauncherComponent,
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
import { Component, Node, _decorator } from "cc";
|
import { Component, Node, _decorator } from "cc";
|
||||||
|
import { EnemyManagerSettings } from "../../Data/GameSettings";
|
||||||
import { XPSpawner } from "../../XP/XPSpawner";
|
import { XPSpawner } from "../../XP/XPSpawner";
|
||||||
import { CircularEnemySpawner } from "./CircularEnemySpawner";
|
|
||||||
import { Enemy } from "./Enemy";
|
import { Enemy } from "./Enemy";
|
||||||
import { EnemyMovementType } from "./EnemyMovementType";
|
import { EnemyMovementType } from "./EnemyMovementType";
|
||||||
import { EnemyMover } from "./EnemyMover";
|
import { EnemyMover } from "./EnemyMover/EnemyMover";
|
||||||
import { EnemySpawner } from "./EnemySpawner";
|
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 { 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;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@ccclass("EnemyManager")
|
@ccclass("EnemyManager")
|
||||||
@ -23,24 +25,24 @@ export class EnemyManager extends Component {
|
|||||||
private circularEnemySpawner: CircularEnemySpawner;
|
private circularEnemySpawner: CircularEnemySpawner;
|
||||||
private waveEnemySpawner: WaveEnemySpawner;
|
private waveEnemySpawner: WaveEnemySpawner;
|
||||||
|
|
||||||
public init(targetNode: Node): void {
|
public init(targetNode: Node, settings: EnemyManagerSettings): void {
|
||||||
this.enemySpawner.init(targetNode);
|
this.enemySpawner.init(targetNode);
|
||||||
this.enemySpawner.EnemyAddedEvent.on(this.onEnemyAdded, this);
|
this.enemySpawner.EnemyAddedEvent.on(this.onEnemyAdded, this);
|
||||||
this.enemySpawner.enemyRemovedEvent.on(this.onRemoveEnemy, this);
|
this.enemySpawner.enemyRemovedEvent.on(this.onRemoveEnemy, this);
|
||||||
|
|
||||||
this.individualEnemySpawner = new IndividualEnemySpawner(this.enemySpawner, EnemyType.Basic);
|
this.individualEnemySpawner = new IndividualEnemySpawner(this.enemySpawner, EnemyType.Basic);
|
||||||
this.circularEnemySpawner = new CircularEnemySpawner(this.enemySpawner, 30, 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.Follow, new FollowTargetEnemyMover(targetNode));
|
||||||
this.movementTypeToMover.set(EnemyMovementType.Launch, new LaunchToTargetEnemyMover(targetNode));
|
this.movementTypeToMover.set(EnemyMovementType.Launch, new WaveEnemyMover(targetNode));
|
||||||
|
|
||||||
this.xpSpawner.init();
|
this.xpSpawner.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public gameTick(deltaTime: number): void {
|
public gameTick(deltaTime: number): void {
|
||||||
//this.individualEnemySpawner.gameTick(deltaTime);
|
this.individualEnemySpawner.gameTick(deltaTime);
|
||||||
//this.circularEnemySpawner.gameTick(deltaTime);
|
this.circularEnemySpawner.gameTick(deltaTime);
|
||||||
this.waveEnemySpawner.gameTick(deltaTime);
|
this.waveEnemySpawner.gameTick(deltaTime);
|
||||||
|
|
||||||
for (const kvp of this.movementTypeToMover) {
|
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 { Node } from "cc";
|
||||||
import { Enemy } from "./Enemy";
|
import { Enemy } from "../Enemy";
|
||||||
|
|
||||||
export abstract class EnemyMover {
|
export abstract class EnemyMover {
|
||||||
protected targetNode: Node;
|
protected targetNode: Node;
|
@ -1,8 +1,8 @@
|
|||||||
import { Vec3 } from "cc";
|
import { Vec3 } from "cc";
|
||||||
import { Enemy } from "./Enemy";
|
import { Enemy } from "../Enemy";
|
||||||
import { EnemyMover } from "./EnemyMover";
|
import { EnemyMover } from "./EnemyMover";
|
||||||
|
|
||||||
export class LaunchToTargetEnemyMover extends EnemyMover {
|
export class WaveEnemyMover extends EnemyMover {
|
||||||
private enemyToDirection: Map<Enemy, Vec3> = new Map<Enemy, Vec3>();
|
private enemyToDirection: Map<Enemy, Vec3> = new Map<Enemy, Vec3>();
|
||||||
private lastTargetPosition: Vec3 = new Vec3();
|
private lastTargetPosition: Vec3 = new Vec3();
|
||||||
private lastDirection: Vec3 = new Vec3();
|
private lastDirection: Vec3 = new Vec3();
|
@ -1,8 +1,8 @@
|
|||||||
import { GameTimer } from "../../../Services/GameTimer";
|
import { GameTimer } from "../../../../Services/GameTimer";
|
||||||
import { roundToOneDecimal } from "../../../Services/Utils/MathUtils";
|
import { roundToOneDecimal } from "../../../../Services/Utils/MathUtils";
|
||||||
import { EnemyMovementType } from "./EnemyMovementType";
|
import { EnemyMovementType } from "../EnemyMovementType";
|
||||||
import { EnemySpawner } from "./EnemySpawner";
|
import { EnemySpawner } from "../EnemySpawner";
|
||||||
import { EnemyType } from "./EnemyType";
|
import { EnemyType } from "../EnemyType";
|
||||||
|
|
||||||
export class CircularEnemySpawner {
|
export class CircularEnemySpawner {
|
||||||
private spawnTimer: GameTimer = new GameTimer(10);
|
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 { _decorator, Component, Prefab, Vec3, Node } from "cc";
|
||||||
import { ISignal } from "../../../Services/EventSystem/ISignal";
|
import { ISignal } from "../../../../Services/EventSystem/ISignal";
|
||||||
import { Signal } from "../../../Services/EventSystem/Signal";
|
import { Signal } from "../../../../Services/EventSystem/Signal";
|
||||||
import { ObjectPool } from "../../../Services/ObjectPool";
|
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;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@ccclass("EnemySpawner")
|
@ccclass("EnemySpawner")
|
@ -2,7 +2,7 @@
|
|||||||
"ver": "4.0.23",
|
"ver": "4.0.23",
|
||||||
"importer": "typescript",
|
"importer": "typescript",
|
||||||
"imported": true,
|
"imported": true,
|
||||||
"uuid": "7914ba19-6cca-4ee2-8231-baebd9eb559b",
|
"uuid": "2260c189-1007-4d96-9270-ce4e6d352cd4",
|
||||||
"files": [],
|
"files": [],
|
||||||
"subMetas": {},
|
"subMetas": {},
|
||||||
"userData": {}
|
"userData": {}
|
@ -1,11 +1,11 @@
|
|||||||
import { randomRange } from "cc";
|
import { randomRange } from "cc";
|
||||||
import { GameTimer } from "../../../Services/GameTimer";
|
import { GameTimer } from "../../../../Services/GameTimer";
|
||||||
import { randomPositiveOrNegative } from "../../../Services/Utils/MathUtils";
|
import { randomPositiveOrNegative } from "../../../../Services/Utils/MathUtils";
|
||||||
import { EnemyMovementType } from "./EnemyMovementType";
|
import { EnemyMovementType } from "../EnemyMovementType";
|
||||||
import { EnemySpawner } from "./EnemySpawner";
|
import { EnemySpawner } from "../EnemySpawner";
|
||||||
import { EnemyType } from "./EnemyType";
|
import { EnemyType } from "../EnemyType";
|
||||||
|
|
||||||
export class InvididualEnemySpawner {
|
export class IndividualEnemySpawner {
|
||||||
private spawnTimer: GameTimer = new GameTimer(1);
|
private spawnTimer: GameTimer = new GameTimer(1);
|
||||||
|
|
||||||
public constructor(private enemySpawner: EnemySpawner, private enemyType: EnemyType) {}
|
public constructor(private enemySpawner: EnemySpawner, private enemyType: EnemyType) {}
|
@ -2,7 +2,7 @@
|
|||||||
"ver": "4.0.23",
|
"ver": "4.0.23",
|
||||||
"importer": "typescript",
|
"importer": "typescript",
|
||||||
"imported": true,
|
"imported": true,
|
||||||
"uuid": "46674857-f5ad-4112-8b5d-c19879117904",
|
"uuid": "2deef32d-8a42-4617-8466-55c49b0a6439",
|
||||||
"files": [],
|
"files": [],
|
||||||
"subMetas": {},
|
"subMetas": {},
|
||||||
"userData": {}
|
"userData": {}
|
@ -1,20 +1,26 @@
|
|||||||
import { randomRange } from "cc";
|
import { randomRange } from "cc";
|
||||||
import { GameTimer } from "../../../Services/GameTimer";
|
import { GameTimer } from "../../../../Services/GameTimer";
|
||||||
import { randomPositiveOrNegative } from "../../../Services/Utils/MathUtils";
|
import { randomPositiveOrNegative } from "../../../../Services/Utils/MathUtils";
|
||||||
import { Enemy } from "./Enemy";
|
import { WaveEnemySpawnerSettings } from "../../../Data/GameSettings";
|
||||||
import { EnemyMovementType } from "./EnemyMovementType";
|
import { Enemy } from "../Enemy";
|
||||||
import { EnemySpawner } from "./EnemySpawner";
|
import { EnemyMovementType } from "../EnemyMovementType";
|
||||||
import { EnemyType } from "./EnemyType";
|
import { EnemySpawner } from "../EnemySpawner";
|
||||||
|
import { EnemyType } from "../EnemyType";
|
||||||
|
|
||||||
export class WaveEnemySpawner {
|
export class WaveEnemySpawner {
|
||||||
private spawnTimer: GameTimer = new GameTimer(5);
|
private enemiesPerWave: number;
|
||||||
|
private waveLifetime: number;
|
||||||
|
private enemyType: EnemyType;
|
||||||
|
|
||||||
|
private spawnTimer: GameTimer;
|
||||||
private waves: EnemyWave[] = [];
|
private waves: EnemyWave[] = [];
|
||||||
public constructor(
|
|
||||||
private enemySpawner: EnemySpawner,
|
public constructor(private enemySpawner: EnemySpawner, settings: WaveEnemySpawnerSettings) {
|
||||||
private enemiesToSpawn: number,
|
this.spawnTimer = new GameTimer(settings.cooldown);
|
||||||
private enemyLifeTime: number,
|
this.enemiesPerWave = settings.enemiesPerWave;
|
||||||
private enemyType: EnemyType
|
this.waveLifetime = settings.waveLifetime;
|
||||||
) {}
|
this.enemyType = <EnemyType>settings.enemyType;
|
||||||
|
}
|
||||||
|
|
||||||
public gameTick(deltaTime: number): void {
|
public gameTick(deltaTime: number): void {
|
||||||
this.spawnTimer.gameTick(deltaTime);
|
this.spawnTimer.gameTick(deltaTime);
|
||||||
@ -27,9 +33,12 @@ export class WaveEnemySpawner {
|
|||||||
for (let i = this.waves.length - 1; 0 <= i; i--) {
|
for (let i = this.waves.length - 1; 0 <= i; i--) {
|
||||||
const wave: EnemyWave = this.waves[i];
|
const wave: EnemyWave = this.waves[i];
|
||||||
wave.lifeTimeLeft -= deltaTime;
|
wave.lifeTimeLeft -= deltaTime;
|
||||||
|
|
||||||
if (wave.lifeTimeLeft <= 0) {
|
if (wave.lifeTimeLeft <= 0) {
|
||||||
for (const enemy of wave.enemies) {
|
for (const enemy of wave.enemies) {
|
||||||
this.enemySpawner.returnEnemy(enemy);
|
if (enemy.Health.IsAlive) {
|
||||||
|
this.enemySpawner.returnEnemy(enemy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.waves.splice(i, 1);
|
this.waves.splice(i, 1);
|
||||||
@ -43,8 +52,8 @@ export class WaveEnemySpawner {
|
|||||||
const defaultPosY: number = 200 * randomPositiveOrNegative();
|
const defaultPosY: number = 200 * randomPositiveOrNegative();
|
||||||
|
|
||||||
const enemies: Enemy[] = [];
|
const enemies: Enemy[] = [];
|
||||||
const side: number = Math.ceil(Math.sqrt(this.enemiesToSpawn));
|
const side: number = Math.ceil(Math.sqrt(this.enemiesPerWave));
|
||||||
for (let i = 0; i < this.enemiesToSpawn; i++) {
|
for (let i = 0; i < this.enemiesPerWave; i++) {
|
||||||
const randomOffsetX: number = randomRange(-20, 20);
|
const randomOffsetX: number = randomRange(-20, 20);
|
||||||
const randomOffsetY: number = randomRange(-20, 20);
|
const randomOffsetY: number = randomRange(-20, 20);
|
||||||
const posX: number = defaultPosX + randomOffsetX + 50 * (i % side);
|
const posX: number = defaultPosX + randomOffsetX + 50 * (i % side);
|
||||||
@ -53,7 +62,7 @@ export class WaveEnemySpawner {
|
|||||||
enemies.push(enemy);
|
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