diff --git a/assets/Data/eng.json b/assets/Data/eng.json index cc35c2e..c9e1ee6 100644 --- a/assets/Data/eng.json +++ b/assets/Data/eng.json @@ -1,14 +1,14 @@ { - "WEAPON_LENGTH_TITLE": "", + "WEAPON_LENGTH_TITLE": "Weapon Length", "WEAPON_LENGTH_DESC": "", - "WEAPON_DAMAGE_TITLE": "", + "WEAPON_DAMAGE_TITLE": "Weapon Damage", "WEAPON_DAMAGE_DESC": "", - "HORIZONTAL_PROJECTILE_TITLE": "", + "HORIZONTAL_PROJECTILE_TITLE": "Horizontal Projectile", "HORIZONTAL_PROJECTILE_DESC": "", - "DIAGONAL_PROJECTILE_TITLE": "", + "DIAGONAL_PROJECTILE_TITLE": "Diagonal Projectile", "DIAGONAL_PROJECTILE_DESC": "", - "HALO_PROJECTILE_TITLE": "", + "HALO_PROJECTILE_TITLE": "Halo Projectile", "HALO_PROJECTILE_DESC": "", - "REGENERATION_TITLE": "", + "REGENERATION_TITLE": "Regeneration", "REGENERATION_DESC": "" } \ No newline at end of file diff --git a/assets/Scripts/Game/Data/TranslationData.ts b/assets/Scripts/Game/Data/TranslationData.ts new file mode 100644 index 0000000..fe727b9 --- /dev/null +++ b/assets/Scripts/Game/Data/TranslationData.ts @@ -0,0 +1,3 @@ +export class TranslationData { + [key: string]: string; +} diff --git a/assets/Scripts/Game/Data/TranslationData.ts.meta b/assets/Scripts/Game/Data/TranslationData.ts.meta new file mode 100644 index 0000000..ac169aa --- /dev/null +++ b/assets/Scripts/Game/Data/TranslationData.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "8711b923-4e6c-4ad6-ba89-0061450d44a1", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/Scripts/Game/Game.ts b/assets/Scripts/Game/Game.ts index 3c6c391..ff4e94e 100644 --- a/assets/Scripts/Game/Game.ts +++ b/assets/Scripts/Game/Game.ts @@ -6,6 +6,7 @@ import { PlayerCollisionSystem } from "./Collision/PlayerCollisionSystem"; import { PlayerProjectileCollisionSystem } from "./Collision/PlayerProjectileCollisionSystem"; import { WeaponCollisionSystem } from "./Collision/WeaponCollisionSystem"; import { GameSettings, PlayerSettings } from "./Data/GameSettings"; +import { TranslationData } from "./Data/TranslationData"; import { UserData } from "./Data/UserData"; import { KeyboardInput } from "./Input/KeyboardInput"; import { MultiInput } from "./Input/MultiInput"; @@ -37,6 +38,7 @@ export class Game extends Component { @property(Background) private background: Background; @property(ModalWindowManager) private modalWindowManager: ModalWindowManager; @property(JsonAsset) private settingsAsset: JsonAsset; + @property(JsonAsset) private translationAsset: JsonAsset; private playerCollisionSystem: PlayerCollisionSystem; private haloProjectileLauncher: HaloProjectileLauncher; @@ -57,7 +59,8 @@ export class Game extends Component { } public async playGame(userData: UserData): Promise { - const settings: GameSettings = this.settingsAsset.json; + const translationData = this.translationAsset.json; + const settings = this.settingsAsset.json; const metaUpgrades = new MetaUpgrades(userData.game.metaUpgrades, settings.metaUpgrades); this.virtualJoystic.init(); @@ -109,7 +112,7 @@ export class Game extends Component { this.diagonalProjectileLauncher, settings.upgrades ); - new GameModalLauncher(this.modalWindowManager, this.player, this.gamePauser, upgrader); + new GameModalLauncher(this.modalWindowManager, this.player, this.gamePauser, upgrader, translationData); this.gameUI.init(this.player); this.background.init(this.player.node); diff --git a/assets/Scripts/Game/ModalWIndows/GameModalLauncher.ts b/assets/Scripts/Game/ModalWIndows/GameModalLauncher.ts index 6246cfb..11b605e 100644 --- a/assets/Scripts/Game/ModalWIndows/GameModalLauncher.ts +++ b/assets/Scripts/Game/ModalWIndows/GameModalLauncher.ts @@ -1,5 +1,7 @@ import { ModalWindowManager } from "../../Services/ModalWindowSystem/ModalWindowManager"; +import { TranslationData } from "../Data/TranslationData"; import { Pauser } from "../Pauser"; +import { LevelUpModalWindowParams } from "../UI/LevelUpWindow/LevelUpModalWindow"; import { Player } from "../Unit/Player/Player"; import { Upgrader } from "../Upgrades/Upgrader"; import { UpgradeType } from "../Upgrades/UpgradeType"; @@ -10,16 +12,17 @@ export class GameModalLauncher { private modalWindowManager: ModalWindowManager, private player: Player, private gamePauser: Pauser, - private upgrader: Upgrader + private upgrader: Upgrader, + private translationData: TranslationData ) { this.player.Level.LevelUpEvent.on(this.showLevelUpModal, this); } private async showLevelUpModal(): Promise { this.gamePauser.pause(); - const skillToUpgrade: UpgradeType = await this.modalWindowManager.showModal( + const skillToUpgrade: UpgradeType = await this.modalWindowManager.showModal( GameModalWindowTypes.LevelUpModal, - Array.from(this.upgrader.getAvailableUpgrades()) + { availableUpgrades: Array.from(this.upgrader.getAvailableUpgrades()), translationData: this.translationData } ); this.gamePauser.resume(); this.upgrader.upgradeSkill(skillToUpgrade); diff --git a/assets/Scripts/Game/UI/LevelUpWindow/LevelUpModalWindow.ts b/assets/Scripts/Game/UI/LevelUpWindow/LevelUpModalWindow.ts index 1401a43..ead8b9c 100644 --- a/assets/Scripts/Game/UI/LevelUpWindow/LevelUpModalWindow.ts +++ b/assets/Scripts/Game/UI/LevelUpWindow/LevelUpModalWindow.ts @@ -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 { +export class LevelUpModalWindow extends ModalWindow { @property(Prefab) private skillPrefab: Prefab; @property(Node) private skillParent: Node; private maxUpgradesToPick = 3; - protected async setup(availableUpgrades: UpgradeType[]): Promise { - const shuffledAvailableUpgrades = shuffle(availableUpgrades); + protected async setup(params: LevelUpModalWindowParams): Promise { + const shuffledAvailableUpgrades = shuffle(params.availableUpgrades); if (this.maxUpgradesToPick < shuffledAvailableUpgrades.length) { shuffledAvailableUpgrades.length = this.maxUpgradesToPick; } @@ -26,7 +27,7 @@ export class LevelUpModalWindow extends ModalWindow 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 this.dismiss(upgradeType); } } + +export class LevelUpModalWindowParams { + public availableUpgrades: UpgradeType[]; + public translationData: TranslationData; +} diff --git a/assets/Scripts/Game/UI/LevelUpWindow/LevelUpSkill.ts b/assets/Scripts/Game/UI/LevelUpWindow/LevelUpSkill.ts index 214517f..1fdcfe2 100644 --- a/assets/Scripts/Game/UI/LevelUpWindow/LevelUpSkill.ts +++ b/assets/Scripts/Game/UI/LevelUpWindow/LevelUpSkill.ts @@ -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 = new Signal(); 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); }