mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-25 11:18:54 +00:00
UpgradesModalWindow
This commit is contained in:
parent
4bdc76510b
commit
8b2897f38b
BIN
assets/Media/Audio/Menu/Special_Powerup_09.WAV
Normal file
BIN
assets/Media/Audio/Menu/Special_Powerup_09.WAV
Normal file
Binary file not shown.
14
assets/Media/Audio/Menu/Special_Powerup_09.WAV.meta
Normal file
14
assets/Media/Audio/Menu/Special_Powerup_09.WAV.meta
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "40d2ac89-6719-4d9e-9d15-0b93ac31510f",
|
||||
"files": [
|
||||
".json",
|
||||
".wav"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
@ -24,18 +24,18 @@
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 48
|
||||
},
|
||||
{
|
||||
"__id__": 50
|
||||
},
|
||||
{
|
||||
"__id__": 52
|
||||
},
|
||||
{
|
||||
"__id__": 54
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 54
|
||||
"__id__": 56
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@ -84,14 +84,14 @@
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 43
|
||||
"__id__": 45
|
||||
},
|
||||
{
|
||||
"__id__": 45
|
||||
"__id__": 47
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 47
|
||||
"__id__": 49
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@ -283,17 +283,17 @@
|
||||
"__id__": 12
|
||||
},
|
||||
{
|
||||
"__id__": 20
|
||||
"__id__": 22
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 40
|
||||
"__id__": 42
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 42
|
||||
"__id__": 44
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@ -341,10 +341,13 @@
|
||||
},
|
||||
{
|
||||
"__id__": 17
|
||||
},
|
||||
{
|
||||
"__id__": 19
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 19
|
||||
"__id__": 21
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@ -462,6 +465,26 @@
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "6cKPriiXpMaIUOeMX1Lu+M"
|
||||
},
|
||||
{
|
||||
"__type__": "146cdU9Cw9I+otUVSgpwCCT",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 12
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 20
|
||||
},
|
||||
"button": {
|
||||
"__id__": 17
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "9ffkR9f0JG+Yvnwzrf6VSC"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
@ -481,26 +504,26 @@
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 21
|
||||
"__id__": 23
|
||||
},
|
||||
{
|
||||
"__id__": 27
|
||||
"__id__": 29
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 33
|
||||
},
|
||||
{
|
||||
"__id__": 35
|
||||
},
|
||||
{
|
||||
"__id__": 37
|
||||
},
|
||||
{
|
||||
"__id__": 39
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 39
|
||||
"__id__": 41
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@ -535,20 +558,20 @@
|
||||
"_name": "CoinsLabel",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 20
|
||||
"__id__": 22
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 22
|
||||
"__id__": 24
|
||||
},
|
||||
{
|
||||
"__id__": 24
|
||||
"__id__": 26
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 26
|
||||
"__id__": 28
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@ -583,11 +606,11 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 21
|
||||
"__id__": 23
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 23
|
||||
"__id__": 25
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@ -610,11 +633,11 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 21
|
||||
"__id__": 23
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 25
|
||||
"__id__": 27
|
||||
},
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
@ -667,20 +690,20 @@
|
||||
"_name": "UpgradesParent",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 20
|
||||
"__id__": 22
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 28
|
||||
"__id__": 30
|
||||
},
|
||||
{
|
||||
"__id__": 30
|
||||
"__id__": 32
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 32
|
||||
"__id__": 34
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@ -715,11 +738,11 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 27
|
||||
"__id__": 29
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 29
|
||||
"__id__": 31
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@ -742,11 +765,11 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 27
|
||||
"__id__": 29
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 31
|
||||
"__id__": 33
|
||||
},
|
||||
"_resizeMode": 1,
|
||||
"_layoutType": 3,
|
||||
@ -789,11 +812,11 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 20
|
||||
"__id__": 22
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 34
|
||||
"__id__": 36
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@ -816,11 +839,11 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 20
|
||||
"__id__": 22
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 36
|
||||
"__id__": 38
|
||||
},
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
@ -860,11 +883,11 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 20
|
||||
"__id__": 22
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 38
|
||||
"__id__": 40
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
@ -891,7 +914,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 41
|
||||
"__id__": 43
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@ -928,7 +951,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 44
|
||||
"__id__": 46
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@ -955,7 +978,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 46
|
||||
"__id__": 48
|
||||
},
|
||||
"playOnLoad": false,
|
||||
"_clips": [
|
||||
@ -997,7 +1020,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 49
|
||||
"__id__": 51
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@ -1025,7 +1048,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 51
|
||||
"__id__": 53
|
||||
},
|
||||
"_alignFlags": 45,
|
||||
"_target": null,
|
||||
@ -1060,10 +1083,10 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 53
|
||||
"__id__": 55
|
||||
},
|
||||
"animation": {
|
||||
"__id__": 45
|
||||
"__id__": 47
|
||||
},
|
||||
"closeButton": {
|
||||
"__id__": 17
|
||||
@ -1076,10 +1099,14 @@
|
||||
"__expectedType__": "cc.Prefab"
|
||||
},
|
||||
"upgradeButtonParent": {
|
||||
"__id__": 27
|
||||
"__id__": 29
|
||||
},
|
||||
"goldCoinsLabel": {
|
||||
"__id__": 24
|
||||
"__id__": 26
|
||||
},
|
||||
"upgradeAudioClip": {
|
||||
"__uuid__": "40d2ac89-6719-4d9e-9d15-0b93ac31510f",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
|
@ -2,7 +2,7 @@ import { sys } from "cc";
|
||||
import { UserData } from "../Game/Data/UserData";
|
||||
|
||||
export class SaveSystem {
|
||||
private userDataIdentifier = "user-d";
|
||||
private userDataIdentifier = "user-de";
|
||||
public save(userData: UserData): void {
|
||||
sys.localStorage.setItem(this.userDataIdentifier, JSON.stringify(userData));
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
export class UserData {
|
||||
public soundVolume = 0;
|
||||
public musicVolume = 0;
|
||||
public soundVolume = 1;
|
||||
public musicVolume = 1;
|
||||
public game = new GameData();
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { instantiate, Label, Node, Prefab, TiledUserNodeData, _decorator } from "cc";
|
||||
import { AudioClip, instantiate, Label, Node, Prefab, _decorator } from "cc";
|
||||
import { AppRoot } from "../../../AppRoot/AppRoot";
|
||||
import { MetaUpgradeSettings } from "../../../Game/Data/GameSettings";
|
||||
import { UserData, GameData, MetaUpgradesData } from "../../../Game/Data/UserData";
|
||||
import { MetaUpgradeType, UpgradeType } from "../../../Game/Upgrades/UpgradeType";
|
||||
import { MetaUpgradesData, UserData } from "../../../Game/Data/UserData";
|
||||
import { MetaUpgradeType } from "../../../Game/Upgrades/UpgradeType";
|
||||
import { ModalWindow } from "../../../Services/ModalWindowSystem/ModalWindow";
|
||||
import { UpgradeUI } from "./UpgradeUI";
|
||||
|
||||
@ -13,6 +13,7 @@ export class UpgradesModalWindow extends ModalWindow<Empty, Empty> {
|
||||
@property(Prefab) private upgradeButtonPrefab: Prefab;
|
||||
@property(Node) private upgradeButtonParent: Node;
|
||||
@property(Label) private goldCoinsLabel: Label;
|
||||
@property(AudioClip) private upgradeAudioClip: AudioClip;
|
||||
|
||||
private typeToLevel = new Map<MetaUpgradeType, number>();
|
||||
private typeToCosts = new Map<MetaUpgradeType, number[]>();
|
||||
@ -62,12 +63,15 @@ export class UpgradesModalWindow extends ModalWindow<Empty, Empty> {
|
||||
if (costs.length <= currentLevel) return; // already max level
|
||||
if (this.userData.game.goldCoins < costs[currentLevel]) return; // not enough gold
|
||||
|
||||
AppRoot.Instance.AudioPlayer.playSound(this.upgradeAudioClip);
|
||||
|
||||
this.userData.game.goldCoins -= costs[currentLevel];
|
||||
const level = ++this.userData.game.metaUpgrades[this.typeToLevelKey.get(upgradeType)];
|
||||
this.typeToUpgradeUI.get(upgradeType).updateLevel(level);
|
||||
this.typeToLevel.set(upgradeType, level);
|
||||
|
||||
this.goldCoinsLabel.string = this.userData.game.goldCoins.toString();
|
||||
AppRoot.Instance.saveUserData;
|
||||
AppRoot.Instance.saveUserData();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user