mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 16:46:00 +00:00
Data holders, audio
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Component, director, JsonAsset, _decorator } from "cc";
|
||||
import { Component, director, instantiate, JsonAsset, Prefab, _decorator } from "cc";
|
||||
import { GameSettings } from "../Game/Data/GameSettings";
|
||||
import { GameAssets } from "../Game/Data/Assets/GameAssets";
|
||||
import { TranslationData } from "../Game/Data/TranslationData";
|
||||
import { UserData } from "../Game/Data/UserData";
|
||||
import { AudioPlayer } from "../Services/AudioPlayer/AudioPlayer";
|
||||
@@ -11,11 +12,13 @@ export class AppRoot extends Component {
|
||||
@property(AudioPlayer) private audio: AudioPlayer;
|
||||
@property(JsonAsset) private settingsAsset: JsonAsset;
|
||||
@property(JsonAsset) private engTranslationAsset: JsonAsset;
|
||||
@property(Prefab) private gameAssetsPrefab: Prefab;
|
||||
|
||||
private static instance: AppRoot;
|
||||
private saveSystem: SaveSystem;
|
||||
|
||||
private liveUserData: UserData;
|
||||
private gameAssets: GameAssets;
|
||||
|
||||
public static get Instance(): AppRoot {
|
||||
return this.instance;
|
||||
@@ -25,6 +28,10 @@ export class AppRoot extends Component {
|
||||
return this.audio;
|
||||
}
|
||||
|
||||
public get GameAssets(): GameAssets {
|
||||
return this.gameAssets;
|
||||
}
|
||||
|
||||
public get LiveUserData(): UserData {
|
||||
return this.liveUserData;
|
||||
}
|
||||
@@ -55,6 +62,10 @@ export class AppRoot extends Component {
|
||||
this.saveSystem = new SaveSystem();
|
||||
this.liveUserData = this.saveSystem.load();
|
||||
|
||||
const gameAssetsNode = instantiate(this.gameAssetsPrefab);
|
||||
gameAssetsNode.setParent(this.node);
|
||||
this.gameAssets = gameAssetsNode.getComponent(GameAssets);
|
||||
|
||||
this.audio.init(this.LiveUserData.soundVolume, this.LiveUserData.musicVolume);
|
||||
}
|
||||
}
|
||||
|
12
assets/Scripts/Game/Data/Assets.meta
Normal file
12
assets/Scripts/Game/Data/Assets.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "2c68679f-e9d3-4ce0-8e9a-908415d73fc7",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
8
assets/Scripts/Game/Data/Assets/AudioAssets.ts
Normal file
8
assets/Scripts/Game/Data/Assets/AudioAssets.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { AudioClip, Component, _decorator } from "cc";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("AudioAssets")
|
||||
export class AudioAssets extends Component {
|
||||
@property(AudioClip) public buttonClick: AudioClip;
|
||||
}
|
9
assets/Scripts/Game/Data/Assets/AudioAssets.ts.meta
Normal file
9
assets/Scripts/Game/Data/Assets/AudioAssets.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "207935a7-6b2c-4a92-b539-6a7e009ed2e0",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
24
assets/Scripts/Game/Data/Assets/GameAssets.ts
Normal file
24
assets/Scripts/Game/Data/Assets/GameAssets.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { _decorator, Component, Node } from "cc";
|
||||
import { AudioAssets } from "./AudioAssets";
|
||||
import { MetaUpgradeIcons } from "./MetaUpgradeIcons";
|
||||
import { UpgradeIcons } from "./UpgradeIcons";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("GameAssets")
|
||||
export class GameAssets extends Component {
|
||||
@property(UpgradeIcons) private upgradeIcons: UpgradeIcons;
|
||||
@property(MetaUpgradeIcons) private metaUpgradeIcons: MetaUpgradeIcons;
|
||||
@property(AudioAssets) private audioAssets: AudioAssets;
|
||||
|
||||
public get UpgradeIcons(): UpgradeIcons {
|
||||
return this.upgradeIcons;
|
||||
}
|
||||
|
||||
public get MetaUpgradeIcons(): MetaUpgradeIcons {
|
||||
return this.metaUpgradeIcons;
|
||||
}
|
||||
|
||||
public get AudioAssets(): AudioAssets {
|
||||
return this.audioAssets;
|
||||
}
|
||||
}
|
9
assets/Scripts/Game/Data/Assets/GameAssets.ts.meta
Normal file
9
assets/Scripts/Game/Data/Assets/GameAssets.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "564e9e8b-b0dd-47cd-bb36-68ee618732c5",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
30
assets/Scripts/Game/Data/Assets/MetaUpgradeIcons.ts
Normal file
30
assets/Scripts/Game/Data/Assets/MetaUpgradeIcons.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Component, SpriteFrame, _decorator } from "cc";
|
||||
import { MetaUpgradeType, UpgradeType } from "../../Upgrades/UpgradeType";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("MetaUpgradeIcons")
|
||||
export class MetaUpgradeIcons extends Component {
|
||||
@property(SpriteFrame) private healthSprite: SpriteFrame;
|
||||
@property(SpriteFrame) private overallDamageSprite: SpriteFrame;
|
||||
@property(SpriteFrame) private projectilePiercingSprite: SpriteFrame;
|
||||
@property(SpriteFrame) private movementSpeedSprite: SpriteFrame;
|
||||
@property(SpriteFrame) private xpGathererSprite: SpriteFrame;
|
||||
@property(SpriteFrame) private goldGathererSprite: SpriteFrame;
|
||||
|
||||
private typeToIcon = new Map<MetaUpgradeType, SpriteFrame>();
|
||||
|
||||
public init(): void {
|
||||
this.typeToIcon.set(MetaUpgradeType.Health, this.healthSprite);
|
||||
this.typeToIcon.set(MetaUpgradeType.OverallDamage, this.overallDamageSprite);
|
||||
this.typeToIcon.set(MetaUpgradeType.ProjectilePiercing, this.projectilePiercingSprite);
|
||||
this.typeToIcon.set(MetaUpgradeType.MovementSpeed, this.movementSpeedSprite);
|
||||
this.typeToIcon.set(MetaUpgradeType.XPGatherer, this.xpGathererSprite);
|
||||
this.typeToIcon.set(MetaUpgradeType.GoldGatherer, this.goldGathererSprite);
|
||||
}
|
||||
|
||||
public getIcon(upgradeType: MetaUpgradeType): SpriteFrame {
|
||||
if (!this.typeToIcon.has(upgradeType)) throw new Error("Does not have upgrade type asset " + upgradeType);
|
||||
return this.typeToIcon.get(upgradeType);
|
||||
}
|
||||
}
|
9
assets/Scripts/Game/Data/Assets/MetaUpgradeIcons.ts.meta
Normal file
9
assets/Scripts/Game/Data/Assets/MetaUpgradeIcons.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "b18fb120-2466-4e27-ac3e-ead10c683fb4",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
30
assets/Scripts/Game/Data/Assets/UpgradeIcons.ts
Normal file
30
assets/Scripts/Game/Data/Assets/UpgradeIcons.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Component, SpriteFrame, _decorator } from "cc";
|
||||
import { UpgradeType } from "../../Upgrades/UpgradeType";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("UpgradeIcons")
|
||||
export class UpgradeIcons extends Component {
|
||||
@property(SpriteFrame) private weaponLengthSprite: SpriteFrame;
|
||||
@property(SpriteFrame) private weaponDamageSprite: SpriteFrame;
|
||||
@property(SpriteFrame) private horizontalProjectileSprite: SpriteFrame;
|
||||
@property(SpriteFrame) private diagonalProjectileSprite: SpriteFrame;
|
||||
@property(SpriteFrame) private haloProjectileSprite: SpriteFrame;
|
||||
@property(SpriteFrame) private regenerationSprite: SpriteFrame;
|
||||
|
||||
private typeToIcon = new Map<UpgradeType, SpriteFrame>();
|
||||
|
||||
public init(): void {
|
||||
this.typeToIcon.set(UpgradeType.WeaponLength, this.weaponLengthSprite);
|
||||
this.typeToIcon.set(UpgradeType.WeaponDamage, this.weaponDamageSprite);
|
||||
this.typeToIcon.set(UpgradeType.HorizontalProjectile, this.horizontalProjectileSprite);
|
||||
this.typeToIcon.set(UpgradeType.DiagonalProjectile, this.diagonalProjectileSprite);
|
||||
this.typeToIcon.set(UpgradeType.HaloProjectlie, this.haloProjectileSprite);
|
||||
this.typeToIcon.set(UpgradeType.Regeneration, this.regenerationSprite);
|
||||
}
|
||||
|
||||
public getIcon(upgradeType: UpgradeType): SpriteFrame {
|
||||
if (!this.typeToIcon.has(upgradeType)) throw new Error("Does not have upgrade type asset " + upgradeType);
|
||||
return this.typeToIcon.get(upgradeType);
|
||||
}
|
||||
}
|
9
assets/Scripts/Game/Data/Assets/UpgradeIcons.ts.meta
Normal file
9
assets/Scripts/Game/Data/Assets/UpgradeIcons.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c397b888-4efb-45be-ac95-2190293ee6b1",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
import { Camera, Component, KeyCode, Vec2, _decorator } from "cc";
|
||||
import { Camera, Component, KeyCode, Prefab, Vec2, _decorator } from "cc";
|
||||
import { ModalWindowManager } from "../Services/ModalWindowSystem/ModalWindowManager";
|
||||
import { delay } from "../Services/Utils/AsyncUtils";
|
||||
import { GameAudioAdapter } from "./Audio/GameAudioAdapter";
|
||||
|
@@ -42,6 +42,8 @@ export class ProjectileLauncher extends Component implements IProjectileLauncher
|
||||
this.projectilePierces = projectilePierces;
|
||||
|
||||
this.projectilePool = new ObjectPool<Projectile>(this.projectilePrefab, this.node, 6, "Projectile");
|
||||
|
||||
console.log("DAMAGE " + JSON.stringify((<Projectile>this.projectilePrefab.data).Damage));
|
||||
}
|
||||
|
||||
public gameTick(deltaTime: number): void {
|
||||
|
17
assets/Scripts/Utils/UIButtonAudioPlayer.ts
Normal file
17
assets/Scripts/Utils/UIButtonAudioPlayer.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Component, _decorator } from "cc";
|
||||
import { AppRoot } from "../AppRoot/AppRoot";
|
||||
import { UIButton } from "../Services/UI/Button/UIButton";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("UIButtonAudioPlayer")
|
||||
export class UIButtonAudioPlayer extends Component {
|
||||
@property(UIButton) private button: UIButton;
|
||||
public start(): void {
|
||||
this.button.InteractedEvent.on(this.playButtonClick, this);
|
||||
}
|
||||
|
||||
private playButtonClick(): void {
|
||||
const audioClip = AppRoot.Instance.GameAssets.AudioAssets.buttonClick;
|
||||
AppRoot.Instance.AudioPlayer.playSound(audioClip);
|
||||
}
|
||||
}
|
9
assets/Scripts/Utils/UIButtonAudioPlayer.ts.meta
Normal file
9
assets/Scripts/Utils/UIButtonAudioPlayer.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "146cd53d-0b0f-48fa-8b54-552829c02093",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Reference in New Issue
Block a user