mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-26 03:38:58 +00:00
Meta upgrades
This commit is contained in:
parent
c85345cba0
commit
499fbac2b2
@ -61,12 +61,78 @@
|
||||
"maxRegenerationUpgrades": 5
|
||||
},
|
||||
"metaUpgrades": {
|
||||
"healthPointsPerLevel": 0,
|
||||
"bonusDamagePerLevel": 0,
|
||||
"projectilePiercingPerLevel": 0,
|
||||
"movementSpeedPerLevel": 0,
|
||||
"xpBonusPerLevel": 0,
|
||||
"goldBonusPerLevel": 0
|
||||
"health": {
|
||||
"costs": [
|
||||
5,
|
||||
10,
|
||||
15
|
||||
],
|
||||
"bonuses": [
|
||||
10,
|
||||
20,
|
||||
30
|
||||
]
|
||||
},
|
||||
"overallDamage": {
|
||||
"costs": [
|
||||
6,
|
||||
10,
|
||||
15
|
||||
],
|
||||
"bonuses": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]
|
||||
},
|
||||
"projectilePiercing": {
|
||||
"costs": [
|
||||
7,
|
||||
10,
|
||||
15
|
||||
],
|
||||
"bonuses": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]
|
||||
},
|
||||
"movementSpeed": {
|
||||
"costs": [
|
||||
8,
|
||||
10,
|
||||
15
|
||||
],
|
||||
"bonuses": [
|
||||
10,
|
||||
20,
|
||||
30
|
||||
]
|
||||
},
|
||||
"xpGatherer": {
|
||||
"costs": [
|
||||
9,
|
||||
10,
|
||||
15
|
||||
],
|
||||
"bonuses": [
|
||||
0.1,
|
||||
0.2,
|
||||
0.3
|
||||
]
|
||||
},
|
||||
"goldGatherer": {
|
||||
"costs": [
|
||||
10,
|
||||
10,
|
||||
15
|
||||
],
|
||||
"bonuses": [
|
||||
0.1,
|
||||
0.2,
|
||||
0.3
|
||||
]
|
||||
}
|
||||
},
|
||||
"enemyManager": {
|
||||
"enemies": [
|
||||
|
@ -10,5 +10,17 @@
|
||||
"HALO_PROJECTILE_TITLE": "Halo Projectile",
|
||||
"HALO_PROJECTILE_DESC": "",
|
||||
"REGENERATION_TITLE": "Regeneration",
|
||||
"REGENERATION_DESC": ""
|
||||
"REGENERATION_DESC": "",
|
||||
"META_HEALTH_TITLE": "HEALTH",
|
||||
"META_HEALTH_DESC": "Increases max health by {0}",
|
||||
"META_OVERALL_DAMAGE_TITLE": "OVERALL DAMAGE",
|
||||
"META_OVERALL_DAMAGE_DESC": "Increases overall damage by {0}",
|
||||
"META_PROJECTILE_PIERCING_TITLE": "",
|
||||
"META_PROJECTILE_PIERCING_DESC": "",
|
||||
"META_MOVEMENT_SPEED_TITLE": "",
|
||||
"META_MOVEMENT_SPEED_DESC": "",
|
||||
"META_XP_GATHERER_TITLE": "",
|
||||
"META_XP_GATHERER_DESC": "",
|
||||
"META_GOLD_GATHERER_TITLE": "",
|
||||
"META_GOLD_GATHERER_DESC": ""
|
||||
}
|
@ -270,8 +270,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 56.43,
|
||||
"height": 20
|
||||
"width": 120,
|
||||
"height": 50
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@ -300,19 +300,19 @@
|
||||
"_dstBlendFactor": 4,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"r": 0,
|
||||
"g": 0,
|
||||
"b": 0,
|
||||
"a": 255
|
||||
},
|
||||
"_string": "label",
|
||||
"_horizontalAlign": 1,
|
||||
"_verticalAlign": 1,
|
||||
"_actualFontSize": 20,
|
||||
"_fontSize": 20,
|
||||
"_actualFontSize": 15,
|
||||
"_fontSize": 15,
|
||||
"_fontFamily": "Arial",
|
||||
"_lineHeight": 20,
|
||||
"_overflow": 0,
|
||||
"_lineHeight": 15,
|
||||
"_overflow": 1,
|
||||
"_enableWrapText": true,
|
||||
"_font": {
|
||||
"__uuid__": "c96b42a9-d20d-4c59-8e99-8ed749a715c8",
|
||||
|
@ -25,17 +25,17 @@
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 42
|
||||
"__id__": 48
|
||||
},
|
||||
{
|
||||
"__id__": 44
|
||||
"__id__": 50
|
||||
},
|
||||
{
|
||||
"__id__": 46
|
||||
"__id__": 52
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 48
|
||||
"__id__": 54
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@ -84,14 +84,14 @@
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 37
|
||||
"__id__": 43
|
||||
},
|
||||
{
|
||||
"__id__": 39
|
||||
"__id__": 45
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 41
|
||||
"__id__": 47
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@ -289,11 +289,11 @@
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 34
|
||||
"__id__": 40
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 36
|
||||
"__id__": 42
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@ -482,22 +482,25 @@
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 21
|
||||
},
|
||||
{
|
||||
"__id__": 27
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 27
|
||||
"__id__": 33
|
||||
},
|
||||
{
|
||||
"__id__": 29
|
||||
"__id__": 35
|
||||
},
|
||||
{
|
||||
"__id__": 31
|
||||
"__id__": 37
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 33
|
||||
"__id__": 39
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@ -529,7 +532,7 @@
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "UpgradesParent",
|
||||
"_name": "CoinsLabel",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 20
|
||||
@ -550,7 +553,7 @@
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"y": 224.95,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
@ -586,6 +589,138 @@
|
||||
"__prefab": {
|
||||
"__id__": 23
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 30,
|
||||
"height": 40
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "0bWTFM0iJOd7lx2YvOQbs5"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Label",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 21
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 25
|
||||
},
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
"_dstBlendFactor": 4,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 179,
|
||||
"b": 82,
|
||||
"a": 255
|
||||
},
|
||||
"_string": "13",
|
||||
"_horizontalAlign": 1,
|
||||
"_verticalAlign": 1,
|
||||
"_actualFontSize": 40,
|
||||
"_fontSize": 40,
|
||||
"_fontFamily": "Arial",
|
||||
"_lineHeight": 40,
|
||||
"_overflow": 0,
|
||||
"_enableWrapText": true,
|
||||
"_font": {
|
||||
"__uuid__": "c96b42a9-d20d-4c59-8e99-8ed749a715c8",
|
||||
"__expectedType__": "cc.BitmapFont"
|
||||
},
|
||||
"_isSystemFontUsed": false,
|
||||
"_spacingX": 0,
|
||||
"_isItalic": false,
|
||||
"_isBold": false,
|
||||
"_isUnderline": false,
|
||||
"_underlineHeight": 2,
|
||||
"_cacheMode": 0,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "1cr4//m/9C8pCUMzr5q/G8"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
"__id__": 1
|
||||
},
|
||||
"asset": {
|
||||
"__id__": 0
|
||||
},
|
||||
"fileId": "1dzqEDPs9PGrSJaf6rz4yO"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "UpgradesParent",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 20
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 28
|
||||
},
|
||||
{
|
||||
"__id__": 30
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 32
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
"__type__": "cc.Quat",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"_lscale": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"z": 1
|
||||
},
|
||||
"_layer": 33554432,
|
||||
"_euler": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 27
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 29
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 430,
|
||||
@ -607,11 +742,11 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 21
|
||||
"__id__": 27
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 25
|
||||
"__id__": 31
|
||||
},
|
||||
"_resizeMode": 1,
|
||||
"_layoutType": 3,
|
||||
@ -658,7 +793,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 28
|
||||
"__id__": 34
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@ -685,7 +820,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 30
|
||||
"__id__": 36
|
||||
},
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
@ -729,7 +864,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 32
|
||||
"__id__": 38
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
@ -756,7 +891,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 35
|
||||
"__id__": 41
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@ -793,7 +928,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 38
|
||||
"__id__": 44
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@ -820,7 +955,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 40
|
||||
"__id__": 46
|
||||
},
|
||||
"playOnLoad": false,
|
||||
"_clips": [
|
||||
@ -862,7 +997,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 43
|
||||
"__id__": 49
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@ -890,7 +1025,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 45
|
||||
"__id__": 51
|
||||
},
|
||||
"_alignFlags": 45,
|
||||
"_target": null,
|
||||
@ -925,10 +1060,10 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 47
|
||||
"__id__": 53
|
||||
},
|
||||
"animation": {
|
||||
"__id__": 39
|
||||
"__id__": 45
|
||||
},
|
||||
"closeButton": {
|
||||
"__id__": 17
|
||||
@ -941,7 +1076,10 @@
|
||||
"__expectedType__": "cc.Prefab"
|
||||
},
|
||||
"upgradeButtonParent": {
|
||||
"__id__": 21
|
||||
"__id__": 27
|
||||
},
|
||||
"goldCoinsLabel": {
|
||||
"__id__": 24
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
|
@ -2,7 +2,7 @@ import { sys } from "cc";
|
||||
import { UserData } from "../Game/Data/UserData";
|
||||
|
||||
export class SaveSystem {
|
||||
private userDataIdentifier = "user-dat";
|
||||
private userDataIdentifier = "user-da";
|
||||
public save(userData: UserData): void {
|
||||
sys.localStorage.setItem(this.userDataIdentifier, JSON.stringify(userData));
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
export class GameSettings {
|
||||
public player: PlayerSettings = new PlayerSettings();
|
||||
public upgrades: UpgradeSettings = new UpgradeSettings();
|
||||
public metaUpgrades: MetaUpgradeSettings = new MetaUpgradeSettings();
|
||||
public metaUpgrades: MetaUpgradesSettings = new MetaUpgradesSettings();
|
||||
public enemyManager: EnemyManagerSettings = new EnemyManagerSettings();
|
||||
}
|
||||
|
||||
@ -50,13 +50,18 @@ export class UpgradeSettings {
|
||||
public maxRegenerationUpgrades = 0;
|
||||
}
|
||||
|
||||
export class MetaUpgradesSettings {
|
||||
public health = new MetaUpgradeSettings();
|
||||
public overallDamage = new MetaUpgradeSettings();
|
||||
public projectilePiercing = new MetaUpgradeSettings();
|
||||
public movementSpeed = new MetaUpgradeSettings();
|
||||
public xpGatherer = new MetaUpgradeSettings();
|
||||
public goldGatherer = new MetaUpgradeSettings();
|
||||
}
|
||||
|
||||
export class MetaUpgradeSettings {
|
||||
public healthPointsPerLevel = 0;
|
||||
public bonusDamagePerLevel = 0;
|
||||
public projectilePiercingPerLevel = 0;
|
||||
public movementSpeedPerLevel = 0;
|
||||
public xpBonusPerLevel = 0;
|
||||
public goldBonusPerLevel = 0;
|
||||
public costs: number[] = [];
|
||||
public bonuses: number[] = [];
|
||||
}
|
||||
|
||||
export class EnemyManagerSettings {
|
||||
|
@ -11,8 +11,8 @@ export class GameData {
|
||||
}
|
||||
|
||||
export class MetaUpgradesData {
|
||||
public maxHpLevel = 0;
|
||||
public bonusDamageLevel = 2;
|
||||
public healthLevel = 0;
|
||||
public overallDamageLevel = 2;
|
||||
public projectilePiercingLevel = 0;
|
||||
public movementSpeedLevel = 0;
|
||||
public xpGathererLevel = 0;
|
||||
|
@ -142,7 +142,7 @@ export class Game extends Component {
|
||||
private createPlayerData(settings: PlayerSettings, metaUpgrades: MetaUpgrades): PlayerData {
|
||||
const playerData: PlayerData = Object.assign(new PlayerData(), settings);
|
||||
|
||||
playerData.maxHp = metaUpgrades.getUpgradeValue(MetaUpgradeType.MaxHp) + settings.defaultHP;
|
||||
playerData.maxHp = metaUpgrades.getUpgradeValue(MetaUpgradeType.Health) + settings.defaultHP;
|
||||
playerData.requiredXP = settings.requiredXP;
|
||||
playerData.speed = metaUpgrades.getUpgradeValue(MetaUpgradeType.MovementSpeed) + settings.speed;
|
||||
playerData.regenerationDelay = settings.regenerationDelay;
|
||||
|
@ -24,8 +24,8 @@ export class TestGameRunner extends Component {
|
||||
while (Game.Instance == null || AppRoot.Instance == null) await delay(100);
|
||||
|
||||
const testUserData = new UserData();
|
||||
testUserData.game.metaUpgrades.maxHpLevel = this.maxHpLevel;
|
||||
testUserData.game.metaUpgrades.bonusDamageLevel = this.bonusDamageLevel;
|
||||
testUserData.game.metaUpgrades.healthLevel = this.maxHpLevel;
|
||||
testUserData.game.metaUpgrades.overallDamageLevel = this.bonusDamageLevel;
|
||||
testUserData.game.metaUpgrades.projectilePiercingLevel = this.projectilePiercingLevel;
|
||||
testUserData.game.metaUpgrades.movementSpeedLevel = this.movementSpeedLevel;
|
||||
testUserData.game.metaUpgrades.xpGathererLevel = this.xpGathererLevel;
|
||||
|
@ -1,16 +1,26 @@
|
||||
import { MetaUpgradeSettings } from "../../Data/GameSettings";
|
||||
import { MetaUpgradesSettings } from "../../Data/GameSettings";
|
||||
import { MetaUpgradesData } from "../../Data/UserData";
|
||||
import { MetaUpgradeType } from "../../Upgrades/UpgradeType";
|
||||
|
||||
export class MetaUpgrades {
|
||||
private upgradeTypeToValue = new Map<MetaUpgradeType, number>();
|
||||
public constructor(data: MetaUpgradesData, settings: MetaUpgradeSettings) {
|
||||
this.upgradeTypeToValue.set(MetaUpgradeType.MaxHp, data.maxHpLevel * settings.healthPointsPerLevel);
|
||||
this.upgradeTypeToValue.set(MetaUpgradeType.OverallDamage, data.bonusDamageLevel * settings.bonusDamagePerLevel);
|
||||
this.upgradeTypeToValue.set(MetaUpgradeType.ProjectilePiercing, data.projectilePiercingLevel * settings.projectilePiercingPerLevel);
|
||||
this.upgradeTypeToValue.set(MetaUpgradeType.MovementSpeed, data.movementSpeedLevel * settings.movementSpeedPerLevel);
|
||||
this.upgradeTypeToValue.set(MetaUpgradeType.XPGatherer, data.xpGathererLevel * settings.xpBonusPerLevel);
|
||||
this.upgradeTypeToValue.set(MetaUpgradeType.GoldGatherer, data.goldGathererLevel * settings.goldBonusPerLevel);
|
||||
public constructor(data: MetaUpgradesData, settings: MetaUpgradesSettings) {
|
||||
this.upgradeTypeToValue.set(MetaUpgradeType.Health, this.getBonusValue(data.healthLevel, settings.health.bonuses));
|
||||
this.upgradeTypeToValue.set(MetaUpgradeType.OverallDamage, this.getBonusValue(data.overallDamageLevel, settings.overallDamage.bonuses));
|
||||
this.upgradeTypeToValue.set(
|
||||
MetaUpgradeType.ProjectilePiercing,
|
||||
this.getBonusValue(data.projectilePiercingLevel, settings.projectilePiercing.bonuses)
|
||||
);
|
||||
this.upgradeTypeToValue.set(MetaUpgradeType.MovementSpeed, this.getBonusValue(data.movementSpeedLevel, settings.movementSpeed.bonuses));
|
||||
this.upgradeTypeToValue.set(MetaUpgradeType.XPGatherer, this.getBonusValue(data.xpGathererLevel, settings.xpGatherer.bonuses));
|
||||
this.upgradeTypeToValue.set(MetaUpgradeType.GoldGatherer, this.getBonusValue(data.goldGathererLevel, settings.goldGatherer.bonuses));
|
||||
}
|
||||
|
||||
private getBonusValue(level: number, bonuses: number[]): number {
|
||||
if (level <= 0) return 0;
|
||||
if (bonuses.length < level) throw new Error(`Meta upgrade does not have settings for level ${level}`);
|
||||
|
||||
return bonuses[level - 1];
|
||||
}
|
||||
|
||||
public getUpgradeValue(type: MetaUpgradeType): number {
|
||||
|
@ -8,10 +8,10 @@ export enum UpgradeType {
|
||||
}
|
||||
|
||||
export enum MetaUpgradeType {
|
||||
MaxHp,
|
||||
OverallDamage,
|
||||
ProjectilePiercing,
|
||||
MovementSpeed,
|
||||
XPGatherer,
|
||||
GoldGatherer
|
||||
Health = "META_HEALTH",
|
||||
OverallDamage = "META_OVERALL_DAMAGE",
|
||||
ProjectilePiercing = "META_PROJECTILE_PIERCING",
|
||||
MovementSpeed = "META_MOVEMENT_SPEED",
|
||||
XPGatherer = "META_XP_GATHERER",
|
||||
GoldGatherer = "META_GOLD_GATHERER"
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
8
assets/Scripts/Services/Utils/StringUtils.ts
Normal file
8
assets/Scripts/Services/Utils/StringUtils.ts
Normal file
@ -0,0 +1,8 @@
|
||||
export function formatString(text: string, params: string[]): string {
|
||||
let textWithParams = text;
|
||||
for (let i = 0; i < params.length; i++) {
|
||||
textWithParams = textWithParams.replace(`{${i}}`, params[i]);
|
||||
}
|
||||
|
||||
return textWithParams;
|
||||
}
|
9
assets/Scripts/Services/Utils/StringUtils.ts.meta
Normal file
9
assets/Scripts/Services/Utils/StringUtils.ts.meta
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "ceda74cb-8b1e-4bd3-9cfb-0bbf0315fc40",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user