mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 00:26:04 +00:00
Meta upgrades
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import { Component, instantiate, Label, Node, Prefab, _decorator } from "cc";
|
||||
import { MetaUpgradeSettings } from "../../../Game/Data/GameSettings";
|
||||
import { TranslationData } from "../../../Game/Data/TranslationData";
|
||||
import { MetaUpgradeType } from "../../../Game/Upgrades/UpgradeType";
|
||||
import { formatString } from "../../../Services/Utils/StringUtils";
|
||||
import { UpgradeLevelPointUI } from "./UpgradeLevelPointUI";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -10,8 +14,8 @@ export class UpgradeUI extends Component {
|
||||
@property(Label) private description: Label;
|
||||
@property(Label) private cost: Label;
|
||||
|
||||
public init(titleText: string, descriptionText: string, levels: number): void {
|
||||
for (let i = 0; i < levels; i++) {
|
||||
public init(upgradeType: MetaUpgradeType, upgradeSettings: MetaUpgradeSettings, level: number, translationData: TranslationData): void {
|
||||
for (let i = 0; i < upgradeSettings.bonuses.length; i++) {
|
||||
const node: Node = instantiate(this.levelPointPrefab);
|
||||
node.setParent(this.levelPointsParent);
|
||||
|
||||
@@ -22,8 +26,8 @@ export class UpgradeUI extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
this.title.string = titleText;
|
||||
this.description.string = descriptionText;
|
||||
this.cost.string = "55";
|
||||
this.title.string = `${translationData[`${upgradeType}_TITLE`]}`;
|
||||
this.description.string = formatString(`${translationData[`${upgradeType}_DESC`]}`, [upgradeSettings.bonuses[level].toString()]);
|
||||
this.cost.string = upgradeSettings.costs[level].toString();
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,8 @@
|
||||
import { instantiate, Prefab, _decorator, Node } from "cc";
|
||||
import { instantiate, Label, Node, Prefab, _decorator } from "cc";
|
||||
import { AppRoot } from "../../../AppRoot/AppRoot";
|
||||
import { MetaUpgradeSettings } from "../../../Game/Data/GameSettings";
|
||||
import { GameData } from "../../../Game/Data/UserData";
|
||||
import { MetaUpgradeType } from "../../../Game/Upgrades/UpgradeType";
|
||||
import { ModalWindow } from "../../../Services/ModalWindowSystem/ModalWindow";
|
||||
import { UpgradeUI } from "./UpgradeUI";
|
||||
|
||||
@@ -6,15 +10,32 @@ const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("UpgradesModalWindow")
|
||||
export class UpgradesModalWindow extends ModalWindow<Empty, Empty> {
|
||||
@property(Prefab) upgradeButtonPrefab: Prefab;
|
||||
@property(Node) upgradeButtonParent: Node;
|
||||
@property(Prefab) private upgradeButtonPrefab: Prefab;
|
||||
@property(Node) private upgradeButtonParent: Node;
|
||||
@property(Label) private goldCoinsLabel: Label;
|
||||
|
||||
public setup(params: Empty): void {
|
||||
for (let index = 0; index < 6; index++) {
|
||||
const upgradeButton: Node = instantiate(this.upgradeButtonPrefab);
|
||||
upgradeButton.getComponent(UpgradeUI).init("Title", "Description", 5);
|
||||
upgradeButton.setParent(this.upgradeButtonParent);
|
||||
}
|
||||
private gameData: GameData;
|
||||
|
||||
public setup(): void {
|
||||
this.gameData = AppRoot.Instance.SaveSystem.load().game;
|
||||
|
||||
const settings = AppRoot.Instance.Settings.metaUpgrades;
|
||||
const data = this.gameData.metaUpgrades;
|
||||
|
||||
this.createUpgradeButton(MetaUpgradeType.Health, settings.health, data.healthLevel);
|
||||
this.createUpgradeButton(MetaUpgradeType.OverallDamage, settings.overallDamage, data.healthLevel);
|
||||
this.createUpgradeButton(MetaUpgradeType.ProjectilePiercing, settings.projectilePiercing, data.healthLevel);
|
||||
this.createUpgradeButton(MetaUpgradeType.MovementSpeed, settings.movementSpeed, data.healthLevel);
|
||||
this.createUpgradeButton(MetaUpgradeType.XPGatherer, settings.xpGatherer, data.healthLevel);
|
||||
this.createUpgradeButton(MetaUpgradeType.GoldGatherer, settings.goldGatherer, data.healthLevel);
|
||||
|
||||
this.goldCoinsLabel.string = this.gameData.goldCoins.toString();
|
||||
}
|
||||
|
||||
private createUpgradeButton(upgradeType: MetaUpgradeType, upgradeSettings: MetaUpgradeSettings, level: number): void {
|
||||
const upgradeButton: Node = instantiate(this.upgradeButtonPrefab);
|
||||
upgradeButton.getComponent(UpgradeUI).init(upgradeType, upgradeSettings, level, AppRoot.Instance.TranslationData);
|
||||
upgradeButton.setParent(this.upgradeButtonParent);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user