Slash-The-Hordes/assets/Scripts/Game/UI/LevelUpWindow/LevelUpModalWindow.ts

31 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-11-24 12:17:05 +00:00
import { instantiate, Node, Prefab, Vec3, _decorator } from "cc";
2022-11-23 08:01:01 +00:00
import { ModalWindow } from "../../../Services/ModalWindowSystem/ModalWindow";
import { delay } from "../../../Services/Utils/AsyncUtils";
2022-11-24 12:17:05 +00:00
import { UpgradeType } from "../../Upgrades/UpgradeType";
2022-11-23 08:01:01 +00:00
import { LevelUpSkill } from "./LevelUpSkill";
const { ccclass, property } = _decorator;
@ccclass("LevelUpModalWindow")
2022-11-24 12:17:05 +00:00
export class LevelUpModalWindow extends ModalWindow<string, UpgradeType> {
2022-11-23 08:01:01 +00:00
@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 {
2022-11-24 12:17:05 +00:00
this.dismiss(UpgradeType.WeaponDamage);
2022-11-23 08:01:01 +00:00
}
}