mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-26 03:38:58 +00:00
Vertical launcher
This commit is contained in:
parent
ac9b67503d
commit
ab39355a5c
@ -21,13 +21,24 @@
|
||||
},
|
||||
"haloLauncher": {
|
||||
"projectilesToSpawn": 24,
|
||||
"cooldownDivisorPerUpgrade": 1,
|
||||
"launcher": {
|
||||
"projectileLifetime": 5,
|
||||
"projectileLifetime": 2,
|
||||
"projectileSpeed": 150,
|
||||
"wavesToShoot": 1,
|
||||
"wavesDelayMs": 0,
|
||||
"cooldown": 10
|
||||
}
|
||||
},
|
||||
"xyLaunchers": {
|
||||
"wavesToShootPerUpgrade": 1,
|
||||
"launcher": {
|
||||
"projectileLifetime": 20,
|
||||
"projectileSpeed": 300,
|
||||
"wavesToShoot": 0,
|
||||
"wavesDelayMs": 100,
|
||||
"cooldown": 4
|
||||
}
|
||||
}
|
||||
},
|
||||
"upgrades": {
|
||||
|
@ -141,7 +141,7 @@
|
||||
"_id": "61KOckV1dET5kaFFrJFLGb"
|
||||
},
|
||||
{
|
||||
"__type__": "422b4bsPhVDfZf8f0Sid8O+",
|
||||
"__type__": "e3d066A8exFBaWWn2gx4c4j",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
@ -153,7 +153,7 @@
|
||||
"__uuid__": "ff0be112-7028-424c-87b8-fc54a106015a",
|
||||
"__expectedType__": "cc.Prefab"
|
||||
},
|
||||
"_id": "02VMV6hX5L5pm3W9sOTjZt"
|
||||
"_id": "59iUbnanhI5rTJrAOksLEe"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
@ -3656,10 +3656,10 @@
|
||||
"player": {
|
||||
"__id__": 55
|
||||
},
|
||||
"haloProjectiles": {
|
||||
"haloProjectileLauncherComponent": {
|
||||
"__id__": 4
|
||||
},
|
||||
"verticalProjectileLauncher": {
|
||||
"verticalProjectileLauncherComponent": {
|
||||
"__id__": 6
|
||||
},
|
||||
"enemyManager": {
|
||||
|
@ -1,10 +1,12 @@
|
||||
import { IProjectileCollisionSignaler } from "../Projectile/IProjectileCollisionSignaler";
|
||||
import { ProjectileCollision } from "../Projectile/ProjectileCollision";
|
||||
import { Enemy } from "../Unit/Enemy/Enemy";
|
||||
import { HaloProjectileLauncher } from "../Unit/Player/ProjectileLauncher/Halo/HaloProjectileLauncher";
|
||||
|
||||
export class PlayerProjectileCollisionSystem {
|
||||
public constructor(haloLauncher: HaloProjectileLauncher) {
|
||||
haloLauncher.ProjectileCollisionEvent.on(this.onProjectileCollision, this);
|
||||
public constructor(collisionSignalers: IProjectileCollisionSignaler[]) {
|
||||
for (const collisionSignaler of collisionSignalers) {
|
||||
collisionSignaler.ProjectileCollisionEvent.on(this.onProjectileCollision, this);
|
||||
}
|
||||
}
|
||||
|
||||
private onProjectileCollision(projectileCollision: ProjectileCollision): void {
|
||||
|
@ -10,6 +10,7 @@ export class PlayerSettings {
|
||||
public collisionDelay = 0;
|
||||
public weapon: WeaponSettings = new WeaponSettings();
|
||||
public haloLauncher: HaloLauncherSettings = new HaloLauncherSettings();
|
||||
public xyLaunchers: WaveLauncherSettings = new WaveLauncherSettings();
|
||||
}
|
||||
|
||||
export class WeaponSettings {
|
||||
@ -17,8 +18,14 @@ export class WeaponSettings {
|
||||
public damage = 0;
|
||||
}
|
||||
|
||||
export class WaveLauncherSettings {
|
||||
public wavesToShootPerUpgrade = 0;
|
||||
public launcher = new ProjectileLauncherSettings();
|
||||
}
|
||||
|
||||
export class HaloLauncherSettings {
|
||||
public projectilesToSpawn = 0;
|
||||
public cooldownDivisorPerUpgrade = 0;
|
||||
public launcher = new ProjectileLauncherSettings();
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,9 @@ import { Pauser } from "./Pauser";
|
||||
import { GameUI } from "./UI/GameUI";
|
||||
import { EnemyManager } from "./Unit/Enemy/EnemyManager";
|
||||
import { Player } from "./Unit/Player/Player";
|
||||
import { HaloProjectileLauncher } from "./Unit/Player/ProjectileLauncher/Halo/HaloProjectileLauncher";
|
||||
import { HaloProjectileLauncher } from "./Unit/Player/ProjectileLauncher/HaloProjectileLauncher";
|
||||
import { ProjectileLauncher } from "./Unit/Player/ProjectileLauncher/ProjectileLauncher";
|
||||
import { VerticalProjectileLauncher } from "./Unit/Player/ProjectileLauncher/VerticalProjectileLauncher";
|
||||
import { Upgrader } from "./Upgrades/Upgrader";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@ -22,8 +23,8 @@ const { ccclass, property } = _decorator;
|
||||
export class GameBootstrapper extends Component {
|
||||
@property(VirtualJoystic) private virtualJoystic: VirtualJoystic;
|
||||
@property(Player) private player: Player;
|
||||
@property(HaloProjectileLauncher) private haloProjectiles: HaloProjectileLauncher;
|
||||
@property(ProjectileLauncher) private verticalProjectileLauncher: ProjectileLauncher;
|
||||
@property(ProjectileLauncher) private haloProjectileLauncherComponent: ProjectileLauncher;
|
||||
@property(ProjectileLauncher) private verticalProjectileLauncherComponent: ProjectileLauncher;
|
||||
@property(EnemyManager) private enemyManager: EnemyManager;
|
||||
@property(Camera) private camera: Camera;
|
||||
@property(GameUI) private gameUI: GameUI;
|
||||
@ -31,6 +32,8 @@ export class GameBootstrapper extends Component {
|
||||
@property(JsonAsset) private settingsAsset: JsonAsset;
|
||||
|
||||
private playerCollisionSystem: PlayerCollisionSystem;
|
||||
private haloProjectileLauncher: HaloProjectileLauncher;
|
||||
private verticalProjectileLauncher: VerticalProjectileLauncher;
|
||||
|
||||
private gamePauser: Pauser = new Pauser();
|
||||
|
||||
@ -52,13 +55,21 @@ export class GameBootstrapper extends Component {
|
||||
|
||||
this.enemyManager.init(this.player.node);
|
||||
|
||||
this.haloProjectiles.init(this.player.node, settings.player.haloLauncher);
|
||||
this.haloProjectiles.upgrade();
|
||||
this.haloProjectileLauncher = new HaloProjectileLauncher(
|
||||
this.haloProjectileLauncherComponent,
|
||||
this.player.node,
|
||||
settings.player.haloLauncher
|
||||
);
|
||||
this.haloProjectileLauncher.upgrade();
|
||||
|
||||
this.verticalProjectileLauncher.init(this.player.node, [new Vec2(-1, 0)]);
|
||||
this.verticalProjectileLauncher = new VerticalProjectileLauncher(
|
||||
this.verticalProjectileLauncherComponent,
|
||||
this.player.node,
|
||||
settings.player.xyLaunchers
|
||||
);
|
||||
this.verticalProjectileLauncher.upgrade();
|
||||
|
||||
new PlayerProjectileCollisionSystem(this.haloProjectiles);
|
||||
new PlayerProjectileCollisionSystem([this.haloProjectileLauncher, this.verticalProjectileLauncher]);
|
||||
|
||||
this.gameUI.init(this.player);
|
||||
}
|
||||
@ -69,7 +80,7 @@ export class GameBootstrapper extends Component {
|
||||
this.player.gameTick(deltaTime);
|
||||
this.playerCollisionSystem.gameTick(deltaTime);
|
||||
this.enemyManager.gameTick(deltaTime);
|
||||
this.haloProjectiles.gameTick(deltaTime);
|
||||
this.haloProjectileLauncher.gameTick(deltaTime);
|
||||
this.verticalProjectileLauncher.gameTick(deltaTime);
|
||||
|
||||
this.camera.node.worldPosition = this.player.node.worldPosition;
|
||||
|
@ -0,0 +1,6 @@
|
||||
import { ISignal } from "../../Services/EventSystem/ISignal";
|
||||
import { ProjectileCollision } from "./ProjectileCollision";
|
||||
|
||||
export interface IProjectileCollisionSignaler {
|
||||
get ProjectileCollisionEvent(): ISignal<ProjectileCollision>;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "1932c90e-393a-44d7-9f23-c52221a89286",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "b89dc5a7-3450-47e4-bc36-ae5d08f4bc89",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
import { Component, Node, Prefab, Vec2, Vec3, _decorator } from "cc";
|
||||
import { ISignal } from "../../../../../Services/EventSystem/ISignal";
|
||||
import { Signal } from "../../../../../Services/EventSystem/Signal";
|
||||
import { GameTimer } from "../../../../../Services/GameTimer";
|
||||
import { ObjectPool } from "../../../../../Services/ObjectPool";
|
||||
import { roundToOneDecimal } from "../../../../../Services/Utils/MathUtils";
|
||||
import { HaloLauncherSettings } from "../../../../Data/GameSettings";
|
||||
import { Projectile } from "../../../../Projectile/Projectile";
|
||||
import { ProjectileCollision } from "../../../../Projectile/ProjectileCollision";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("HaloProjectileLauncher")
|
||||
export class HaloProjectileLauncher extends Component {
|
||||
@property(Prefab) private projectilePrefab: Prefab;
|
||||
private fireTimer: GameTimer;
|
||||
private lifetimeTimer: GameTimer;
|
||||
private projectilesToSpawn: number;
|
||||
private defaultCooldown: number;
|
||||
private speed: number;
|
||||
private currentLevel = 0;
|
||||
|
||||
private isFiring = false;
|
||||
|
||||
private projectilePool: ObjectPool<Projectile>;
|
||||
private projectiles: Projectile[] = [];
|
||||
private directions: Vec2[] = [];
|
||||
|
||||
private playerNode: Node;
|
||||
|
||||
private projectileCollisionEvent: Signal<ProjectileCollision> = new Signal<ProjectileCollision>();
|
||||
|
||||
public init(playerNode: Node, settings: HaloLauncherSettings): void {
|
||||
this.playerNode = playerNode;
|
||||
this.projectilesToSpawn = settings.projectilesToSpawn;
|
||||
this.projectilePool = new ObjectPool<Projectile>(this.projectilePrefab, this.node, this.projectilesToSpawn, "Projectile");
|
||||
|
||||
this.speed = settings.launcher.projectileSpeed;
|
||||
this.defaultCooldown = settings.launcher.cooldown;
|
||||
this.lifetimeTimer = new GameTimer(settings.launcher.projectileLifetime);
|
||||
this.fireTimer = new GameTimer(this.defaultCooldown);
|
||||
|
||||
const angle: number = (2 * Math.PI) / this.projectilesToSpawn;
|
||||
|
||||
for (let i = 0; i < this.projectilesToSpawn; i++) {
|
||||
const x: number = roundToOneDecimal(Math.sin(angle * i));
|
||||
const y: number = roundToOneDecimal(Math.cos(angle * i));
|
||||
this.directions.push(new Vec2(x, y).normalize());
|
||||
}
|
||||
}
|
||||
|
||||
public get ProjectileCollisionEvent(): ISignal<ProjectileCollision> {
|
||||
return this.projectileCollisionEvent;
|
||||
}
|
||||
|
||||
public upgrade(): void {
|
||||
this.currentLevel++;
|
||||
this.fireTimer = new GameTimer(this.defaultCooldown - this.currentLevel);
|
||||
}
|
||||
|
||||
public gameTick(deltaTime: number): void {
|
||||
if (this.currentLevel == 0) return;
|
||||
|
||||
this.fireTimer.gameTick(deltaTime);
|
||||
if (this.isFiring) {
|
||||
this.moveAllProjectiles(deltaTime);
|
||||
this.tryRemoveAllProjectiles(deltaTime);
|
||||
} else {
|
||||
if (this.fireTimer.tryFinishPeriod()) {
|
||||
this.fireProjectiles();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fireProjectiles(): void {
|
||||
for (let index = 0; index < this.projectilesToSpawn; index++) {
|
||||
const projectile: Projectile = this.projectilePool.borrow();
|
||||
projectile.tryInit();
|
||||
projectile.node.setWorldPosition(this.playerNode.worldPosition);
|
||||
projectile.node.active = true;
|
||||
projectile.ContactBeginEvent.on(this.onProjectileCollision, this);
|
||||
this.projectiles.push(projectile);
|
||||
}
|
||||
|
||||
this.isFiring = true;
|
||||
}
|
||||
|
||||
private moveAllProjectiles(deltaTime: number): void {
|
||||
for (let i = 0; i < this.projectiles.length; i++) {
|
||||
const newPosition: Vec3 = this.projectiles[i].node.worldPosition;
|
||||
newPosition.x += this.directions[i].x * deltaTime * this.speed;
|
||||
newPosition.y += this.directions[i].y * deltaTime * this.speed;
|
||||
|
||||
this.projectiles[i].node.setWorldPosition(newPosition);
|
||||
}
|
||||
}
|
||||
|
||||
private tryRemoveAllProjectiles(deltaTime: number): void {
|
||||
this.lifetimeTimer.gameTick(deltaTime);
|
||||
if (this.lifetimeTimer.tryFinishPeriod()) {
|
||||
for (const projectile of this.projectiles) {
|
||||
projectile.ContactBeginEvent.off(this.onProjectileCollision);
|
||||
this.projectilePool.return(projectile);
|
||||
}
|
||||
|
||||
this.projectiles = [];
|
||||
this.isFiring = false;
|
||||
}
|
||||
}
|
||||
|
||||
private onProjectileCollision(projectileCollision: ProjectileCollision): void {
|
||||
this.projectileCollisionEvent.trigger(projectileCollision);
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
import { Vec2, Node } from "cc";
|
||||
import { ISignal } from "../../../../Services/EventSystem/ISignal";
|
||||
import { roundToOneDecimal } from "../../../../Services/Utils/MathUtils";
|
||||
import { HaloLauncherSettings } from "../../../Data/GameSettings";
|
||||
import { ProjectileCollision } from "../../../Projectile/ProjectileCollision";
|
||||
import { IProjectileCollisionSignaler } from "../../../Projectile/IProjectileCollisionSignaler";
|
||||
import { ProjectileLauncher } from "./ProjectileLauncher";
|
||||
|
||||
export class HaloProjectileLauncher implements IProjectileCollisionSignaler {
|
||||
private currentUpgrade = 0;
|
||||
private defaultCooldown = 0;
|
||||
private cooldownDivisorPerUpgrade = 0;
|
||||
|
||||
public constructor(private launcher: ProjectileLauncher, playerNode: Node, settings: HaloLauncherSettings) {
|
||||
this.defaultCooldown = settings.launcher.cooldown;
|
||||
this.cooldownDivisorPerUpgrade = settings.cooldownDivisorPerUpgrade;
|
||||
|
||||
const directions: Vec2[] = [];
|
||||
const angle: number = (2 * Math.PI) / settings.projectilesToSpawn;
|
||||
|
||||
for (let i = 0; i < settings.projectilesToSpawn; i++) {
|
||||
const x: number = roundToOneDecimal(Math.sin(angle * i));
|
||||
const y: number = roundToOneDecimal(Math.cos(angle * i));
|
||||
directions.push(new Vec2(x, y).normalize());
|
||||
}
|
||||
|
||||
launcher.init(playerNode, directions, settings.launcher);
|
||||
}
|
||||
|
||||
public get ProjectileCollisionEvent(): ISignal<ProjectileCollision> {
|
||||
return this.launcher.ProjectileCollisionEvent;
|
||||
}
|
||||
|
||||
public gameTick(deltaTime: number): void {
|
||||
if (this.currentUpgrade == 0) return;
|
||||
|
||||
this.launcher.gameTick(deltaTime);
|
||||
}
|
||||
|
||||
public upgrade(): void {
|
||||
this.currentUpgrade++;
|
||||
this.launcher.Cooldown = (this.defaultCooldown / this.cooldownDivisorPerUpgrade) * this.currentUpgrade;
|
||||
}
|
||||
}
|
@ -1,17 +1,27 @@
|
||||
import { _decorator, Component, Node, Prefab, Vec2, Vec3 } from "cc";
|
||||
import { ISignal } from "../../../../Services/EventSystem/ISignal";
|
||||
import { Signal } from "../../../../Services/EventSystem/Signal";
|
||||
import { GameTimer } from "../../../../Services/GameTimer";
|
||||
import { ObjectPool } from "../../../../Services/ObjectPool";
|
||||
import { delay } from "../../../../Services/Utils/AsyncUtils";
|
||||
import { ProjectileLauncherSettings } from "../../../Data/GameSettings";
|
||||
import { IProjectileCollisionSignaler } from "../../../Projectile/IProjectileCollisionSignaler";
|
||||
import { Projectile } from "../../../Projectile/Projectile";
|
||||
import { ProjectileCollision } from "../../../Projectile/ProjectileCollision";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("ProjectileLauncher")
|
||||
export class ProjectileLauncher extends Component {
|
||||
export class ProjectileLauncher extends Component implements IProjectileCollisionSignaler {
|
||||
@property(Prefab) private projectilePrefab: Prefab;
|
||||
private projectileCollisionEvent: Signal<ProjectileCollision> = new Signal<ProjectileCollision>();
|
||||
|
||||
private projectilePool: ObjectPool<Projectile>;
|
||||
private fireTimer: GameTimer;
|
||||
private projectileLifetime = 5;
|
||||
private speed = 300;
|
||||
private projectileLifetime: number;
|
||||
private speed: number;
|
||||
private wavesToShoot: number;
|
||||
private wavesDelayMs: number;
|
||||
private cooldown: number;
|
||||
|
||||
private fireDirections: Vec2[];
|
||||
|
||||
@ -20,20 +30,43 @@ export class ProjectileLauncher extends Component {
|
||||
private expireTimes: number[] = [];
|
||||
private currentTime = 0;
|
||||
|
||||
private currentUpgrade = 0;
|
||||
|
||||
private playerNode: Node;
|
||||
|
||||
public init(playerNode: Node, fireDirections: Vec2[]): void {
|
||||
public get WavesToShoot(): number {
|
||||
return this.wavesToShoot;
|
||||
}
|
||||
|
||||
public set WavesToShoot(value: number) {
|
||||
this.wavesToShoot = value;
|
||||
}
|
||||
|
||||
public get Cooldown(): number {
|
||||
return this.cooldown;
|
||||
}
|
||||
|
||||
public set Cooldown(value: number) {
|
||||
this.cooldown = value;
|
||||
this.fireTimer = new GameTimer(this.cooldown);
|
||||
}
|
||||
|
||||
public get ProjectileCollisionEvent(): ISignal<ProjectileCollision> {
|
||||
return this.projectileCollisionEvent;
|
||||
}
|
||||
|
||||
public init(playerNode: Node, fireDirections: Vec2[], settings: ProjectileLauncherSettings): void {
|
||||
this.projectileLifetime = settings.projectileLifetime;
|
||||
this.speed = settings.projectileSpeed;
|
||||
this.wavesToShoot = settings.wavesToShoot;
|
||||
this.wavesDelayMs = settings.wavesDelayMs;
|
||||
this.cooldown = settings.cooldown;
|
||||
|
||||
this.playerNode = playerNode;
|
||||
this.fireDirections = fireDirections;
|
||||
this.projectilePool = new ObjectPool<Projectile>(this.projectilePrefab, this.node, 6, "Projectile");
|
||||
this.fireTimer = new GameTimer(2);
|
||||
this.fireTimer = new GameTimer(this.cooldown);
|
||||
}
|
||||
|
||||
public gameTick(deltaTime: number): void {
|
||||
if (this.currentUpgrade == 0) return;
|
||||
|
||||
this.currentTime += deltaTime;
|
||||
this.fireTimer.gameTick(deltaTime);
|
||||
if (this.fireTimer.tryFinishPeriod()) {
|
||||
@ -44,16 +77,13 @@ export class ProjectileLauncher extends Component {
|
||||
this.moveAllProjectiles(deltaTime);
|
||||
}
|
||||
|
||||
public upgrade(): void {
|
||||
this.currentUpgrade++;
|
||||
}
|
||||
|
||||
private async fireProjectiles(): Promise<void> {
|
||||
for (let i = 0; i < this.currentUpgrade; i++) {
|
||||
await delay(100);
|
||||
for (let i = 0; i < this.wavesToShoot; i++) {
|
||||
for (const direction of this.fireDirections) {
|
||||
this.fireProjectile(direction);
|
||||
}
|
||||
|
||||
await delay(this.wavesDelayMs);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,6 +92,7 @@ export class ProjectileLauncher extends Component {
|
||||
projectile.tryInit();
|
||||
projectile.node.setWorldPosition(this.playerNode.worldPosition);
|
||||
projectile.node.active = true;
|
||||
projectile.ContactBeginEvent.on(this.onProjectileCollision, this);
|
||||
|
||||
this.projectiles.push(projectile);
|
||||
this.directions.push(direction);
|
||||
@ -72,7 +103,10 @@ export class ProjectileLauncher extends Component {
|
||||
for (let i = 0; i < this.projectiles.length; i++) {
|
||||
if (this.currentTime < this.expireTimes[i]) break; // the oldest particles are at the start of the array
|
||||
|
||||
this.projectilePool.return(this.projectiles[i]);
|
||||
const projectile: Projectile = this.projectiles[i];
|
||||
projectile.ContactBeginEvent.off(this.onProjectileCollision);
|
||||
this.projectilePool.return(projectile);
|
||||
|
||||
this.projectiles.splice(i, 1);
|
||||
this.directions.splice(i, 1);
|
||||
this.expireTimes.splice(i, 1);
|
||||
@ -89,4 +123,8 @@ export class ProjectileLauncher extends Component {
|
||||
this.projectiles[i].node.setWorldPosition(newPosition);
|
||||
}
|
||||
}
|
||||
|
||||
private onProjectileCollision(projectlieCollision: ProjectileCollision): void {
|
||||
this.projectileCollisionEvent.trigger(projectlieCollision);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
import { Node, Vec2 } from "cc";
|
||||
import { ISignal } from "../../../../Services/EventSystem/ISignal";
|
||||
import { WaveLauncherSettings } from "../../../Data/GameSettings";
|
||||
import { IProjectileCollisionSignaler } from "../../../Projectile/IProjectileCollisionSignaler";
|
||||
import { ProjectileCollision } from "../../../Projectile/ProjectileCollision";
|
||||
import { ProjectileLauncher } from "./ProjectileLauncher";
|
||||
|
||||
export class VerticalProjectileLauncher implements IProjectileCollisionSignaler {
|
||||
private currentUpgrade = 0;
|
||||
private wavesToShootPerUpgrade = 0;
|
||||
|
||||
public constructor(private launcher: ProjectileLauncher, playerNode: Node, settings: WaveLauncherSettings) {
|
||||
this.wavesToShootPerUpgrade = settings.wavesToShootPerUpgrade;
|
||||
launcher.init(playerNode, [new Vec2(-1, 0), new Vec2(1, 0)], settings.launcher);
|
||||
}
|
||||
|
||||
public get ProjectileCollisionEvent(): ISignal<ProjectileCollision> {
|
||||
return this.launcher.ProjectileCollisionEvent;
|
||||
}
|
||||
|
||||
public gameTick(deltaTime: number): void {
|
||||
if (this.currentUpgrade == 0) return;
|
||||
|
||||
this.launcher.gameTick(deltaTime);
|
||||
}
|
||||
|
||||
public upgrade(): void {
|
||||
this.currentUpgrade++;
|
||||
this.launcher.WavesToShoot += this.wavesToShootPerUpgrade;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "1e160c96-efda-4b1a-8e21-8c1b525bc7ef",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@ -3,10 +3,12 @@ export enum UpgradeType {
|
||||
WeaponDamage,
|
||||
HorizontalProjectile,
|
||||
VerticalProjectile,
|
||||
HaloProjectlie,
|
||||
Regeneration
|
||||
}
|
||||
|
||||
export enum MetaUpgradeType {
|
||||
MaxHp,
|
||||
OverallDamage
|
||||
OverallDamage,
|
||||
ProjectilePiercing
|
||||
}
|
||||
|
@ -1,18 +1,24 @@
|
||||
import { UpgradeSettings } from "../Data/GameSettings";
|
||||
import { Player } from "../Unit/Player/Player";
|
||||
import { HaloProjectileLauncher } from "../Unit/Player/ProjectileLauncher/HaloProjectileLauncher";
|
||||
import { VerticalProjectileLauncher } from "../Unit/Player/ProjectileLauncher/VerticalProjectileLauncher";
|
||||
import { UpgradeType } from "./UpgradeType";
|
||||
|
||||
export class Upgrader {
|
||||
private player: Player;
|
||||
private typeToAction: Map<UpgradeType, () => void> = new Map<UpgradeType, () => void>();
|
||||
private typeToLevel: Map<UpgradeType, number> = new Map<UpgradeType, number>();
|
||||
private typeToMaxLevel: Map<UpgradeType, number> = new Map<UpgradeType, number>();
|
||||
|
||||
public constructor(player: Player, settings: UpgradeSettings) {
|
||||
this.player = player;
|
||||
|
||||
public constructor(
|
||||
private player: Player,
|
||||
private verticalProjectileLauncher: VerticalProjectileLauncher,
|
||||
private haloProjectileLauncher: HaloProjectileLauncher,
|
||||
settings: UpgradeSettings
|
||||
) {
|
||||
this.setTypeMaps(UpgradeType.WeaponLength, this.upgradeWeaponLength.bind(this), settings.maxWeaponLengthUpgrades);
|
||||
this.setTypeMaps(UpgradeType.WeaponDamage, this.upgradeWeaponDamage.bind(this), settings.maxWeaponDamageUpgrades);
|
||||
this.setTypeMaps(UpgradeType.VerticalProjectile, this.upgradeVerticalProjectileLauncher.bind(this), settings.maxVerticalProjectileUpgrades);
|
||||
this.setTypeMaps(UpgradeType.HaloProjectlie, this.upgradeHaloProjectileLauncher.bind(this), settings.maxHaloProjectileUpgrades);
|
||||
this.setTypeMaps(UpgradeType.Regeneration, this.upgradeRegeneration.bind(this), settings.maxRegenerationUpgrades);
|
||||
}
|
||||
|
||||
@ -50,6 +56,14 @@ export class Upgrader {
|
||||
this.player.Weapon.upgradeWeaponDamage();
|
||||
}
|
||||
|
||||
private upgradeVerticalProjectileLauncher(): void {
|
||||
this.verticalProjectileLauncher.upgrade();
|
||||
}
|
||||
|
||||
private upgradeHaloProjectileLauncher(): void {
|
||||
this.haloProjectileLauncher.upgrade();
|
||||
}
|
||||
|
||||
private upgradeRegeneration(): void {
|
||||
this.player.Regeneration.upgrade();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user