initial translations

This commit is contained in:
Martin
2022-12-13 16:58:55 +01:00
parent c20ca61290
commit 9a41923b17
7 changed files with 42 additions and 17 deletions

View File

@@ -2,20 +2,21 @@ import { instantiate, Node, Prefab, Vec3, _decorator } from "cc";
import { ModalWindow } from "../../../Services/ModalWindowSystem/ModalWindow";
import { shuffle } from "../../../Services/Utils/ArrayUtils";
import { delay } from "../../../Services/Utils/AsyncUtils";
import { TranslationData } from "../../Data/TranslationData";
import { UpgradeType } from "../../Upgrades/UpgradeType";
import { LevelUpSkill } from "./LevelUpSkill";
const { ccclass, property } = _decorator;
@ccclass("LevelUpModalWindow")
export class LevelUpModalWindow extends ModalWindow<UpgradeType[], UpgradeType> {
export class LevelUpModalWindow extends ModalWindow<LevelUpModalWindowParams, UpgradeType> {
@property(Prefab) private skillPrefab: Prefab;
@property(Node) private skillParent: Node;
private maxUpgradesToPick = 3;
protected async setup(availableUpgrades: UpgradeType[]): Promise<void> {
const shuffledAvailableUpgrades = shuffle(availableUpgrades);
protected async setup(params: LevelUpModalWindowParams): Promise<void> {
const shuffledAvailableUpgrades = shuffle(params.availableUpgrades);
if (this.maxUpgradesToPick < shuffledAvailableUpgrades.length) {
shuffledAvailableUpgrades.length = this.maxUpgradesToPick;
}
@@ -26,7 +27,7 @@ export class LevelUpModalWindow extends ModalWindow<UpgradeType[], UpgradeType>
const skill: LevelUpSkill = instantiate(this.skillPrefab).getComponent(LevelUpSkill);
skill.node.setParent(this.skillParent);
skill.node.setPosition(new Vec3(xPositions[i]));
skill.init(shuffledAvailableUpgrades[i]);
skill.init(shuffledAvailableUpgrades[i], params.translationData);
skill.ChooseSkillEvent.on(this.chooseSkill, this);
}
}
@@ -35,3 +36,8 @@ export class LevelUpModalWindow extends ModalWindow<UpgradeType[], UpgradeType>
this.dismiss(upgradeType);
}
}
export class LevelUpModalWindowParams {
public availableUpgrades: UpgradeType[];
public translationData: TranslationData;
}

View File

@@ -1,6 +1,7 @@
import { Component, Label, NodeEventType, _decorator } from "cc";
import { ISignal } from "../../../Services/EventSystem/ISignal";
import { Signal } from "../../../Services/EventSystem/Signal";
import { TranslationData } from "../../Data/TranslationData";
import { UpgradeType } from "../../Upgrades/UpgradeType";
const { ccclass, property } = _decorator;
@@ -10,9 +11,9 @@ export class LevelUpSkill extends Component {
private chooseSkillEvent: Signal<UpgradeType> = new Signal<UpgradeType>();
private skillType: UpgradeType;
public init(skillType: UpgradeType): void {
public init(skillType: UpgradeType, translationData: TranslationData): void {
this.skillType = skillType;
this.skillTitle.string = `${skillType}`;
this.skillTitle.string = `${translationData[`${skillType}_TITLE`]}`;
this.node.on(NodeEventType.MOUSE_DOWN, this.chooseSkill, this);
}