Gold in main menu

This commit is contained in:
Martin 2023-01-12 15:59:35 +01:00
parent a8416732d7
commit 5c2330aa7c
2 changed files with 318 additions and 16 deletions

View File

@ -24,11 +24,11 @@
"_active": true, "_active": true,
"_components": [], "_components": [],
"_prefab": { "_prefab": {
"__id__": 94 "__id__": 102
}, },
"autoReleaseAssets": false, "autoReleaseAssets": false,
"_globals": { "_globals": {
"__id__": 95 "__id__": 103
}, },
"_id": "1a3bccb5-bbb7-4058-846c-ed41b52415b0" "_id": "1a3bccb5-bbb7-4058-846c-ed41b52415b0"
}, },
@ -342,24 +342,27 @@
}, },
{ {
"__id__": 86 "__id__": 86
},
{
"__id__": 89
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 89 "__id__": 97
}, },
{ {
"__id__": 90 "__id__": 98
}, },
{ {
"__id__": 91 "__id__": 99
}, },
{ {
"__id__": 92 "__id__": 100
}, },
{ {
"__id__": 93 "__id__": 101
} }
], ],
"_prefab": null, "_prefab": null,
@ -2719,6 +2722,293 @@
"_atlas": null, "_atlas": null,
"_id": "5aB7OXEtBOBa7DA9DZexHe" "_id": "5aB7OXEtBOBa7DA9DZexHe"
}, },
{
"__type__": "cc.Node",
"_name": "GoldCounter",
"_objFlags": 0,
"_parent": {
"__id__": 22
},
"_children": [
{
"__id__": 90
},
{
"__id__": 93
}
],
"_active": true,
"_components": [
{
"__id__": 96
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -4.065,
"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": "500T8SJ0BChbrLAxpDvYSy"
},
{
"__type__": "cc.Node",
"_name": "GoldSprite",
"_objFlags": 0,
"_parent": {
"__id__": 89
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 91
},
{
"__id__": 92
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": -14.218,
"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": "544vCifotILpJQIV5TEp5a"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 90
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 28,
"height": 28
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": "af+K5Gk6dHSY2tTFpFzZuq"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 90
},
"_enabled": true,
"__prefab": null,
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "d18dd93e-df20-447d-96dd-d4d8e5507d87@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": {
"__uuid__": "c4872559-07b2-44e5-9613-5f22506b1989",
"__expectedType__": "cc.SpriteAtlas"
},
"_id": "55RzZ1utNBALN/Wvb3uQ0m"
},
{
"__type__": "cc.Node",
"_name": "GoldLabel",
"_objFlags": 0,
"_parent": {
"__id__": 89
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 94
},
{
"__id__": 95
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 1.185,
"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": "291vOv8B1NvYKFtVqYUfIq"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 93
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 16.07,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0.5
},
"_id": "0aNj6mP1ZH8ra0gijWpUwS"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 93
},
"_enabled": true,
"__prefab": null,
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 224,
"b": 0,
"a": 255
},
"_string": "0",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 30,
"_fontSize": 30,
"_fontFamily": "Arial",
"_lineHeight": 30,
"_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": "a8NIfeBdNANac8k570jvsJ"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 89
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 80,
"height": 40
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": "3ccBq+Y69GZ4xwb93799iO"
},
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
@ -2800,11 +3090,17 @@
"upgradeAvailableIndicator": { "upgradeAvailableIndicator": {
"__id__": 66 "__id__": 66
}, },
"goldCounter": {
"__id__": 89
},
"goldLabel": {
"__id__": 95
},
"audioSettingsBtn": { "audioSettingsBtn": {
"__id__": 81 "__id__": 81
}, },
"menuCanvas": { "menuCanvas": {
"__id__": 90 "__id__": 98
}, },
"highscoreLabel": { "highscoreLabel": {
"__id__": 85 "__id__": 85
@ -2845,19 +3141,19 @@
{ {
"__type__": "cc.SceneGlobals", "__type__": "cc.SceneGlobals",
"ambient": { "ambient": {
"__id__": 96 "__id__": 104
}, },
"shadows": { "shadows": {
"__id__": 97 "__id__": 105
}, },
"_skybox": { "_skybox": {
"__id__": 98 "__id__": 106
}, },
"fog": { "fog": {
"__id__": 99 "__id__": 107
}, },
"octree": { "octree": {
"__id__": 100 "__id__": 108
} }
}, },
{ {

View File

@ -14,6 +14,8 @@ export class Menu extends Component {
@property(UIButton) private playBtn: UIButton; @property(UIButton) private playBtn: UIButton;
@property(UIButton) private upgradeBtn: UIButton; @property(UIButton) private upgradeBtn: UIButton;
@property(Node) private upgradeAvailableIndicator: Node; @property(Node) private upgradeAvailableIndicator: Node;
@property(Node) private goldCounter: Node;
@property(Label) private goldLabel: Label;
@property(UIButton) private audioSettingsBtn: UIButton; @property(UIButton) private audioSettingsBtn: UIButton;
@property(Canvas) private menuCanvas: Canvas; @property(Canvas) private menuCanvas: Canvas;
@property(Label) private highscoreLabel: Label; @property(Label) private highscoreLabel: Label;
@ -32,11 +34,15 @@ export class Menu extends Component {
this.highscoreLabel.string = `Highscore: ${Math.floor(AppRoot.Instance.LiveUserData.game.highscore)}`; this.highscoreLabel.string = `Highscore: ${Math.floor(AppRoot.Instance.LiveUserData.game.highscore)}`;
this.updateUpgradeIndicator(); this.updateGoldIndicators();
} }
private updateUpgradeIndicator(): void { private updateGoldIndicators(): void {
this.upgradeAvailableIndicator.active = this.isUpgradeAffordable(); this.upgradeAvailableIndicator.active = this.isUpgradeAffordable();
const goldCoins = AppRoot.Instance.LiveUserData.game.goldCoins;
this.goldCounter.active = 0 < goldCoins;
this.goldLabel.string = goldCoins.toString();
} }
private isUpgradeAffordable(): boolean { private isUpgradeAffordable(): boolean {
@ -69,7 +75,7 @@ export class Menu extends Component {
private async openUpgradesWindow(): Promise<void> { private async openUpgradesWindow(): Promise<void> {
await this.menuModalLauncher.openUpgradesWindow(); await this.menuModalLauncher.openUpgradesWindow();
this.updateUpgradeIndicator(); this.updateGoldIndicators();
} }
private openAudioSettingsWindow(): void { private openAudioSettingsWindow(): void {