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

@ -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": ""
}

View File

@ -0,0 +1,3 @@
export class TranslationData {
[key: string]: string;
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "8711b923-4e6c-4ad6-ba89-0061450d44a1",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -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<number> {
const settings: GameSettings = <GameSettings>this.settingsAsset.json;
const translationData = <TranslationData>this.translationAsset.json;
const settings = <GameSettings>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);

View File

@ -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<void> {
this.gamePauser.pause();
const skillToUpgrade: UpgradeType = await this.modalWindowManager.showModal<UpgradeType[], UpgradeType>(
const skillToUpgrade: UpgradeType = await this.modalWindowManager.showModal<LevelUpModalWindowParams, UpgradeType>(
GameModalWindowTypes.LevelUpModal,
Array.from(this.upgrader.getAvailableUpgrades())
{ availableUpgrades: Array.from(this.upgrader.getAvailableUpgrades()), translationData: this.translationData }
);
this.gamePauser.resume();
this.upgrader.upgradeSkill(skillToUpgrade);

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);
}