diff --git a/assets/Scenes/Menu.scene b/assets/Scenes/Menu.scene index 552b3d6..ef67449 100644 --- a/assets/Scenes/Menu.scene +++ b/assets/Scenes/Menu.scene @@ -24,11 +24,11 @@ "_active": true, "_components": [], "_prefab": { - "__id__": 94 + "__id__": 102 }, "autoReleaseAssets": false, "_globals": { - "__id__": 95 + "__id__": 103 }, "_id": "1a3bccb5-bbb7-4058-846c-ed41b52415b0" }, @@ -342,24 +342,27 @@ }, { "__id__": 86 + }, + { + "__id__": 89 } ], "_active": true, "_components": [ { - "__id__": 89 + "__id__": 97 }, { - "__id__": 90 + "__id__": 98 }, { - "__id__": 91 + "__id__": 99 }, { - "__id__": 92 + "__id__": 100 }, { - "__id__": 93 + "__id__": 101 } ], "_prefab": null, @@ -2719,6 +2722,293 @@ "_atlas": null, "_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", "_name": "", @@ -2800,11 +3090,17 @@ "upgradeAvailableIndicator": { "__id__": 66 }, + "goldCounter": { + "__id__": 89 + }, + "goldLabel": { + "__id__": 95 + }, "audioSettingsBtn": { "__id__": 81 }, "menuCanvas": { - "__id__": 90 + "__id__": 98 }, "highscoreLabel": { "__id__": 85 @@ -2845,19 +3141,19 @@ { "__type__": "cc.SceneGlobals", "ambient": { - "__id__": 96 + "__id__": 104 }, "shadows": { - "__id__": 97 + "__id__": 105 }, "_skybox": { - "__id__": 98 + "__id__": 106 }, "fog": { - "__id__": 99 + "__id__": 107 }, "octree": { - "__id__": 100 + "__id__": 108 } }, { diff --git a/assets/Scripts/Menu/Menu.ts b/assets/Scripts/Menu/Menu.ts index 2523e7c..daf3d98 100644 --- a/assets/Scripts/Menu/Menu.ts +++ b/assets/Scripts/Menu/Menu.ts @@ -14,6 +14,8 @@ export class Menu extends Component { @property(UIButton) private playBtn: UIButton; @property(UIButton) private upgradeBtn: UIButton; @property(Node) private upgradeAvailableIndicator: Node; + @property(Node) private goldCounter: Node; + @property(Label) private goldLabel: Label; @property(UIButton) private audioSettingsBtn: UIButton; @property(Canvas) private menuCanvas: Canvas; @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.updateUpgradeIndicator(); + this.updateGoldIndicators(); } - private updateUpgradeIndicator(): void { + private updateGoldIndicators(): void { 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 { @@ -69,7 +75,7 @@ export class Menu extends Component { private async openUpgradesWindow(): Promise { await this.menuModalLauncher.openUpgradesWindow(); - this.updateUpgradeIndicator(); + this.updateGoldIndicators(); } private openAudioSettingsWindow(): void {