From f15f654ac66cbbf54ddb8a52951d4ffe771f7741 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 22 Dec 2022 14:05:31 +0100 Subject: [PATCH] Icons --- assets/Media/Prefabs/AppRoot.prefab | 2 +- .../ModalWindows/LevelUp/LevelUpSkill.prefab | 308 +++++++++++++++++- .../Upgrades/UpgradeButton.prefab | 168 +++++++++- assets/Scripts/AppRoot/AppRoot.ts | 1 + assets/Scripts/AppRoot/SaveSystem.ts | 2 +- assets/Scripts/Game/Data/Assets/GameAssets.ts | 5 + .../Game/UI/LevelUpWindow/LevelUpSkill.ts | 7 +- .../Menu/ModalWindows/Upgrades/UpgradeUI.ts | 5 +- .../Services/AudioPlayer/AudioPlayer.ts | 1 + 9 files changed, 464 insertions(+), 35 deletions(-) diff --git a/assets/Media/Prefabs/AppRoot.prefab b/assets/Media/Prefabs/AppRoot.prefab index 0803de1..77b5810 100644 --- a/assets/Media/Prefabs/AppRoot.prefab +++ b/assets/Media/Prefabs/AppRoot.prefab @@ -248,7 +248,7 @@ "__expectedType__": "cc.AudioClip" }, "_loop": true, - "_playOnAwake": true, + "_playOnAwake": false, "_volume": 1, "_id": "" }, diff --git a/assets/Media/Prefabs/ModalWindows/LevelUp/LevelUpSkill.prefab b/assets/Media/Prefabs/ModalWindows/LevelUp/LevelUpSkill.prefab index f5944e0..e477d66 100644 --- a/assets/Media/Prefabs/ModalWindows/LevelUp/LevelUpSkill.prefab +++ b/assets/Media/Prefabs/ModalWindows/LevelUp/LevelUpSkill.prefab @@ -20,25 +20,31 @@ "_children": [ { "__id__": 2 - } - ], - "_active": true, - "_components": [ + }, { "__id__": 8 }, - { - "__id__": 10 - }, - { - "__id__": 12 - }, { "__id__": 14 } ], + "_active": true, + "_components": [ + { + "__id__": 20 + }, + { + "__id__": 22 + }, + { + "__id__": 24 + }, + { + "__id__": 26 + } + ], "_prefab": { - "__id__": 16 + "__id__": 28 }, "_lpos": { "__type__": "cc.Vec3", @@ -70,7 +76,7 @@ }, { "__type__": "cc.Node", - "_name": "SkillTitle", + "_name": "Title", "_objFlags": 0, "_parent": { "__id__": 1 @@ -200,6 +206,270 @@ }, "fileId": "b23ZKbNTtBGqonQhKULY4F" }, + { + "__type__": "cc.Node", + "_name": "Description", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 9 + }, + { + "__id__": 11 + } + ], + "_prefab": { + "__id__": 13 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 16.532, + "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__": 8 + }, + "_enabled": true, + "__prefab": { + "__id__": 10 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 117.86, + "height": 80 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "5cEiirW8lFMbNYu/3Nqu51" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "__prefab": { + "__id__": 12 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_string": "Increase healthwefwef", + "_horizontalAlign": 1, + "_verticalAlign": 1, + "_actualFontSize": 15, + "_fontSize": 15, + "_fontFamily": "Arial", + "_lineHeight": 20, + "_overflow": 1, + "_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": 1, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "2eMtRyCjtF2a1RNdoIUZs/" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "e2JV80Si1M+JfO9kW6Ga0d" + }, + { + "__type__": "cc.Node", + "_name": "Sprite", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 15 + }, + { + "__id__": 17 + } + ], + "_prefab": { + "__id__": 19 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": -48, + "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__": 14 + }, + "_enabled": true, + "__prefab": { + "__id__": 16 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 26, + "height": 22 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "b0oSTIwV9M3btBKLcJZX+X" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 14 + }, + "_enabled": true, + "__prefab": { + "__id__": 18 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_spriteFrame": { + "__uuid__": "e6f506a9-a7b6-4382-8e34-716df203e7ae@f9941", + "__expectedType__": "cc.SpriteFrame" + }, + "_type": 0, + "_fillType": 0, + "_sizeMode": 1, + "_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": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "df5r3bDyFISqMuUS02/aAs" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "dbYlHctO5I568ZqegDS1AZ" + }, { "__type__": "cc.UITransform", "_name": "", @@ -209,7 +479,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 9 + "__id__": 21 }, "_contentSize": { "__type__": "cc.Size", @@ -236,7 +506,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 11 + "__id__": 23 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -280,7 +550,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 13 + "__id__": 25 }, "playOnLoad": true, "_clips": [ @@ -308,11 +578,17 @@ }, "_enabled": true, "__prefab": { - "__id__": 15 + "__id__": 27 }, "skillTitle": { "__id__": 5 }, + "skillDescription": { + "__id__": 11 + }, + "skillIcon": { + "__id__": 17 + }, "_id": "" }, { diff --git a/assets/Media/Prefabs/ModalWindows/Upgrades/UpgradeButton.prefab b/assets/Media/Prefabs/ModalWindows/Upgrades/UpgradeButton.prefab index b357d9f..34adbda 100644 --- a/assets/Media/Prefabs/ModalWindows/Upgrades/UpgradeButton.prefab +++ b/assets/Media/Prefabs/ModalWindows/Upgrades/UpgradeButton.prefab @@ -32,28 +32,31 @@ }, { "__id__": 26 + }, + { + "__id__": 32 } ], "_active": true, "_components": [ { - "__id__": 32 - }, - { - "__id__": 34 - }, - { - "__id__": 36 + "__id__": 38 }, { "__id__": 40 }, { - "__id__": 38 + "__id__": 42 + }, + { + "__id__": 46 + }, + { + "__id__": 44 } ], "_prefab": { - "__id__": 42 + "__id__": 48 }, "_lpos": { "__type__": "cc.Vec3", @@ -733,6 +736,138 @@ }, "fileId": "69ItV8RjNK0LBrhjv1o0Iu" }, + { + "__type__": "cc.Node", + "_name": "Icon", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 33 + }, + { + "__id__": 35 + } + ], + "_prefab": { + "__id__": 37 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 25.234, + "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__": 32 + }, + "_enabled": true, + "__prefab": { + "__id__": 34 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 16, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "f19c9B7K5Efo2QTH+f0fvq" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 32 + }, + "_enabled": true, + "__prefab": { + "__id__": 36 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_spriteFrame": { + "__uuid__": "1ad27e7b-edee-48c1-8e87-90bd16039dc1@f9941", + "__expectedType__": "cc.SpriteFrame" + }, + "_type": 0, + "_fillType": 0, + "_sizeMode": 1, + "_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": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "24NFMgic5FZIkT8040WkWI" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "8dK6A1v6BCg571nXx6pyVq" + }, { "__type__": "cc.UITransform", "_name": "", @@ -742,7 +877,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 33 + "__id__": 39 }, "_contentSize": { "__type__": "cc.Size", @@ -769,7 +904,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 35 + "__id__": 41 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -813,7 +948,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 37 + "__id__": 43 }, "levelPointPrefab": { "__uuid__": "41ca6952-fa32-4e38-8d43-eec2e982533c", @@ -834,8 +969,11 @@ "maxLevel": { "__id__": 23 }, + "icon": { + "__id__": 35 + }, "uiButton": { - "__id__": 38 + "__id__": 44 }, "_id": "" }, @@ -852,7 +990,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 39 + "__id__": 45 }, "_id": "" }, @@ -869,7 +1007,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 41 + "__id__": 47 }, "clickEvents": [], "_interactable": true, diff --git a/assets/Scripts/AppRoot/AppRoot.ts b/assets/Scripts/AppRoot/AppRoot.ts index 7e5b87c..a88d978 100644 --- a/assets/Scripts/AppRoot/AppRoot.ts +++ b/assets/Scripts/AppRoot/AppRoot.ts @@ -65,6 +65,7 @@ export class AppRoot extends Component { const gameAssetsNode = instantiate(this.gameAssetsPrefab); gameAssetsNode.setParent(this.node); this.gameAssets = gameAssetsNode.getComponent(GameAssets); + this.gameAssets.init(); this.audio.init(this.LiveUserData.soundVolume, this.LiveUserData.musicVolume); } diff --git a/assets/Scripts/AppRoot/SaveSystem.ts b/assets/Scripts/AppRoot/SaveSystem.ts index 068deb2..c721ce6 100644 --- a/assets/Scripts/AppRoot/SaveSystem.ts +++ b/assets/Scripts/AppRoot/SaveSystem.ts @@ -2,7 +2,7 @@ import { sys } from "cc"; import { UserData } from "../Game/Data/UserData"; export class SaveSystem { - private userDataIdentifier = "user-de"; + private userDataIdentifier = "user-dse"; public save(userData: UserData): void { sys.localStorage.setItem(this.userDataIdentifier, JSON.stringify(userData)); } diff --git a/assets/Scripts/Game/Data/Assets/GameAssets.ts b/assets/Scripts/Game/Data/Assets/GameAssets.ts index 9244f63..1b11b69 100644 --- a/assets/Scripts/Game/Data/Assets/GameAssets.ts +++ b/assets/Scripts/Game/Data/Assets/GameAssets.ts @@ -10,6 +10,11 @@ export class GameAssets extends Component { @property(MetaUpgradeIcons) private metaUpgradeIcons: MetaUpgradeIcons; @property(AudioAssets) private audioAssets: AudioAssets; + public init(): void { + this.upgradeIcons.init(); + this.metaUpgradeIcons.init(); + } + public get UpgradeIcons(): UpgradeIcons { return this.upgradeIcons; } diff --git a/assets/Scripts/Game/UI/LevelUpWindow/LevelUpSkill.ts b/assets/Scripts/Game/UI/LevelUpWindow/LevelUpSkill.ts index 4e2e1f0..f6e511b 100644 --- a/assets/Scripts/Game/UI/LevelUpWindow/LevelUpSkill.ts +++ b/assets/Scripts/Game/UI/LevelUpWindow/LevelUpSkill.ts @@ -1,4 +1,5 @@ -import { Component, Label, NodeEventType, _decorator } from "cc"; +import { approx, Component, Label, NodeEventType, Sprite, _decorator } from "cc"; +import { AppRoot } from "../../../AppRoot/AppRoot"; import { ISignal } from "../../../Services/EventSystem/ISignal"; import { Signal } from "../../../Services/EventSystem/Signal"; import { TranslationData } from "../../Data/TranslationData"; @@ -8,12 +9,16 @@ const { ccclass, property } = _decorator; @ccclass("LevelUpSkill") export class LevelUpSkill extends Component { @property(Label) private skillTitle: Label; + @property(Label) private skillDescription: Label; + @property(Sprite) private skillIcon: Sprite; private chooseSkillEvent: Signal = new Signal(); private skillType: UpgradeType; public init(skillType: UpgradeType, translationData: TranslationData): void { this.skillType = skillType; this.skillTitle.string = `${translationData[`${skillType}_TITLE`]}`; + this.skillDescription.string = `${translationData[`${skillType}_DESC`]}`; + this.skillIcon.spriteFrame = AppRoot.Instance.GameAssets.UpgradeIcons.getIcon(skillType); this.node.on(NodeEventType.TOUCH_START, this.chooseSkill, this); } diff --git a/assets/Scripts/Menu/ModalWindows/Upgrades/UpgradeUI.ts b/assets/Scripts/Menu/ModalWindows/Upgrades/UpgradeUI.ts index 4927eb4..a745879 100644 --- a/assets/Scripts/Menu/ModalWindows/Upgrades/UpgradeUI.ts +++ b/assets/Scripts/Menu/ModalWindows/Upgrades/UpgradeUI.ts @@ -1,4 +1,5 @@ -import { Component, instantiate, Label, Node, Prefab, _decorator } from "cc"; +import { Component, instantiate, Label, Node, Prefab, Sprite, _decorator } from "cc"; +import { AppRoot } from "../../../AppRoot/AppRoot"; import { MetaUpgradeSettings } from "../../../Game/Data/GameSettings"; import { TranslationData } from "../../../Game/Data/TranslationData"; import { MetaUpgradeType } from "../../../Game/Upgrades/UpgradeType"; @@ -17,6 +18,7 @@ export class UpgradeUI extends Component { @property(Label) private description: Label; @property(Label) private cost: Label; @property(Label) private maxLevel: Label; + @property(Sprite) private icon: Sprite; @property(UIButton) private uiButton: UIButton; @@ -33,6 +35,7 @@ export class UpgradeUI extends Component { this.upgradeSettings = upgradeSettings; this.translationData = translationData; + this.icon.spriteFrame = AppRoot.Instance.GameAssets.MetaUpgradeIcons.getIcon(upgradeType); this.title.string = `${translationData[`${upgradeType}_TITLE`]}`; this.uiButton.InteractedEvent.on(() => this.interactedEvent.trigger(upgradeType), this); diff --git a/assets/Scripts/Services/AudioPlayer/AudioPlayer.ts b/assets/Scripts/Services/AudioPlayer/AudioPlayer.ts index ca271f3..856ce00 100644 --- a/assets/Scripts/Services/AudioPlayer/AudioPlayer.ts +++ b/assets/Scripts/Services/AudioPlayer/AudioPlayer.ts @@ -32,6 +32,7 @@ export class AudioPlayer extends Component { } public playMusic(clip: AudioClip): void { + this.musicSource.stop(); this.musicSource.clip = clip; this.musicSource.play(); }