155 lines
5.2 KiB
TypeScript
155 lines
5.2 KiB
TypeScript
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
@ccclass('GameConfig')
|
|
export class GameConfig {
|
|
//所有控制信息都通过GameAppStart内控制
|
|
private static _instance : GameConfig = null;
|
|
//用于盛放埋点数据上传,每次上传后清空
|
|
static GM_INFO: {
|
|
// isEnd: false,
|
|
mean_Time: number; //平均放箭速度
|
|
total: number; //总共对的个数
|
|
currSeed: number; //用于随机数种子
|
|
gameId: string; //游戏ID
|
|
userId: number; //用户ID
|
|
guide: boolean; //是否有引导
|
|
url: string; //访问域名
|
|
success: boolean; //用户游戏成功与否
|
|
matchId: any; //用于埋点上传的ID
|
|
custom: number; //用于测试跳关卡
|
|
};
|
|
static CLICK_DATA: {
|
|
type: number; //上传数据类型
|
|
success: boolean; //此局游戏胜负
|
|
round: number; //回合数
|
|
totalSunCount: number; //太阳总数
|
|
movedSunCount: number; //可移动太阳个数
|
|
sunSpeed: number; //太阳移动速度
|
|
overlapSunCount: number; //重叠太阳个数
|
|
colorList: any[]; //太阳颜色数组
|
|
duration: number; //每次点击的反应时间
|
|
difficultyLevel: number; //此次难度
|
|
sunList: any[]; //太阳数组,用于存放太阳类型 0:普通 1:移动 2:重叠
|
|
stepTimeList: any[]; //每次点击间隔
|
|
remainder: number; //游戏剩余时间
|
|
};
|
|
|
|
static GAME_DATA: any[];
|
|
static LEVEL_INFO: {
|
|
map: number[][]; //地图
|
|
opacity: number; //提示透明度
|
|
moveSpeed: number;//洪水移动速度
|
|
}[];
|
|
|
|
|
|
static get Instance()
|
|
{
|
|
if (this._instance == null)
|
|
{
|
|
this._instance = new GameConfig();
|
|
}
|
|
return this._instance;
|
|
}
|
|
|
|
static init(Authentication){
|
|
this.GM_INFO_init();
|
|
this.CLICK_init();
|
|
this.LEVEL_INFO_init();
|
|
|
|
// cc.resources.load('Json/GM_INFO', (err: any, res: cc.JsonAsset) => {
|
|
// if (err) {
|
|
// this.GM_INFO_init();
|
|
// if(!Authentication) this.Authentication();
|
|
// return;
|
|
// }
|
|
// let jsonData: object = res.json!;
|
|
// this.GM_INFO = jsonData["data"];
|
|
// if(!Authentication) this.Authentication();
|
|
// })
|
|
// cc.resources.load('Json/CLICK_DATA', (err: any, res: cc.JsonAsset) => {
|
|
// if (err) {
|
|
// this.CLICK_init();
|
|
// return;
|
|
// }
|
|
// let jsonData: object = res.json!;
|
|
// this.CLICK_DATA = jsonData["data"];
|
|
// })
|
|
// cc.resources.load('Json/LEVEL_INFO', (err: any, res: cc.JsonAsset) => {
|
|
// if (err) {
|
|
// this.LEVEL_INFO_init();
|
|
// return;
|
|
// }
|
|
// let jsonData: object = res.json!;
|
|
// this.LEVEL_INFO = jsonData["data"];
|
|
// })
|
|
|
|
//GAME_DATA 废弃了,暂时不删除以防后面修改回 一整局传一次
|
|
this.GAME_DATA = [
|
|
]
|
|
}
|
|
|
|
//数据备用
|
|
static GM_INFO_init() {
|
|
this.GM_INFO = {
|
|
// isEnd: false,
|
|
mean_Time: 0, //平均放箭速度
|
|
total: 0, //总共对的个数
|
|
currSeed: 203213, //用于随机数种子
|
|
gameId: '100009', //游戏ID
|
|
userId: 0, //用户ID
|
|
guide: true, //是否有引导
|
|
url: "http://api.sparkus.cn",//访问域名
|
|
success: false, //用户游戏成功与否
|
|
matchId: null, //用于埋点上传的ID
|
|
custom: 0 //用于测试跳关卡
|
|
};
|
|
}
|
|
static CLICK_init() {
|
|
this.CLICK_DATA =
|
|
{
|
|
type: 1, //上传数据类型
|
|
success: false, //此局游戏胜负
|
|
round: 0, //回合数
|
|
totalSunCount: 0, //太阳总数
|
|
movedSunCount: 0, //可移动太阳个数
|
|
sunSpeed: 0, //太阳移动速度
|
|
overlapSunCount: 0, //重叠太阳个数
|
|
colorList: [], //太阳颜色数组
|
|
duration: 0, //每次点击的反应时间
|
|
difficultyLevel: 0, //此次难度
|
|
sunList: [], //太阳数组,用于存放太阳类型 0:普通 1:移动 2:重叠
|
|
stepTimeList: [], //每次点击间隔
|
|
remainder: 120 //游戏剩余时间
|
|
}
|
|
}
|
|
static LEVEL_INFO_init() {
|
|
this.LEVEL_INFO = [
|
|
{ //地图
|
|
map: [
|
|
[
|
|
1,0,1,1
|
|
],
|
|
[
|
|
1,1,1,1
|
|
],
|
|
[
|
|
1,1,1,1
|
|
],
|
|
[
|
|
1,1,1,5
|
|
]
|
|
], //太阳总数
|
|
opacity: 0.9, //提示透明度
|
|
moveSpeed: 0.3, //洪水移动速度
|
|
|
|
}
|
|
]
|
|
}
|
|
|
|
static Authentication(){
|
|
cc.fx.GameTool.Authentication();
|
|
}
|
|
}
|
|
|