mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-10-09 00:26:11 +00:00
update
This commit is contained in:
42
JisolGameCocos/assets/script/AppData.ts
Normal file
42
JisolGameCocos/assets/script/AppData.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import SystemBase from "../../extensions/ngame/assets/ngame/system/SystemBase";
|
||||
import { app } from "./App";
|
||||
import { API, NewsContext, PlayerInfoOV } from "./consts/API";
|
||||
|
||||
|
||||
//数据类 (用于初始化游戏信息)
|
||||
export class AppData extends SystemBase{
|
||||
|
||||
static loading = "AppData";
|
||||
|
||||
//玩家信息
|
||||
static PLAYER_INFO:string = "PLAYER_INFO";
|
||||
|
||||
get loadings():{[key:string]:Function}{
|
||||
return {
|
||||
[AppData.PLAYER_INFO]:API.GetPlayerInfo, //玩家信息
|
||||
}
|
||||
}
|
||||
|
||||
data:{[key:string]:any} = {};
|
||||
|
||||
async onInit(): Promise<any> {
|
||||
|
||||
app.loading.setCurrent(AppData.loading);
|
||||
|
||||
//加载信息
|
||||
let keys = Object.keys(this.loadings);
|
||||
for (let index = 0; index < keys.length; index++) {
|
||||
this.data[keys[index]] = (await this.loadings[keys[index]]());
|
||||
}
|
||||
|
||||
app.loading.ok(AppData.loading);
|
||||
|
||||
}
|
||||
|
||||
//获取玩家信息
|
||||
getPlayerInfo():PlayerInfoOV{
|
||||
return this.data[AppData.PLAYER_INFO];
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user