Upgrader, LevelUpSkill

This commit is contained in:
Martin
2022-11-23 09:01:01 +01:00
parent 94605e673e
commit b1f8f66499
38 changed files with 5158 additions and 692 deletions

View File

@@ -0,0 +1,9 @@
export enum UpgradeType {
MaxHP,
WeaponLength,
WeaponDamage,
HorizontalProjectile,
VerticalProjectile,
OverallDamage,
Regeneration
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "a481c31c-b6ba-4871-b8d7-f151788a450a",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,39 @@
import { Player } from "../Player/Player";
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>();
public constructor(player: Player) {
this.player = player;
this.typeToAction.set(UpgradeType.MaxHP, this.upgradeMaxHp);
this.typeToAction.set(UpgradeType.WeaponLength, this.upgradeWeaponLength);
this.typeToAction.set(UpgradeType.WeaponDamage, this.upgradeWeaponDamage);
this.typeToLevel.set(UpgradeType.MaxHP, 0);
this.typeToLevel.set(UpgradeType.WeaponLength, 0);
}
public upgradeSkill(type: UpgradeType): void {
if (!this.typeToAction.has(type)) throw new Error("Upgrade does not have " + type);
this.typeToAction.get(type)();
}
private upgradeMaxHp(): void {
const healthIncrease = 5;
const currentMax: number = this.player.Health.MaxHealthPoints;
this.player.Health.setMaxHealth(currentMax + healthIncrease);
this.player.Health.heal(healthIncrease);
}
private upgradeWeaponLength(): void {
this.player.Weapon.upgradeWeaponLength();
}
private upgradeWeaponDamage(): void {
this.player.Weapon.upgradeWeaponDamage();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "51a09dd7-ec63-40dd-a0ce-1a16632f16fa",
"files": [],
"subMetas": {},
"userData": {}
}