This commit is contained in:
Martin
2022-12-22 14:05:31 +01:00
parent 8b2897f38b
commit f15f654ac6
9 changed files with 464 additions and 35 deletions

View File

@@ -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);
}

View File

@@ -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));
}

View File

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

View File

@@ -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<UpgradeType> = new Signal<UpgradeType>();
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);
}

View File

@@ -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);

View File

@@ -32,6 +32,7 @@ export class AudioPlayer extends Component {
}
public playMusic(clip: AudioClip): void {
this.musicSource.stop();
this.musicSource.clip = clip;
this.musicSource.play();
}