mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-26 11:48:54 +00:00
22 lines
1.0 KiB
TypeScript
22 lines
1.0 KiB
TypeScript
import { randomRangeInt, _decorator } from "cc";
|
|
import { ModalWindow } from "../../Services/ModalWindowSystem/ModalWindow";
|
|
import { UIButton } from "../../Services/UI/Button/UIButton";
|
|
import { LevelUpModalWindowParams } from "../UI/LevelUpWindow/LevelUpModalWindow";
|
|
import { LevelUpSkill } from "../UI/LevelUpWindow/LevelUpSkill";
|
|
import { UpgradeType } from "../Upgrades/UpgradeType";
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass("ChestModalWindow")
|
|
export class ChestModalWindow extends ModalWindow<LevelUpModalWindowParams, UpgradeType> {
|
|
@property(LevelUpSkill) private levelUpSkill: LevelUpSkill;
|
|
@property(UIButton) private okButton: UIButton;
|
|
|
|
protected setup(params: LevelUpModalWindowParams): void {
|
|
const randomIndex = randomRangeInt(0, params.availableUpgrades.length - 1);
|
|
const skillToUpgrade = params.availableUpgrades[randomIndex];
|
|
this.levelUpSkill.init(skillToUpgrade, params.translationData);
|
|
|
|
this.okButton.InteractedEvent.on(() => this.dismiss(skillToUpgrade), this);
|
|
}
|
|
}
|