mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-26 11:48:54 +00:00
Settings and translation into app root
This commit is contained in:
parent
40ebf267e0
commit
6521ce1f92
@ -66,6 +66,14 @@
|
|||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 3
|
"__id__": 3
|
||||||
},
|
},
|
||||||
|
"settingsAsset": {
|
||||||
|
"__uuid__": "4a156ee8-535e-4443-8bf5-8b979a08d232",
|
||||||
|
"__expectedType__": "cc.JsonAsset"
|
||||||
|
},
|
||||||
|
"engTranslationAsset": {
|
||||||
|
"__uuid__": "7d43843c-0765-427c-9161-2fd9030369c8",
|
||||||
|
"__expectedType__": "cc.JsonAsset"
|
||||||
|
},
|
||||||
"_id": ""
|
"_id": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { _decorator, Component, Node, director, AudioSource } from "cc";
|
import { _decorator, Component, Node, director, AudioSource, JsonAsset } from "cc";
|
||||||
|
import { GameSettings } from "../Game/Data/GameSettings";
|
||||||
|
import { TranslationData } from "../Game/Data/TranslationData";
|
||||||
import { SaveSystem } from "./SaveSystem";
|
import { SaveSystem } from "./SaveSystem";
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@ -6,6 +8,8 @@ const { ccclass, property } = _decorator;
|
|||||||
export class AppRoot extends Component {
|
export class AppRoot extends Component {
|
||||||
@property(AudioSource) private soundSource: AudioSource;
|
@property(AudioSource) private soundSource: AudioSource;
|
||||||
@property(AudioSource) private musicSource: AudioSource;
|
@property(AudioSource) private musicSource: AudioSource;
|
||||||
|
@property(JsonAsset) private settingsAsset: JsonAsset;
|
||||||
|
@property(JsonAsset) private engTranslationAsset: JsonAsset;
|
||||||
|
|
||||||
private static instance: AppRoot;
|
private static instance: AppRoot;
|
||||||
private saveSystem: SaveSystem;
|
private saveSystem: SaveSystem;
|
||||||
@ -18,6 +22,14 @@ export class AppRoot extends Component {
|
|||||||
return this.saveSystem;
|
return this.saveSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get Settings(): GameSettings {
|
||||||
|
return <GameSettings>this.settingsAsset.json;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get TranslationData(): TranslationData {
|
||||||
|
return <TranslationData>this.engTranslationAsset.json;
|
||||||
|
}
|
||||||
|
|
||||||
public start(): void {
|
public start(): void {
|
||||||
if (AppRoot.Instance == null) {
|
if (AppRoot.Instance == null) {
|
||||||
AppRoot.instance = this;
|
AppRoot.instance = this;
|
||||||
|
@ -37,8 +37,6 @@ export class Game extends Component {
|
|||||||
@property(GameUI) private gameUI: GameUI;
|
@property(GameUI) private gameUI: GameUI;
|
||||||
@property(Background) private background: Background;
|
@property(Background) private background: Background;
|
||||||
@property(ModalWindowManager) private modalWindowManager: ModalWindowManager;
|
@property(ModalWindowManager) private modalWindowManager: ModalWindowManager;
|
||||||
@property(JsonAsset) private settingsAsset: JsonAsset;
|
|
||||||
@property(JsonAsset) private translationAsset: JsonAsset;
|
|
||||||
|
|
||||||
private playerCollisionSystem: PlayerCollisionSystem;
|
private playerCollisionSystem: PlayerCollisionSystem;
|
||||||
private haloProjectileLauncher: HaloProjectileLauncher;
|
private haloProjectileLauncher: HaloProjectileLauncher;
|
||||||
@ -59,9 +57,7 @@ export class Game extends Component {
|
|||||||
this.gamePauser.pause();
|
this.gamePauser.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async playGame(userData: UserData): Promise<GameResult> {
|
public async playGame(userData: UserData, settings: GameSettings, translationData: TranslationData): Promise<GameResult> {
|
||||||
const translationData = <TranslationData>this.translationAsset.json;
|
|
||||||
const settings = <GameSettings>this.settingsAsset.json;
|
|
||||||
const metaUpgrades = new MetaUpgrades(userData.game.metaUpgrades, settings.metaUpgrades);
|
const metaUpgrades = new MetaUpgrades(userData.game.metaUpgrades, settings.metaUpgrades);
|
||||||
|
|
||||||
this.virtualJoystic.init();
|
this.virtualJoystic.init();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { CCInteger, Component, _decorator } from "cc";
|
import { approx, CCInteger, Component, _decorator } from "cc";
|
||||||
|
import { AppRoot } from "../AppRoot/AppRoot";
|
||||||
import { GameRunner } from "../Menu/GameRunner";
|
import { GameRunner } from "../Menu/GameRunner";
|
||||||
import { delay } from "../Services/Utils/AsyncUtils";
|
import { delay } from "../Services/Utils/AsyncUtils";
|
||||||
import { UserData } from "./Data/UserData";
|
import { UserData } from "./Data/UserData";
|
||||||
@ -20,7 +21,7 @@ export class TestGameRunner extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async playTestGameAsync(): Promise<void> {
|
public async playTestGameAsync(): Promise<void> {
|
||||||
while (Game.Instance == null) await delay(100);
|
while (Game.Instance == null || AppRoot.Instance == null) await delay(100);
|
||||||
|
|
||||||
const testUserData = new UserData();
|
const testUserData = new UserData();
|
||||||
testUserData.game.metaUpgrades.maxHpLevel = this.maxHpLevel;
|
testUserData.game.metaUpgrades.maxHpLevel = this.maxHpLevel;
|
||||||
@ -29,6 +30,6 @@ export class TestGameRunner extends Component {
|
|||||||
testUserData.game.metaUpgrades.movementSpeedLevel = this.movementSpeedLevel;
|
testUserData.game.metaUpgrades.movementSpeedLevel = this.movementSpeedLevel;
|
||||||
testUserData.game.metaUpgrades.xpGathererLevel = this.xpGathererLevel;
|
testUserData.game.metaUpgrades.xpGathererLevel = this.xpGathererLevel;
|
||||||
testUserData.game.metaUpgrades.goldGathererLevel = this.goldGathererLevel;
|
testUserData.game.metaUpgrades.goldGathererLevel = this.goldGathererLevel;
|
||||||
Game.Instance.playGame(testUserData);
|
Game.Instance.playGame(testUserData, AppRoot.Instance.Settings, AppRoot.Instance.TranslationData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ export class GameRunner {
|
|||||||
director.loadScene("Game");
|
director.loadScene("Game");
|
||||||
const userData: UserData = AppRoot.Instance.SaveSystem.load();
|
const userData: UserData = AppRoot.Instance.SaveSystem.load();
|
||||||
while (Game.Instance == null) await delay(10);
|
while (Game.Instance == null) await delay(10);
|
||||||
const result: GameResult = await Game.Instance.playGame(userData);
|
const result: GameResult = await Game.Instance.playGame(userData, AppRoot.Instance.Settings, AppRoot.Instance.TranslationData);
|
||||||
userData.game.goldCoins += result.goldCoins;
|
userData.game.goldCoins += result.goldCoins;
|
||||||
|
|
||||||
if (userData.game.highscore < result.score) {
|
if (userData.game.highscore < result.score) {
|
||||||
|
Loading…
Reference in New Issue
Block a user