Meta upgrades

This commit is contained in:
Martin 2022-12-16 13:52:54 +01:00
parent c85345cba0
commit 499fbac2b2
15 changed files with 688 additions and 415 deletions

View File

@ -61,343 +61,409 @@
"maxRegenerationUpgrades": 5 "maxRegenerationUpgrades": 5
}, },
"metaUpgrades": { "metaUpgrades": {
"healthPointsPerLevel": 0, "health": {
"bonusDamagePerLevel": 0, "costs": [
"projectilePiercingPerLevel": 0, 5,
"movementSpeedPerLevel": 0, 10,
"xpBonusPerLevel": 0, 15
"goldBonusPerLevel": 0 ],
"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": { "enemyManager": {
"enemies": [ "enemies": [
{ {
"id": "BasicEnemy", "id": "BasicEnemy",
"moveType": "Follow", "moveType": "Follow",
"health": 2, "health": 2,
"damage": 1, "damage": 1,
"speed": 60, "speed": 60,
"lifetime": -1, "lifetime": -1,
"xpReward": 0, "xpReward": 0,
"goldReward": 0 "goldReward": 0
}, },
{ {
"id": "StandardEnemy", "id": "StandardEnemy",
"moveType": "Follow", "moveType": "Follow",
"health": 3, "health": 3,
"damage": 2, "damage": 2,
"speed": 65, "speed": 65,
"lifetime": -1, "lifetime": -1,
"xpReward": 0, "xpReward": 0,
"goldReward": 0.1 "goldReward": 0.1
}, },
{ {
"id": "FastEnemy", "id": "FastEnemy",
"moveType": "Follow", "moveType": "Follow",
"health": 3, "health": 3,
"damage": 2, "damage": 2,
"speed": 75, "speed": 75,
"lifetime": -1, "lifetime": -1,
"xpReward": 0, "xpReward": 0,
"goldReward": 0.1 "goldReward": 0.1
}, },
{ {
"id": "CircleEnemy", "id": "CircleEnemy",
"moveType": "Follow", "moveType": "Follow",
"health": 4, "health": 4,
"damage": 1, "damage": 1,
"speed": 25, "speed": 25,
"lifetime": 29, "lifetime": 29,
"xpReward": 0, "xpReward": 0,
"goldReward": 1 "goldReward": 1
}, },
{ {
"id": "CircleEnemyStandard", "id": "CircleEnemyStandard",
"moveType": "Follow", "moveType": "Follow",
"health": 7, "health": 7,
"damage": 2, "damage": 2,
"speed": 35, "speed": 35,
"lifetime": 27, "lifetime": 27,
"xpReward": 0, "xpReward": 0,
"goldReward": 2 "goldReward": 2
}, },
{ {
"id": "WaveEnemy", "id": "WaveEnemy",
"moveType": "Launch", "moveType": "Launch",
"health": 1, "health": 1,
"damage": 2, "damage": 2,
"speed": 390, "speed": 390,
"lifetime": 20, "lifetime": 20,
"xpReward": 0, "xpReward": 0,
"goldReward": 0.2 "goldReward": 0.2
}, },
{ {
"id": "WaveEnemyArmor", "id": "WaveEnemyArmor",
"moveType": "Launch", "moveType": "Launch",
"health": 5, "health": 5,
"damage": 3, "damage": 3,
"speed": 70, "speed": 70,
"lifetime": 30, "lifetime": 30,
"xpReward": 0, "xpReward": 0,
"goldReward": 1 "goldReward": 1
}, },
{ {
"id": "WaveEnemyArmorFast", "id": "WaveEnemyArmorFast",
"moveType": "Launch", "moveType": "Launch",
"health": 5, "health": 5,
"damage": 3, "damage": 3,
"speed": 320, "speed": 320,
"lifetime": 30, "lifetime": 30,
"xpReward": 0, "xpReward": 0,
"goldReward": 1 "goldReward": 1
}, },
{ {
"id": "BasicBoss", "id": "BasicBoss",
"moveType": "Follow", "moveType": "Follow",
"health": 8, "health": 8,
"damage": 2, "damage": 2,
"speed": 65, "speed": 65,
"lifetime": -1, "lifetime": -1,
"xpReward": 0, "xpReward": 0,
"goldReward": 3 "goldReward": 3
}, },
{ {
"id": "StandardBoss", "id": "StandardBoss",
"moveType": "Follow", "moveType": "Follow",
"health": 12, "health": 12,
"damage": 3, "damage": 3,
"speed": 75, "speed": 75,
"lifetime": -1, "lifetime": -1,
"xpReward": 2, "xpReward": 2,
"goldReward": 5 "goldReward": 5
}, },
{ {
"id": "BasicCheetah", "id": "BasicCheetah",
"moveType": "PeriodicFollow", "moveType": "PeriodicFollow",
"health": 4, "health": 4,
"damage": 1, "damage": 1,
"speed": 120, "speed": 120,
"lifetime": -1, "lifetime": -1,
"xpReward": 0, "xpReward": 0,
"goldReward": 1 "goldReward": 1
} }
], ],
"individualEnemySpawners": [ "individualEnemySpawners": [
{ {
"common": { "common": {
"enemyId": "BasicEnemy", "enemyId": "BasicEnemy",
"startDelay": 0, "startDelay": 0,
"stopDelay": 59, "stopDelay": 59,
"cooldown": 1 "cooldown": 1
} }
}, },
{ {
"common": { "common": {
"enemyId": "BasicBoss", "enemyId": "BasicBoss",
"startDelay": 89, "startDelay": 89,
"stopDelay": 90, "stopDelay": 90,
"cooldown": 0.9 "cooldown": 0.9
} }
}, },
{ {
"common": { "common": {
"enemyId": "BasicEnemy", "enemyId": "BasicEnemy",
"startDelay": 61, "startDelay": 61,
"stopDelay": 120, "stopDelay": 120,
"cooldown": 0.9 "cooldown": 0.9
} }
}, },
{ {
"common": { "common": {
"enemyId": "BasicEnemy", "enemyId": "BasicEnemy",
"startDelay": 121, "startDelay": 121,
"stopDelay": 190, "stopDelay": 190,
"cooldown": 0.8 "cooldown": 0.8
} }
}, },
{ {
"common": { "common": {
"enemyId": "StandardBoss", "enemyId": "StandardBoss",
"startDelay": 199, "startDelay": 199,
"stopDelay": 200, "stopDelay": 200,
"cooldown": 0.9 "cooldown": 0.9
} }
}, },
{ {
"common": { "common": {
"enemyId": "BasicEnemy", "enemyId": "BasicEnemy",
"startDelay": 191, "startDelay": 191,
"stopDelay": 220, "stopDelay": 220,
"cooldown": 1.5 "cooldown": 1.5
} }
}, },
{ {
"common": { "common": {
"enemyId": "StandardEnemy", "enemyId": "StandardEnemy",
"startDelay": 210, "startDelay": 210,
"stopDelay": 250, "stopDelay": 250,
"cooldown": 0.9 "cooldown": 0.9
} }
}, },
{ {
"common": { "common": {
"enemyId": "BasicEnemy", "enemyId": "BasicEnemy",
"startDelay": 290, "startDelay": 290,
"stopDelay": 320, "stopDelay": 320,
"cooldown": 1 "cooldown": 1
} }
}, },
{ {
"common": { "common": {
"enemyId": "StandardEnemy", "enemyId": "StandardEnemy",
"startDelay": 335, "startDelay": 335,
"stopDelay": 420, "stopDelay": 420,
"cooldown": 0.7 "cooldown": 0.7
} }
}, },
{ {
"common": { "common": {
"enemyId": "StandardEnemy", "enemyId": "StandardEnemy",
"startDelay": 421, "startDelay": 421,
"stopDelay": 520, "stopDelay": 520,
"cooldown": 0.5 "cooldown": 0.5
} }
}, },
{ {
"common": { "common": {
"enemyId": "StandardEnemy", "enemyId": "StandardEnemy",
"startDelay": 520, "startDelay": 520,
"stopDelay": 600, "stopDelay": 600,
"cooldown": 0.3 "cooldown": 0.3
} }
}, },
{ {
"common": { "common": {
"enemyId": "FastEnemy", "enemyId": "FastEnemy",
"startDelay": 310, "startDelay": 310,
"stopDelay": 340, "stopDelay": 340,
"cooldown": 0.5 "cooldown": 0.5
} }
}, },
{ {
"common": { "common": {
"enemyId": "FastEnemy", "enemyId": "FastEnemy",
"startDelay": 260, "startDelay": 260,
"stopDelay": 300, "stopDelay": 300,
"cooldown": 0.8 "cooldown": 0.8
} }
} }
], ],
"circularEnemySpawners": [ "circularEnemySpawners": [
{ {
"common": { "common": {
"enemyId": "CircleEnemy", "enemyId": "CircleEnemy",
"startDelay": 1, "startDelay": 1,
"stopDelay": 130, "stopDelay": 130,
"cooldown": 45 "cooldown": 45
}, },
"enemiesToSpawn": 38 "enemiesToSpawn": 38
}, },
{ {
"common": { "common": {
"enemyId": "BasicEnemy", "enemyId": "BasicEnemy",
"startDelay": 0, "startDelay": 0,
"stopDelay": 122, "stopDelay": 122,
"cooldown": 60 "cooldown": 60
}, },
"enemiesToSpawn": 10 "enemiesToSpawn": 10
}, },
{ {
"common": { "common": {
"enemyId": "CircleEnemyStandard", "enemyId": "CircleEnemyStandard",
"startDelay": 280, "startDelay": 280,
"stopDelay": 520, "stopDelay": 520,
"cooldown": 50 "cooldown": 50
}, },
"enemiesToSpawn": 44 "enemiesToSpawn": 44
}, },
{ {
"common": { "common": {
"enemyId": "CircleEnemyStandard", "enemyId": "CircleEnemyStandard",
"startDelay": 383, "startDelay": 383,
"stopDelay": 390, "stopDelay": 390,
"cooldown": 3 "cooldown": 3
}, },
"enemiesToSpawn": 44 "enemiesToSpawn": 44
}, },
{ {
"common": { "common": {
"enemyId": "BasicEnemy", "enemyId": "BasicEnemy",
"startDelay": 245, "startDelay": 245,
"stopDelay": 280, "stopDelay": 280,
"cooldown": 5 "cooldown": 5
}, },
"enemiesToSpawn": 12 "enemiesToSpawn": 12
}, },
{ {
"common": { "common": {
"enemyId": "BasicEnemy", "enemyId": "BasicEnemy",
"startDelay": 278, "startDelay": 278,
"stopDelay": 291, "stopDelay": 291,
"cooldown": 3 "cooldown": 3
}, },
"enemiesToSpawn": 30 "enemiesToSpawn": 30
}, },
{ {
"common": { "common": {
"enemyId": "BasicBoss", "enemyId": "BasicBoss",
"startDelay": 300, "startDelay": 300,
"stopDelay": 303, "stopDelay": 303,
"cooldown": 2 "cooldown": 2
}, },
"enemiesToSpawn": 8 "enemiesToSpawn": 8
}, },
{ {
"common": { "common": {
"enemyId": "BasicCheetah", "enemyId": "BasicCheetah",
"startDelay": 139, "startDelay": 139,
"stopDelay": 140, "stopDelay": 140,
"cooldown": 0.9 "cooldown": 0.9
}, },
"enemiesToSpawn": 6 "enemiesToSpawn": 6
} }
], ],
"waveEnemySpawners": [ "waveEnemySpawners": [
{ {
"common": { "common": {
"enemyId": "WaveEnemy", "enemyId": "WaveEnemy",
"startDelay": 1, "startDelay": 1,
"stopDelay": 201, "stopDelay": 201,
"cooldown": 25 "cooldown": 25
}, },
"enemiesToSpawn": 12 "enemiesToSpawn": 12
}, },
{ {
"common": { "common": {
"enemyId": "WaveEnemy", "enemyId": "WaveEnemy",
"startDelay": 420, "startDelay": 420,
"stopDelay": 600, "stopDelay": 600,
"cooldown": 35 "cooldown": 35
}, },
"enemiesToSpawn": 30 "enemiesToSpawn": 30
}, },
{ {
"common": { "common": {
"enemyId": "WaveEnemyArmor", "enemyId": "WaveEnemyArmor",
"startDelay": 1, "startDelay": 1,
"stopDelay": 199, "stopDelay": 199,
"cooldown": 50 "cooldown": 50
}, },
"enemiesToSpawn": 10 "enemiesToSpawn": 10
}, },
{ {
"common": { "common": {
"enemyId": "WaveEnemyArmorFast", "enemyId": "WaveEnemyArmorFast",
"startDelay": 200, "startDelay": 200,
"stopDelay": 600, "stopDelay": 600,
"cooldown": 27 "cooldown": 27
}, },
"enemiesToSpawn": 14 "enemiesToSpawn": 14
} }
] ]
} }
} }

View File

@ -10,5 +10,17 @@
"HALO_PROJECTILE_TITLE": "Halo Projectile", "HALO_PROJECTILE_TITLE": "Halo Projectile",
"HALO_PROJECTILE_DESC": "", "HALO_PROJECTILE_DESC": "",
"REGENERATION_TITLE": "Regeneration", "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": ""
} }

View File

@ -270,8 +270,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 56.43, "width": 120,
"height": 20 "height": 50
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@ -300,19 +300,19 @@
"_dstBlendFactor": 4, "_dstBlendFactor": 4,
"_color": { "_color": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 0,
"g": 255, "g": 0,
"b": 255, "b": 0,
"a": 255 "a": 255
}, },
"_string": "label", "_string": "label",
"_horizontalAlign": 1, "_horizontalAlign": 1,
"_verticalAlign": 1, "_verticalAlign": 1,
"_actualFontSize": 20, "_actualFontSize": 15,
"_fontSize": 20, "_fontSize": 15,
"_fontFamily": "Arial", "_fontFamily": "Arial",
"_lineHeight": 20, "_lineHeight": 15,
"_overflow": 0, "_overflow": 1,
"_enableWrapText": true, "_enableWrapText": true,
"_font": { "_font": {
"__uuid__": "c96b42a9-d20d-4c59-8e99-8ed749a715c8", "__uuid__": "c96b42a9-d20d-4c59-8e99-8ed749a715c8",

View File

@ -25,17 +25,17 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 42 "__id__": 48
}, },
{ {
"__id__": 44 "__id__": 50
}, },
{ {
"__id__": 46 "__id__": 52
} }
], ],
"_prefab": { "_prefab": {
"__id__": 48 "__id__": 54
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -84,14 +84,14 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 37 "__id__": 43
}, },
{ {
"__id__": 39 "__id__": 45
} }
], ],
"_prefab": { "_prefab": {
"__id__": 41 "__id__": 47
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -289,11 +289,11 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 34 "__id__": 40
} }
], ],
"_prefab": { "_prefab": {
"__id__": 36 "__id__": 42
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -482,22 +482,25 @@
"_children": [ "_children": [
{ {
"__id__": 21 "__id__": 21
},
{
"__id__": 27
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 27 "__id__": 33
}, },
{ {
"__id__": 29 "__id__": 35
}, },
{ {
"__id__": 31 "__id__": 37
} }
], ],
"_prefab": { "_prefab": {
"__id__": 33 "__id__": 39
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -529,7 +532,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "UpgradesParent", "_name": "CoinsLabel",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 20 "__id__": 20
@ -550,7 +553,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 224.95,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@ -586,6 +589,138 @@
"__prefab": { "__prefab": {
"__id__": 23 "__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": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 430, "width": 430,
@ -607,11 +742,11 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 21 "__id__": 27
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 25 "__id__": 31
}, },
"_resizeMode": 1, "_resizeMode": 1,
"_layoutType": 3, "_layoutType": 3,
@ -658,7 +793,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 28 "__id__": 34
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@ -685,7 +820,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 30 "__id__": 36
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@ -729,7 +864,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 32 "__id__": 38
}, },
"_id": "" "_id": ""
}, },
@ -756,7 +891,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 35 "__id__": 41
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@ -793,7 +928,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 38 "__id__": 44
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@ -820,7 +955,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 40 "__id__": 46
}, },
"playOnLoad": false, "playOnLoad": false,
"_clips": [ "_clips": [
@ -862,7 +997,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 43 "__id__": 49
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@ -890,7 +1025,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 45 "__id__": 51
}, },
"_alignFlags": 45, "_alignFlags": 45,
"_target": null, "_target": null,
@ -925,10 +1060,10 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 47 "__id__": 53
}, },
"animation": { "animation": {
"__id__": 39 "__id__": 45
}, },
"closeButton": { "closeButton": {
"__id__": 17 "__id__": 17
@ -941,7 +1076,10 @@
"__expectedType__": "cc.Prefab" "__expectedType__": "cc.Prefab"
}, },
"upgradeButtonParent": { "upgradeButtonParent": {
"__id__": 21 "__id__": 27
},
"goldCoinsLabel": {
"__id__": 24
}, },
"_id": "" "_id": ""
}, },

View File

@ -2,7 +2,7 @@ import { sys } from "cc";
import { UserData } from "../Game/Data/UserData"; import { UserData } from "../Game/Data/UserData";
export class SaveSystem { export class SaveSystem {
private userDataIdentifier = "user-dat"; private userDataIdentifier = "user-da";
public save(userData: UserData): void { public save(userData: UserData): void {
sys.localStorage.setItem(this.userDataIdentifier, JSON.stringify(userData)); sys.localStorage.setItem(this.userDataIdentifier, JSON.stringify(userData));
} }

View File

@ -1,7 +1,7 @@
export class GameSettings { export class GameSettings {
public player: PlayerSettings = new PlayerSettings(); public player: PlayerSettings = new PlayerSettings();
public upgrades: UpgradeSettings = new UpgradeSettings(); public upgrades: UpgradeSettings = new UpgradeSettings();
public metaUpgrades: MetaUpgradeSettings = new MetaUpgradeSettings(); public metaUpgrades: MetaUpgradesSettings = new MetaUpgradesSettings();
public enemyManager: EnemyManagerSettings = new EnemyManagerSettings(); public enemyManager: EnemyManagerSettings = new EnemyManagerSettings();
} }
@ -50,13 +50,18 @@ export class UpgradeSettings {
public maxRegenerationUpgrades = 0; 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 { export class MetaUpgradeSettings {
public healthPointsPerLevel = 0; public costs: number[] = [];
public bonusDamagePerLevel = 0; public bonuses: number[] = [];
public projectilePiercingPerLevel = 0;
public movementSpeedPerLevel = 0;
public xpBonusPerLevel = 0;
public goldBonusPerLevel = 0;
} }
export class EnemyManagerSettings { export class EnemyManagerSettings {

View File

@ -11,8 +11,8 @@ export class GameData {
} }
export class MetaUpgradesData { export class MetaUpgradesData {
public maxHpLevel = 0; public healthLevel = 0;
public bonusDamageLevel = 2; public overallDamageLevel = 2;
public projectilePiercingLevel = 0; public projectilePiercingLevel = 0;
public movementSpeedLevel = 0; public movementSpeedLevel = 0;
public xpGathererLevel = 0; public xpGathererLevel = 0;

View File

@ -142,7 +142,7 @@ export class Game extends Component {
private createPlayerData(settings: PlayerSettings, metaUpgrades: MetaUpgrades): PlayerData { private createPlayerData(settings: PlayerSettings, metaUpgrades: MetaUpgrades): PlayerData {
const playerData: PlayerData = Object.assign(new PlayerData(), settings); 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.requiredXP = settings.requiredXP;
playerData.speed = metaUpgrades.getUpgradeValue(MetaUpgradeType.MovementSpeed) + settings.speed; playerData.speed = metaUpgrades.getUpgradeValue(MetaUpgradeType.MovementSpeed) + settings.speed;
playerData.regenerationDelay = settings.regenerationDelay; playerData.regenerationDelay = settings.regenerationDelay;

View File

@ -24,8 +24,8 @@ export class TestGameRunner extends Component {
while (Game.Instance == null || AppRoot.Instance == null) await delay(100); while (Game.Instance == null || AppRoot.Instance == null) await delay(100);
const testUserData = new UserData(); const testUserData = new UserData();
testUserData.game.metaUpgrades.maxHpLevel = this.maxHpLevel; testUserData.game.metaUpgrades.healthLevel = this.maxHpLevel;
testUserData.game.metaUpgrades.bonusDamageLevel = this.bonusDamageLevel; testUserData.game.metaUpgrades.overallDamageLevel = this.bonusDamageLevel;
testUserData.game.metaUpgrades.projectilePiercingLevel = this.projectilePiercingLevel; testUserData.game.metaUpgrades.projectilePiercingLevel = this.projectilePiercingLevel;
testUserData.game.metaUpgrades.movementSpeedLevel = this.movementSpeedLevel; testUserData.game.metaUpgrades.movementSpeedLevel = this.movementSpeedLevel;
testUserData.game.metaUpgrades.xpGathererLevel = this.xpGathererLevel; testUserData.game.metaUpgrades.xpGathererLevel = this.xpGathererLevel;

View File

@ -1,16 +1,26 @@
import { MetaUpgradeSettings } from "../../Data/GameSettings"; import { MetaUpgradesSettings } from "../../Data/GameSettings";
import { MetaUpgradesData } from "../../Data/UserData"; import { MetaUpgradesData } from "../../Data/UserData";
import { MetaUpgradeType } from "../../Upgrades/UpgradeType"; import { MetaUpgradeType } from "../../Upgrades/UpgradeType";
export class MetaUpgrades { export class MetaUpgrades {
private upgradeTypeToValue = new Map<MetaUpgradeType, number>(); private upgradeTypeToValue = new Map<MetaUpgradeType, number>();
public constructor(data: MetaUpgradesData, settings: MetaUpgradeSettings) { public constructor(data: MetaUpgradesData, settings: MetaUpgradesSettings) {
this.upgradeTypeToValue.set(MetaUpgradeType.MaxHp, data.maxHpLevel * settings.healthPointsPerLevel); this.upgradeTypeToValue.set(MetaUpgradeType.Health, this.getBonusValue(data.healthLevel, settings.health.bonuses));
this.upgradeTypeToValue.set(MetaUpgradeType.OverallDamage, data.bonusDamageLevel * settings.bonusDamagePerLevel); this.upgradeTypeToValue.set(MetaUpgradeType.OverallDamage, this.getBonusValue(data.overallDamageLevel, settings.overallDamage.bonuses));
this.upgradeTypeToValue.set(MetaUpgradeType.ProjectilePiercing, data.projectilePiercingLevel * settings.projectilePiercingPerLevel); this.upgradeTypeToValue.set(
this.upgradeTypeToValue.set(MetaUpgradeType.MovementSpeed, data.movementSpeedLevel * settings.movementSpeedPerLevel); MetaUpgradeType.ProjectilePiercing,
this.upgradeTypeToValue.set(MetaUpgradeType.XPGatherer, data.xpGathererLevel * settings.xpBonusPerLevel); this.getBonusValue(data.projectilePiercingLevel, settings.projectilePiercing.bonuses)
this.upgradeTypeToValue.set(MetaUpgradeType.GoldGatherer, data.goldGathererLevel * settings.goldBonusPerLevel); );
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 { public getUpgradeValue(type: MetaUpgradeType): number {

View File

@ -8,10 +8,10 @@ export enum UpgradeType {
} }
export enum MetaUpgradeType { export enum MetaUpgradeType {
MaxHp, Health = "META_HEALTH",
OverallDamage, OverallDamage = "META_OVERALL_DAMAGE",
ProjectilePiercing, ProjectilePiercing = "META_PROJECTILE_PIERCING",
MovementSpeed, MovementSpeed = "META_MOVEMENT_SPEED",
XPGatherer, XPGatherer = "META_XP_GATHERER",
GoldGatherer GoldGatherer = "META_GOLD_GATHERER"
} }

View File

@ -1,4 +1,8 @@
import { Component, instantiate, Label, Node, Prefab, _decorator } from "cc"; 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"; import { UpgradeLevelPointUI } from "./UpgradeLevelPointUI";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ -10,8 +14,8 @@ export class UpgradeUI extends Component {
@property(Label) private description: Label; @property(Label) private description: Label;
@property(Label) private cost: Label; @property(Label) private cost: Label;
public init(titleText: string, descriptionText: string, levels: number): void { public init(upgradeType: MetaUpgradeType, upgradeSettings: MetaUpgradeSettings, level: number, translationData: TranslationData): void {
for (let i = 0; i < levels; i++) { for (let i = 0; i < upgradeSettings.bonuses.length; i++) {
const node: Node = instantiate(this.levelPointPrefab); const node: Node = instantiate(this.levelPointPrefab);
node.setParent(this.levelPointsParent); node.setParent(this.levelPointsParent);
@ -22,8 +26,8 @@ export class UpgradeUI extends Component {
} }
} }
this.title.string = titleText; this.title.string = `${translationData[`${upgradeType}_TITLE`]}`;
this.description.string = descriptionText; this.description.string = formatString(`${translationData[`${upgradeType}_DESC`]}`, [upgradeSettings.bonuses[level].toString()]);
this.cost.string = "55"; this.cost.string = upgradeSettings.costs[level].toString();
} }
} }

View File

@ -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 { ModalWindow } from "../../../Services/ModalWindowSystem/ModalWindow";
import { UpgradeUI } from "./UpgradeUI"; import { UpgradeUI } from "./UpgradeUI";
@ -6,15 +10,32 @@ const { ccclass, property } = _decorator;
@ccclass("UpgradesModalWindow") @ccclass("UpgradesModalWindow")
export class UpgradesModalWindow extends ModalWindow<Empty, Empty> { export class UpgradesModalWindow extends ModalWindow<Empty, Empty> {
@property(Prefab) upgradeButtonPrefab: Prefab; @property(Prefab) private upgradeButtonPrefab: Prefab;
@property(Node) upgradeButtonParent: Node; @property(Node) private upgradeButtonParent: Node;
@property(Label) private goldCoinsLabel: Label;
public setup(params: Empty): void { private gameData: GameData;
for (let index = 0; index < 6; index++) {
const upgradeButton: Node = instantiate(this.upgradeButtonPrefab); public setup(): void {
upgradeButton.getComponent(UpgradeUI).init("Title", "Description", 5); this.gameData = AppRoot.Instance.SaveSystem.load().game;
upgradeButton.setParent(this.upgradeButtonParent);
} 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);
} }
} }

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

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "ceda74cb-8b1e-4bd3-9cfb-0bbf0315fc40",
"files": [],
"subMetas": {},
"userData": {}
}