|
|
@@ -18,9 +18,11 @@ export class GameData {
|
|
|
|
|
|
public configs: any = {};
|
|
|
/** 功能开启 */
|
|
|
- public funOpenData:string[] = [];
|
|
|
+ public funOpenData: string[] = [];
|
|
|
|
|
|
- public gameData: PlayerInfoType;
|
|
|
+ public gameData: PlayerProp = null;
|
|
|
+ /** 标志位:刷新主界面货币 */
|
|
|
+ public init_coin: boolean = false;
|
|
|
|
|
|
public props: Map<number, number>;
|
|
|
|
|
|
@@ -31,12 +33,13 @@ export class GameData {
|
|
|
|
|
|
/** 主页样式脚本 */
|
|
|
public gameStyle: Game = null;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 初始化游戏数据:网络配置信息,用户信息
|
|
|
* @returns
|
|
|
*/
|
|
|
public async init() {
|
|
|
+
|
|
|
let data: any = { "versionCode": gData.appData.version };
|
|
|
let response = await mk.http.sendData('getAllConfigInfo', data);
|
|
|
if (response.errcode != 0) {
|
|
|
@@ -46,7 +49,7 @@ export class GameData {
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
- mk.console.logSingle("getAllConfigInfo",response.data)
|
|
|
+ mk.console.logSingle("getAllConfigInfo", response.data)
|
|
|
this.initConfigs(response.data);
|
|
|
|
|
|
data = {};
|
|
|
@@ -54,8 +57,8 @@ export class GameData {
|
|
|
if (response.errcode != 0) {
|
|
|
return;
|
|
|
}
|
|
|
- mk.console.logSingle("getInfoCrypt",response.data)
|
|
|
- this.gameData = response.data;
|
|
|
+ mk.console.logSingle("getInfoCrypt", response.data)
|
|
|
+ this.initPlayerProp(response.data)
|
|
|
|
|
|
if (this.props == null) {
|
|
|
this.props = new Map<number, number>();
|
|
|
@@ -69,12 +72,34 @@ export class GameData {
|
|
|
this.dataFinish = true;
|
|
|
}
|
|
|
|
|
|
- private initConfigs(data){
|
|
|
+ private initConfigs(data) {
|
|
|
this.configs = data;
|
|
|
this.funOpenData = this.configs.ServerConfig.Functionswitch.split(",");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 初始化玩家数据
|
|
|
+ */
|
|
|
+ private initPlayerProp(res_data) {
|
|
|
+ this.gameData = new PlayerProp();
|
|
|
+ this.gameData.cashIndex = res_data.cashIndex;
|
|
|
+ this.gameData.gameUserData = res_data.gameUserData;
|
|
|
+ this.gameData.isSignInToday = res_data.isSignInToday;
|
|
|
+ this.gameData.isWithdrawable = res_data.isWithdrawable;
|
|
|
+ this.gameData.lastTime = res_data.lastTime;
|
|
|
+ this.gameData.loginDays = res_data.loginDays;
|
|
|
+ this.gameData.newPlayer = res_data.newPlayer;
|
|
|
+ this.gameData.piggyBank = res_data.piggyBank;
|
|
|
+ this.gameData.piggyBankCashTimes = res_data.piggyBankCashTimes;
|
|
|
+ this.gameData.redMoney = res_data.redMoney;
|
|
|
+ this.gameData.signInDay = res_data.signInDay;
|
|
|
+ this.gameData.totalPiggyBankCashTimes = res_data.totalPiggyBankCashTimes;
|
|
|
+ this.gameData.turntableTimes = res_data.turntableTimes;
|
|
|
+ this.gameData.userTuCaoInfo = res_data.userTuCaoInfo;
|
|
|
+ this.gameData.versioncfg = res_data.versioncfg;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 保存单个数据
|
|
|
*/
|
|
|
public async setProp(key: GameProp, value: number) {
|
|
|
@@ -175,6 +200,58 @@ export enum GameProp {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 玩家数据
|
|
|
+ */
|
|
|
+class PlayerProp {
|
|
|
+ /** 自定义不需要校验的数据 */
|
|
|
+ gameUserData = 0;
|
|
|
+ /** 今日是否有签到 */
|
|
|
+ isSignInToday = 0;
|
|
|
+
|
|
|
+ private _piggyBank: number = 0;
|
|
|
+ /** 存钱罐存款 */
|
|
|
+ set piggyBank(value: number) {
|
|
|
+ this._piggyBank = value;
|
|
|
+ gData.gameData.init_coin = true;
|
|
|
+ }
|
|
|
+ get piggyBank(): number {
|
|
|
+ return this._piggyBank;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 存钱罐能否提现 */
|
|
|
+ isWithdrawable = 0;
|
|
|
+ /** 存钱罐每日提现次数 */
|
|
|
+ piggyBankCashTimes = 0;
|
|
|
+ /** 累计存钱罐每日提现次数 */
|
|
|
+ totalPiggyBankCashTimes = 0;
|
|
|
+ /** 提现进度 */
|
|
|
+ cashIndex = 0;
|
|
|
+ /** 上次登录时间 */
|
|
|
+ lastTime = 0;
|
|
|
+ /** 登录天数 */
|
|
|
+ loginDays = 0;
|
|
|
+ newPlayer = 0;
|
|
|
+
|
|
|
+ private _redMoney: number = 0;
|
|
|
+ /** 红包币数量 */
|
|
|
+ set redMoney(value: number) {
|
|
|
+ this._redMoney = value;
|
|
|
+ gData.gameData.init_coin = true;
|
|
|
+ }
|
|
|
+ get redMoney(): number {
|
|
|
+ return this._redMoney;
|
|
|
+ }
|
|
|
+ /** 累计签到次数 客户端理解 上次签到天数 */
|
|
|
+ signInDay = 0;
|
|
|
+ /** 转盘次数 */
|
|
|
+ turntableTimes = 0;
|
|
|
+ /** 版本号 */
|
|
|
+ versioncfg = 0;
|
|
|
+ /** 福袋数据 */
|
|
|
+ userTuCaoInfo = 0;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
* 奖励状态
|
|
|
*/
|
|
|
export enum RewardState {
|
|
|
@@ -203,23 +280,23 @@ export enum RewardType {
|
|
|
*/
|
|
|
export enum AUDIO_TYPE {
|
|
|
/**主界面背景音乐*/
|
|
|
- bgm = 'bgm',
|
|
|
+ bgm = 'bgm',
|
|
|
/**打开存钱罐界面播放一次*/
|
|
|
- pigBank = 'pigBank',
|
|
|
+ pigBank = 'pigBank',
|
|
|
/**关卡玩法背景音乐*/
|
|
|
- missionBg = 'missionBg',
|
|
|
+ missionBg = 'missionBg',
|
|
|
/**红包币领取界面关闭音效*/
|
|
|
- rewardClose = 'rewardClose',
|
|
|
+ rewardClose = 'rewardClose',
|
|
|
/**红包币领取界面开启音效*/
|
|
|
- rewardOpen = 'rewardOpen',
|
|
|
+ rewardOpen = 'rewardOpen',
|
|
|
/**红包界面打开音效*/
|
|
|
- reward = 'reward',
|
|
|
+ reward = 'reward',
|
|
|
/**提现到账界面打开播放一次*/
|
|
|
- receiptNotice = 'receiptNotice',
|
|
|
+ receiptNotice = 'receiptNotice',
|
|
|
/**通用按钮点击音效 */
|
|
|
- button = 'button',
|
|
|
+ button = 'button',
|
|
|
/**转盘转动音效*/
|
|
|
- turnableplay = 'turnableplay',
|
|
|
+ turnableplay = 'turnableplay',
|
|
|
/**主页背景音乐 */
|
|
|
music_startBg = "music_startBg",
|
|
|
/**游戏背景音乐 */
|