Slash-The-Hordes/assets/Scripts/Game/ModalWIndows/ChestModalWindow.ts

22 lines
1.0 KiB
TypeScript
Raw Normal View History

2023-01-02 07:57:59 +00:00
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);
}
}