125 lines
4.5 KiB
TypeScript
125 lines
4.5 KiB
TypeScript
/**
|
|
* loadscene
|
|
* 加载游戏资源 数据
|
|
*/
|
|
|
|
import Define from "../Tools/Define";
|
|
import GameResMgr from "../Tools/GameResMgr";
|
|
import PlayData from "../Tools/PlayData";
|
|
import AdsApiMgr from "../Tools/Sdk/ads/AdsApiMgr";
|
|
//import gameNetWorkControl from "../Tools/gameNetWorkControl";
|
|
import gameStorage from "../Tools/gameStorage";
|
|
import TipsManager from "./TipsManager";
|
|
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class LoadSceneSc extends cc.Component {
|
|
|
|
@property(cc.Label)
|
|
loadnum:cc.Label = null;
|
|
|
|
@property(cc.ProgressBar)
|
|
loadingbar:cc.ProgressBar = null
|
|
|
|
private loadOver:boolean = !1
|
|
|
|
onLoad () {
|
|
|
|
if(cc.sys.platform == cc.sys.WECHAT_GAME){
|
|
//@ts-ignore
|
|
// const updateManager = wx.getUpdateManager()
|
|
// updateManager.onCheckForUpdate(function (res) {
|
|
// // 请求完新版本信息的回调
|
|
// console.log(res.hasUpdate)
|
|
// })
|
|
|
|
// updateManager.onUpdateReady(function () {
|
|
// //@ts-ignore
|
|
// wx.showModal({
|
|
// title: '更新提示',
|
|
// content: '新版本已经准备好,是否重启应用?',
|
|
// success: function (res) {
|
|
// if (res.confirm) {
|
|
// // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
// updateManager.applyUpdate()
|
|
// }
|
|
// }
|
|
// })
|
|
// })
|
|
}else if(cc.sys.platform == cc.sys.BYTEDANCE_GAME){
|
|
//@ts-ignore
|
|
// const updateManager = tt.getUpdateManager();
|
|
// updateManager.onUpdateReady((res) => {
|
|
// //@ts-ignore
|
|
// tt.showModal({
|
|
// title: "更新提示",
|
|
// content: "新版本已经准备好,是否重启小游戏?",
|
|
// success: (res) => {
|
|
// if (res.confirm) {
|
|
// // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
// updateManager.applyUpdate();
|
|
// }
|
|
// },
|
|
// });
|
|
// });
|
|
|
|
//@ts-ignore //监听小游戏切换到前台
|
|
tt.onShow(op => {
|
|
console.log('监听小游戏',op);
|
|
PlayData.Instance.backGameIndex++
|
|
console.log('监听小游戏切换到前台', PlayData.Instance.backGameIndex)
|
|
console.log("启动场景字段:", op.launch_from, ", ", op.location, op.scene);
|
|
if(op.launch_from == 'homepage' || op.location == 'sidebar_card' || op.scene === '021036'){
|
|
PlayData.Instance.cebianlingquState = 1
|
|
console.log('侧边进入', PlayData.Instance.cebianlingquState)
|
|
cc.game.emit('opencebian')
|
|
}
|
|
});
|
|
}
|
|
|
|
AdsApiMgr.Instance.gameLogin(false)
|
|
//gameNetWorkControl.Instance.getGameOpenState(()=>{})
|
|
this.loadingbar.progress = 0
|
|
gameStorage.Instance.getMaxEngryVideoShu()
|
|
PlayData.Instance.energytime = Define.eneryTime
|
|
this.loadOver = !1
|
|
GameResMgr.Instance.Initial()
|
|
TipsManager.Instance.Initial()
|
|
AdsApiMgr.Instance.showShareMenu()
|
|
AdsApiMgr.Instance.chaPingAds_Load()
|
|
AdsApiMgr.Instance.motivational_Video_Load()
|
|
}
|
|
|
|
start () {
|
|
this.initGameData()
|
|
//cc.director.loadScene('StartScene')
|
|
}
|
|
|
|
/**
|
|
* 初始化游戏数据
|
|
*/
|
|
initGameData(){
|
|
// PlayData.Instance.userInfo.gold = gameStorage.Instance.getGold()
|
|
// PlayData.Instance.userInfo.linelevle = gameStorage.Instance.getLineLevle()
|
|
// PlayData.Instance.userInfo.oillevel = gameStorage.Instance.getOilLevel()
|
|
// PlayData.Instance.userInfo.goldaddlevel = gameStorage.Instance.getGoldAddLevel()
|
|
// PlayData.Instance.userInfo.jiazilevel = gameStorage.Instance.getJiaZiLevel()
|
|
// PlayData.Instance.userInfo.boomNum = gameStorage.Instance.getBoomNum()
|
|
}
|
|
|
|
update (dt) {
|
|
if(this.loadOver){
|
|
return
|
|
}
|
|
let pesent = GameResMgr.Instance.loadOverNum/GameResMgr.Instance.totalResNum
|
|
this.loadnum.string = Math.floor(pesent*100) + '%'
|
|
this.loadingbar.progress = pesent
|
|
if(pesent >= 1){
|
|
this.loadOver = !0
|
|
cc.director.loadScene('StartScene')
|
|
}
|
|
}
|
|
}
|