You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.3 KiB
80 lines
2.3 KiB
2 months ago
|
/*
|
||
|
* @Descripttion:
|
||
|
* @version: 1.0.0
|
||
|
* @Author: YeeChan
|
||
|
* @Date: 2020-07-09 18:54:40
|
||
|
*/
|
||
|
|
||
|
import User from "../User/User";
|
||
|
|
||
|
import AppConfig from "../Config/AppConfig";
|
||
|
|
||
|
import GameReport, { ENTERTYPE } from "../Report/ZyZyReport";
|
||
|
import { DateUtils } from "../Util/DateUtils";
|
||
|
|
||
|
|
||
|
|
||
|
//游戏管理器,游戏代码的入口
|
||
|
export default class GameMgr {
|
||
|
public isFirstLoadAD: boolean = false;
|
||
|
public isWinner: boolean = false;
|
||
|
private static _instance_custom: GameMgr = new GameMgr();
|
||
|
|
||
|
public static getInstance_custom(): GameMgr {
|
||
|
return GameMgr._instance_custom;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 预加载一些场景 在Main.ts中
|
||
|
*/
|
||
|
public preloadScene_custom() {
|
||
|
//PrefabManage.preloadPrefabByType(GameType.LinJiaDaYuan)
|
||
|
// cc.director.preloadScene("FMMainScene");
|
||
|
// cc.director.preloadScene("FMGameScene");
|
||
|
// cc.director.preloadScene("FMGameSettleWinScene");
|
||
|
// cc.director.preloadScene("FMGameSettleFailScene");
|
||
|
//LogUtils.warn_custom("GameMgr.getInstance().preloadScene_custom这里可以加载需要预加载的场景");
|
||
|
}
|
||
|
|
||
|
//在合适的时候 cc.director.preloadScene 预加载你的场景
|
||
|
|
||
|
/**
|
||
|
* 登录加载后跳转自己的场景
|
||
|
*/
|
||
|
public onLoadToWorldScene_custom() {
|
||
|
// cc.director.loadScene("FMMainScene", function (err, scene) {
|
||
|
// console.log("跳转游戏场景 FMMainScene")
|
||
|
// });
|
||
|
|
||
|
// console.error(User.getFirstInNew(), 'User.getFirstInNew')
|
||
|
if(User.getFirstInNew()){
|
||
|
console.error("老玩家重置数据");
|
||
|
User.restartGame()
|
||
|
User.setFirstInNew(false)
|
||
|
}
|
||
|
|
||
|
|
||
|
cc.director.loadScene("MainScene", function (err, scene) {
|
||
|
console.log("跳转游戏场景 MainScene11");
|
||
|
// GameReport.EnterReport(ENTERTYPE.TIAOZHUAN, 'MainScene加载完成')
|
||
|
// GameReport.setLoadingFinishTime(DateUtils.getNowTime_custom())
|
||
|
// GameReport.getOpenUserId()
|
||
|
if(User.getFirstInNew()){
|
||
|
User.setFirstInNew(false)
|
||
|
}
|
||
|
|
||
|
});
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
//游戏存档,合适的时候调用它来保存
|
||
|
public saveGameData_custom() {
|
||
|
//存本地
|
||
|
cc.sys.localStorage.setItem("data" + AppConfig.AppID_custom, User.getSaveData_custom());
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|