mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 08:36:14 +00:00
Upgrader, LevelUpSkill
This commit is contained in:
@@ -26,6 +26,8 @@ export class GameBootstrapper extends Component {
|
||||
|
||||
private playerCollisionSystem: PlayerCollisionSystem;
|
||||
|
||||
private isPaused = false;
|
||||
|
||||
public start(): void {
|
||||
this.virtualJoystic.init();
|
||||
this.weapon.init(this.strikeDelay);
|
||||
@@ -45,6 +47,8 @@ export class GameBootstrapper extends Component {
|
||||
}
|
||||
|
||||
public update(deltaTime: number): void {
|
||||
if (this.isPaused) return;
|
||||
|
||||
this.player.gameTick(deltaTime);
|
||||
this.playerCollisionSystem.gameTick(deltaTime);
|
||||
this.enemyManager.gameTick(deltaTime);
|
||||
@@ -53,7 +57,9 @@ export class GameBootstrapper extends Component {
|
||||
}
|
||||
|
||||
private async showModal(): Promise<void> {
|
||||
this.isPaused = true;
|
||||
const result: string = await this.modalWindowManager.showModal<string, string>("LevelUpModalWindow", "test params");
|
||||
this.isPaused = false;
|
||||
console.log("Result: " + result);
|
||||
}
|
||||
}
|
||||
|
@@ -17,8 +17,6 @@ export class Player extends Component {
|
||||
private health: UnitHealth;
|
||||
private level: UnitLevel;
|
||||
|
||||
private xp: number;
|
||||
|
||||
public init(input: IInput, weapon: Weapon, maxHp: number, requiredLevelXps: number[]): void {
|
||||
this.input = input;
|
||||
this.weapon = weapon;
|
||||
@@ -39,6 +37,10 @@ export class Player extends Component {
|
||||
return this.level;
|
||||
}
|
||||
|
||||
public get Weapon(): Weapon {
|
||||
return this.weapon;
|
||||
}
|
||||
|
||||
public get Collider(): Collider2D {
|
||||
return this.collider;
|
||||
}
|
||||
|
12
assets/Scripts/Game/UI/LevelUpWindow.meta
Normal file
12
assets/Scripts/Game/UI/LevelUpWindow.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "b10425c2-13b2-4c46-a497-13a269a204de",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
29
assets/Scripts/Game/UI/LevelUpWindow/LevelUpModalWindow.ts
Normal file
29
assets/Scripts/Game/UI/LevelUpWindow/LevelUpModalWindow.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { CCString, instantiate, Node, Prefab, Vec3, _decorator } from "cc";
|
||||
import { ModalWindow } from "../../../Services/ModalWindowSystem/ModalWindow";
|
||||
import { delay } from "../../../Services/Utils/AsyncUtils";
|
||||
import { LevelUpSkill } from "./LevelUpSkill";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("LevelUpModalWindow")
|
||||
export class LevelUpModalWindow extends ModalWindow<string, string> {
|
||||
@property(Prefab) private skillPrefab: Prefab;
|
||||
@property(Node) private skillParent: Node;
|
||||
|
||||
protected async setup(params: string): Promise<void> {
|
||||
const xPositions: number[] = [-180, 0, 180];
|
||||
await delay(300);
|
||||
for (let i = 0; i < 3; i++) {
|
||||
await delay(500);
|
||||
const skill: LevelUpSkill = instantiate(this.skillPrefab).getComponent(LevelUpSkill);
|
||||
skill.node.setParent(this.skillParent);
|
||||
skill.node.setPosition(new Vec3(xPositions[i]));
|
||||
skill.init(params);
|
||||
skill.ChooseSkillEvent.on(this.chooseSkill, this);
|
||||
}
|
||||
}
|
||||
|
||||
private chooseSkill(skill: LevelUpSkill): void {
|
||||
this.dismiss("FInishedSuccessfuly");
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "f7ac6f2a-2bea-42ec-b5d0-58976001856c",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
22
assets/Scripts/Game/UI/LevelUpWindow/LevelUpSkill.ts
Normal file
22
assets/Scripts/Game/UI/LevelUpWindow/LevelUpSkill.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Component, Label, NodeEventType, _decorator } from "cc";
|
||||
import { ISignal } from "../../../Services/EventSystem/ISignal";
|
||||
import { Signal } from "../../../Services/EventSystem/Signal";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("LevelUpSkill")
|
||||
export class LevelUpSkill extends Component {
|
||||
@property(Label) private skillTitle: Label;
|
||||
private chooseSkillEvent: Signal<LevelUpSkill> = new Signal<LevelUpSkill>();
|
||||
public init(skillTitle: string): void {
|
||||
this.skillTitle.string = skillTitle;
|
||||
this.node.on(NodeEventType.MOUSE_DOWN, this.chooseSkill, this);
|
||||
}
|
||||
|
||||
public get ChooseSkillEvent(): ISignal<LevelUpSkill> {
|
||||
return this.chooseSkillEvent;
|
||||
}
|
||||
|
||||
private chooseSkill(): void {
|
||||
this.chooseSkillEvent.trigger(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "65e26889-bc4f-487d-8625-602fbced8eb1",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
12
assets/Scripts/Game/Upgrades.meta
Normal file
12
assets/Scripts/Game/Upgrades.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "c281ddc9-4aa5-4d69-af47-cf25a4ff4c11",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
9
assets/Scripts/Game/Upgrades/UpgradeType.ts
Normal file
9
assets/Scripts/Game/Upgrades/UpgradeType.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export enum UpgradeType {
|
||||
MaxHP,
|
||||
WeaponLength,
|
||||
WeaponDamage,
|
||||
HorizontalProjectile,
|
||||
VerticalProjectile,
|
||||
OverallDamage,
|
||||
Regeneration
|
||||
}
|
9
assets/Scripts/Game/Upgrades/UpgradeType.ts.meta
Normal file
9
assets/Scripts/Game/Upgrades/UpgradeType.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a481c31c-b6ba-4871-b8d7-f151788a450a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
39
assets/Scripts/Game/Upgrades/Upgrader.ts
Normal file
39
assets/Scripts/Game/Upgrades/Upgrader.ts
Normal 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();
|
||||
}
|
||||
}
|
9
assets/Scripts/Game/Upgrades/Upgrader.ts.meta
Normal file
9
assets/Scripts/Game/Upgrades/Upgrader.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "51a09dd7-ec63-40dd-a0ce-1a16632f16fa",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -34,6 +34,9 @@ export class Weapon extends Component {
|
||||
return 5;
|
||||
}
|
||||
|
||||
public upgradeWeaponDamage(): void {}
|
||||
public upgradeWeaponLength(): void {}
|
||||
|
||||
private strike(): void {
|
||||
this.node.active = true;
|
||||
this.weaponAnimation.play(this.strikeState.name);
|
||||
|
Reference in New Issue
Block a user