Diagonal projectile launcher

This commit is contained in:
Martin 2022-12-01 12:16:52 +01:00
parent ab4935403e
commit 772a5cc7e0
7 changed files with 381 additions and 294 deletions

View File

@ -30,7 +30,17 @@
"cooldown": 10 "cooldown": 10
} }
}, },
"xyLaunchers": { "horizontalLauncher": {
"wavesToShootPerUpgrade": 1,
"launcher": {
"projectileLifetime": 3,
"projectileSpeed": 300,
"wavesToShoot": 0,
"wavesDelayMs": 100,
"cooldown": 4
}
},
"diagonalLauncher": {
"wavesToShootPerUpgrade": 1, "wavesToShootPerUpgrade": 1,
"launcher": { "launcher": {
"projectileLifetime": 20, "projectileLifetime": 20,
@ -45,7 +55,7 @@
"maxWeaponLengthUpgrades": 5, "maxWeaponLengthUpgrades": 5,
"maxWeaponDamageUpgrades": 5, "maxWeaponDamageUpgrades": 5,
"maxHorizontalProjectileUpgrades": 0, "maxHorizontalProjectileUpgrades": 0,
"maxVerticalProjectileUpgrades": 0, "maxDiagonalProjectileUpgrades": 0,
"maxHaloProjectileUpgrades": 5, "maxHaloProjectileUpgrades": 5,
"maxRegenerationUpgrades": 5 "maxRegenerationUpgrades": 5
} }

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,8 @@ export class PlayerSettings {
public collisionDelay = 0; public collisionDelay = 0;
public weapon: WeaponSettings = new WeaponSettings(); public weapon: WeaponSettings = new WeaponSettings();
public haloLauncher: HaloLauncherSettings = new HaloLauncherSettings(); public haloLauncher: HaloLauncherSettings = new HaloLauncherSettings();
public xyLaunchers: WaveLauncherSettings = new WaveLauncherSettings(); public horizontalLauncher: WaveLauncherSettings = new WaveLauncherSettings();
public diagonalLauncher: WaveLauncherSettings = new WaveLauncherSettings();
} }
export class WeaponSettings { export class WeaponSettings {
@ -41,7 +42,7 @@ export class UpgradeSettings {
public maxWeaponLengthUpgrades = 0; public maxWeaponLengthUpgrades = 0;
public maxWeaponDamageUpgrades = 0; public maxWeaponDamageUpgrades = 0;
public maxHorizontalProjectileUpgrades = 0; public maxHorizontalProjectileUpgrades = 0;
public maxHorizontalProjectileUpgrades = 0; public maxDiagonalProjectileUpgrades = 0;
public maxHaloProjectileUpgrades = 0; public maxHaloProjectileUpgrades = 0;
public maxRegenerationUpgrades = 0; public maxRegenerationUpgrades = 0;
} }

View File

@ -14,7 +14,7 @@ import { EnemyManager } from "./Unit/Enemy/EnemyManager";
import { Player } from "./Unit/Player/Player"; import { Player } from "./Unit/Player/Player";
import { HaloProjectileLauncher } from "./Unit/Player/ProjectileLauncher/HaloProjectileLauncher"; import { HaloProjectileLauncher } from "./Unit/Player/ProjectileLauncher/HaloProjectileLauncher";
import { ProjectileLauncher } from "./Unit/Player/ProjectileLauncher/ProjectileLauncher"; import { ProjectileLauncher } from "./Unit/Player/ProjectileLauncher/ProjectileLauncher";
import { HorizontalProjectileLauncher } from "./Unit/Player/ProjectileLauncher/HorizontalProjectileLauncher"; import { WaveProjectileLauncher } from "./Unit/Player/ProjectileLauncher/WaveProjectileLauncher";
import { Upgrader } from "./Upgrades/Upgrader"; import { Upgrader } from "./Upgrades/Upgrader";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ -24,7 +24,8 @@ export class GameBootstrapper extends Component {
@property(VirtualJoystic) private virtualJoystic: VirtualJoystic; @property(VirtualJoystic) private virtualJoystic: VirtualJoystic;
@property(Player) private player: Player; @property(Player) private player: Player;
@property(ProjectileLauncher) private haloProjectileLauncherComponent: ProjectileLauncher; @property(ProjectileLauncher) private haloProjectileLauncherComponent: ProjectileLauncher;
@property(ProjectileLauncher) private verticalProjectileLauncherComponent: ProjectileLauncher; @property(ProjectileLauncher) private horizontalProjectileLauncherComponent: ProjectileLauncher;
@property(ProjectileLauncher) private diagonalProjectileLauncherComponent: ProjectileLauncher;
@property(EnemyManager) private enemyManager: EnemyManager; @property(EnemyManager) private enemyManager: EnemyManager;
@property(Camera) private camera: Camera; @property(Camera) private camera: Camera;
@property(GameUI) private gameUI: GameUI; @property(GameUI) private gameUI: GameUI;
@ -33,7 +34,8 @@ export class GameBootstrapper extends Component {
private playerCollisionSystem: PlayerCollisionSystem; private playerCollisionSystem: PlayerCollisionSystem;
private haloProjectileLauncher: HaloProjectileLauncher; private haloProjectileLauncher: HaloProjectileLauncher;
private horizontalProjectileLauncher: HorizontalProjectileLauncher; private horizontalProjectileLauncher: WaveProjectileLauncher;
private diagonalProjectileLauncher: WaveProjectileLauncher;
private gamePauser: Pauser = new Pauser(); private gamePauser: Pauser = new Pauser();
@ -59,14 +61,23 @@ export class GameBootstrapper extends Component {
); );
this.haloProjectileLauncher.upgrade(); this.haloProjectileLauncher.upgrade();
this.horizontalProjectileLauncher = new HorizontalProjectileLauncher( this.horizontalProjectileLauncher = new WaveProjectileLauncher(
this.verticalProjectileLauncherComponent, this.horizontalProjectileLauncherComponent,
this.player.node, this.player.node,
settings.player.xyLaunchers [new Vec2(-1, 0), new Vec2(1, 0)],
settings.player.horizontalLauncher
); );
this.horizontalProjectileLauncher.upgrade(); this.horizontalProjectileLauncher.upgrade();
new PlayerProjectileCollisionSystem([this.haloProjectileLauncher, this.horizontalProjectileLauncher]); this.diagonalProjectileLauncher = new WaveProjectileLauncher(
this.diagonalProjectileLauncherComponent,
this.player.node,
[new Vec2(-0.5, -0.5), new Vec2(0.5, -0.5)],
settings.player.diagonalLauncher
);
this.diagonalProjectileLauncher.upgrade();
new PlayerProjectileCollisionSystem([this.haloProjectileLauncher, this.horizontalProjectileLauncher, this.diagonalProjectileLauncher]);
const upgrader = new Upgrader(this.player, this.horizontalProjectileLauncher, this.haloProjectileLauncher, settings.upgrades); const upgrader = new Upgrader(this.player, this.horizontalProjectileLauncher, this.haloProjectileLauncher, settings.upgrades);
new GameModalLauncher(this.modalWindowManager, this.player, this.gamePauser, upgrader); new GameModalLauncher(this.modalWindowManager, this.player, this.gamePauser, upgrader);
@ -82,6 +93,7 @@ export class GameBootstrapper extends Component {
this.enemyManager.gameTick(deltaTime); this.enemyManager.gameTick(deltaTime);
this.haloProjectileLauncher.gameTick(deltaTime); this.haloProjectileLauncher.gameTick(deltaTime);
this.horizontalProjectileLauncher.gameTick(deltaTime); this.horizontalProjectileLauncher.gameTick(deltaTime);
this.diagonalProjectileLauncher.gameTick(deltaTime);
this.camera.node.worldPosition = this.player.node.worldPosition; this.camera.node.worldPosition = this.player.node.worldPosition;
} }

View File

@ -5,13 +5,13 @@ import { IProjectileCollisionSignaler } from "../../../Projectile/IProjectileCol
import { ProjectileCollision } from "../../../Projectile/ProjectileCollision"; import { ProjectileCollision } from "../../../Projectile/ProjectileCollision";
import { ProjectileLauncher } from "./ProjectileLauncher"; import { ProjectileLauncher } from "./ProjectileLauncher";
export class HorizontalProjectileLauncher implements IProjectileCollisionSignaler { export class WaveProjectileLauncher implements IProjectileCollisionSignaler {
private currentUpgrade = 0; private currentUpgrade = 0;
private wavesToShootPerUpgrade = 0; private wavesToShootPerUpgrade = 0;
public constructor(private launcher: ProjectileLauncher, playerNode: Node, settings: WaveLauncherSettings) { public constructor(private launcher: ProjectileLauncher, playerNode: Node, directions: Vec2[], settings: WaveLauncherSettings) {
this.wavesToShootPerUpgrade = settings.wavesToShootPerUpgrade; this.wavesToShootPerUpgrade = settings.wavesToShootPerUpgrade;
launcher.init(playerNode, [new Vec2(-1, 0), new Vec2(1, 0)], settings.launcher); launcher.init(playerNode, directions, settings.launcher);
} }
public get ProjectileCollisionEvent(): ISignal<ProjectileCollision> { public get ProjectileCollisionEvent(): ISignal<ProjectileCollision> {

View File

@ -2,7 +2,7 @@
"ver": "4.0.23", "ver": "4.0.23",
"importer": "typescript", "importer": "typescript",
"imported": true, "imported": true,
"uuid": "1e160c96-efda-4b1a-8e21-8c1b525bc7ef", "uuid": "1ed6eff1-da2e-4727-8f44-2e802848719c",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": {} "userData": {}

View File

@ -1,7 +1,7 @@
import { UpgradeSettings } from "../Data/GameSettings"; import { UpgradeSettings } from "../Data/GameSettings";
import { Player } from "../Unit/Player/Player"; import { Player } from "../Unit/Player/Player";
import { HaloProjectileLauncher } from "../Unit/Player/ProjectileLauncher/HaloProjectileLauncher"; import { HaloProjectileLauncher } from "../Unit/Player/ProjectileLauncher/HaloProjectileLauncher";
import { HorizontalProjectileLauncher } from "../Unit/Player/ProjectileLauncher/HorizontalProjectileLauncher"; import { WaveProjectileLauncher } from "../Unit/Player/ProjectileLauncher/WaveProjectileLauncher";
import { UpgradeType } from "./UpgradeType"; import { UpgradeType } from "./UpgradeType";
export class Upgrader { export class Upgrader {
@ -11,7 +11,7 @@ export class Upgrader {
public constructor( public constructor(
private player: Player, private player: Player,
private horizontalProjectileLauncher: HorizontalProjectileLauncher, private horizontalProjectileLauncher: WaveProjectileLauncher,
private haloProjectileLauncher: HaloProjectileLauncher, private haloProjectileLauncher: HaloProjectileLauncher,
settings: UpgradeSettings settings: UpgradeSettings
) { ) {