123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811 |
- import { _decorator, AudioClip, AudioSource, Component, Node, Size, Sprite, SpriteFrame, sys, UITransform, Vec3 } from 'cc';
- import { game_run } from './game_run';
- import { attributes_data, event_item, LevelItemData, other_widget_finish_listen_item, scene_item_data, sysMessage, task_data, ui_att_item, UserData, UserUnlockLevesData, widget_item_data } from '../../data/data';
- import { config } from '../config';
- import { sceneManager } from './sceneManager';
- import { http } from '../http';
- import { tools } from '../tools';
- import { taskServce } from './TaskSchedule/taskServce';
- import { ClientEvent } from '../clientEvent';
- import { sysSound } from './sysSound';
- import { SdkUtil } from '../sdkUtil';
- import { statisticsManager } from '../statisticsManager';
- import { fail } from './ui/fail';
- const { ccclass, property } = _decorator;
- @ccclass('gameManager')
- export class gameManager extends Component {
- private mGameRun:game_run = null;
- private mGameData:scene_item_data[] = [];
- private mCurSceneIndex:number =0; //当前第几个场景
- public static Singleton:gameManager = null;
- private static g_userData:UserData;
- private static g_userUnlockLevesData:UserUnlockLevesData;
- public static res_map:Map<string,SpriteFrame> = new Map()
- public static mp3_cache:Map<string,AudioClip> = new Map()
- private mLevelData:LevelItemData = null;
- private static sys_data:sysMessage = null;
- private static isLoadingStatus:boolean = false;
- public static lookVideoAdsNumber:number = 0;
- public static isTestUser:boolean = false;
- public static isPlayGameLevelMusic:boolean = false;
- @property(sceneManager) mSceneManager:sceneManager = null;
- @property(sysSound) mSysSound:sysSound = null;
- protected start(): void {
- gameManager.Singleton = this;
- }
- public static isFreeAds():boolean {
- if(sys.platform==sys.Platform.BYTEDANCE_MINI_GAME||sys.platform==sys.Platform.WECHAT_GAME) {
- if(gameManager.isTestUser==false) {
- return false
- }
- }
- return true
- }
- public static is24Free():boolean{
- if(gameManager.getStaticUserData().freeTime==undefined){
- gameManager.getStaticUserData().freeTime = 0;
- gameManager.saveUserData()
- }
- if(gameManager.getStaticUserData().freeTime!=0){
- let cur_time = new Date()
- let old_time = new Date(gameManager.getStaticUserData().freeTime)
- let timeDiff = cur_time.getTime() - old_time.getTime();
- // console.log("old",tools.getLocalTime(old))
- // console.log("cur",tools.getLocalTime(cur))
- var seconds = Math.floor(timeDiff / 1000);
- var minutes = Math.floor(seconds / 60);
- // var hours = Math.floor(minutes / 60);
- console.log("相隔几分钟",minutes)
- if(minutes>=1440){
- gameManager.getStaticUserData().freeTime = 0;
- gameManager.saveUserData()
- return false;
- }else{
- return true;
- }
- }
- return false;
- }
- public static setUser24Free(){
- gameManager.g_userData.freeTime = new Date().getTime()
- gameManager.saveUserData()
- }
- public static loadSceneRes(level_id:number,scene_num:number,cb){
- if(scene_num<1){
- return
- }
- gameManager.isLoadingStatus = true;
- let scene_count = 0;
- let start_loading_all_res =()=>{
- let count = 0;
- let num = 0;
-
- let load_call = ()=>{
- count++;
- // console.log("count",count,num,scene_count,scene_num)
- if(scene_count==scene_num){
- if(count>=num){
- gameManager.isLoadingStatus = false;
- console.log("完成全部加载!")
- }
- }
- }
- if(scene_num<=2){
- gameManager.isLoadingStatus = false;
- console.log("完成全部加载!")
- return
- }
- for (let i = 2; i <= scene_num; i++) {
- let url = http.get_level_resource(level_id,i)
- http.run_get_static(url,(err,data)=>{
- if(!err){
- let _data = JSON.parse(data)
- scene_count++;
- num += _data.content.length;
- if(scene_count==scene_num){
- if(num==0){
- gameManager.isLoadingStatus = false;
- console.log("完成全部加载!")
- return
- }else{
- if(count>=num){
- gameManager.isLoadingStatus = false;
- console.log("完成全部加载!")
- return
- }
- }
- }
- // console.log("run_get:",scene_count,_data.content.length,i)
- for (let index = 0; index < _data.content.length; index++) {
- const url:string = _data.content[index];
- load_res(url,load_call)
- }
- }else{
- tools.showToast(`获取关卡错误${err}`)
- }
- })
- }
- }
- // console.log("scene_num",scene_num)
- let load_res = (url:string,call)=>{
- let hz = url.substring(url.length-3,url.length);
-
- if(hz==="png"||hz==="jpg"){
- tools.loadSceneImg(url,(d)=>{
- first_load_res.delete(url)
- gameManager.res_map.set(d.url,d.sf)
- call()
- })
-
- }
- if(hz==="mp3"){
- tools.loadSceneMp3(url,(d)=>{
- first_load_res.delete(url)
- gameManager.mp3_cache.set(d.url,d.clip)
- call()
- })
- }
- }
- let first_finish_call = ()=>{
- first_load_res.forEach((v,k)=>{
- const url:string =k;
- load_res(url,()=>{
- if(first_load_res.size<=0){
- cb()
- start_loading_all_res()
- }
- })
- })
- }
- let first_count = 0;
- let first_load_res:Map<string,boolean> = new Map;
- for (let i = 0; i < 2; i++) {
- let url = http.get_level_resource(level_id,i)
- http.run_get_static(url,(err,data)=>{
- if(!err){
- let _data = JSON.parse(data)
- first_count++;
- for (let index = 0; index < _data.content.length; index++) {
- const url:string = _data.content[index];
- first_load_res.set(url,false)
- }
- if(first_count==2){
- scene_count=1;
- first_finish_call()
- }
- }
- })
- }
-
- }
- public setLevelData(data:LevelItemData){
- this.mLevelData = data;
- }
- public getLevelData(){
- return this.mLevelData;
- }
- public static setSysData(data:sysMessage){
- gameManager.sys_data = data;
- }
- public static getSysData(){
- return gameManager.sys_data;
- }
- public getSceneCurIndex():number {
- return this.mCurSceneIndex
- }
- public getSceneCurTotalCount():number {
- return this.mGameData.length
- }
- public static loadSceneMp3(){
- }
- public static getUserData():UserData{
- let str = sys.localStorage.getItem(config.USER_DATA)
- if(str==undefined||str==""||str==null){
- return null;
- }
- let user:UserData = JSON.parse(str)
- return user;
- }
- public static getStaticUserData(){
- return gameManager.g_userData
- }
- public static setUserData(user:UserData){
- gameManager.g_userData = user;
- gameManager.saveUserData()
- }
- public static saveUserData(){
- if(gameManager.g_userData!=null){
- sys.localStorage.setItem(config.USER_DATA, JSON.stringify(gameManager.g_userData));
- }
- }
- public static getZbOpenid(): string {
- let zb_openid = '';
- try {
- zb_openid = sys.localStorage.getItem(config.ZB_OPENID)
- } catch {
- console.log("getZbOpenid fail")
- }
- return zb_openid
- }
- public static setZbOpenid(id: String) {
- sys.localStorage.setItem(config.ZB_OPENID, id)
- }
- public reLife(){
- let ad_id = SdkUtil.getAdId(config.AD_TYPE.RE_LIFE)
- SdkUtil.showVideoAd(ad_id,(res)=>{
- if(res.isEnded){
- this.mGameRun.onlaunch(()=>{
- gameManager.Singleton.startLevelGame()
- })
- }
- // 统计-激励视频广告
- let level_id = gameManager.Singleton.getLevelData().id
- let collect_data = statisticsManager.get_collect_ads_data(level_id, res, config.STATISTICS_ACTION_TYPE.GUAN_KA_FU_HUO)
- statisticsManager.request_collect_rewardVideoData(collect_data)
- })
- }
- public reStartGame(){
- this.mGameRun.onlaunch(()=>{
- this.mCurSceneIndex = 0;
- gameManager.Singleton.startLevelGame()
- })
- }
- public levleIsUnLock(levle_id:number){
- let isunlock = false;
- for (let index = 0; index < gameManager.getStaticUserData().unlock_levels.length; index++) {
- const id = gameManager.getStaticUserData().unlock_levels[index];
- if(id==levle_id){
- isunlock = true;
- break;
- }
- }
- return isunlock
- }
- public unLockLevel(levle_id:number){
- let is_have = false;
- for (let index = 0; index < gameManager.getStaticUserData().unlock_levels.length; index++) {
- const id = gameManager.getStaticUserData().unlock_levels[index];
- if(id==levle_id){
- is_have = true;
- break;
- }
- }
- if(!is_have){
- gameManager.getStaticUserData().unlock_levels.push(levle_id)
- gameManager.saveUserData()
- gameManager.Singleton.sync_data()
- }
- }
- public sync_data(){
- let url = http.sync_data()
- let unlock_levels = gameManager.getStaticUserData().unlock_levels;
- http.run_post(url,{"unlock_levels":JSON.stringify(unlock_levels)},(err,data)=>{
- if(!err){
- // console.log("sync_data finish!"+JSON.stringify(unlock_levels));
- }
- })
- }
- public nextScene(){
- this.mCurSceneIndex++;
- let not_scene = false;
- if(this.mCurSceneIndex>=this.mGameData.length){
- not_scene = true;
- }
- if(!not_scene){
- let task_data = this.mGameData[this.mCurSceneIndex]._task_data
- if(task_data==null||task_data==undefined) {
- return tools.showToast('没有任务')
- }
- let call_back =(()=>{
- this.mGameRun.unInit()
- this.startLevelGame()
- })
- if(task_data.is_open_interlude_default_animation==undefined||
- task_data.is_open_interlude_default_animation==null) {
- task_data.is_open_interlude_default_animation = true
- }
- if(task_data.is_open_interlude_default_animation) {
- this.onLaunch(()=>{
- call_back()
- })
- } else {
- call_back()
- }
- }else{
- // tools.showToast("没有场景了!")
- }
- // this.onLaunch(()=>{
- // this.mCurSceneIndex++;
- // let not_scene = false;
- // if(this.mCurSceneIndex>=this.mGameData.length){
- // not_scene = true;
- // }
- // if(!not_scene){
- // this.mGameRun.unInit()
- // this.startLevelGame()
- // }else{
- // // tools.showToast("没有场景了!")
- // }
- // })
- }
- public gameOver(){
- ClientEvent.dispatchEvent(config.EventRun.ON_WIN)
- }
- public gameFail() {
- console.log('游戏失败')
- }
- public gotoGameLevel() {
- SdkUtil.ttStartScreenRecording()
- statisticsManager.startRecordUserLevel()
- }
- public backGameList(status = config.BACK_GAME_STATUS.NORMAL){
- if(!gameManager.isLoadingStatus){
- this.unscheduleAllCallbacks()
- this.mGameRun.backGameList()
- gameManager.Singleton.mSceneManager.play_sys_music()
- gameManager.isPlayGameLevelMusic = false
- SdkUtil.ttStopScreenRecording(true)
- if(status == config.BACK_GAME_STATUS.WIN) {
- statisticsManager.uploadRecordUserLevel(true)
- } else {
- statisticsManager.uploadRecordUserLevel(false)
- }
- }else{
- console.log("没有全部加载完成!")
- }
- }
- public initEvent(){
- ClientEvent.offAll(config.EventRun.NOTICE_EVENT)
- ClientEvent.offAll(config.EventRun.WIDGET_FINISH)
- ClientEvent.offAll(config.EventRun.WIDGET_FAIL)
- ClientEvent.offAll(config.EventRun.ON_WIDGET_FINISH_COLLECT_EVENT)
- ClientEvent.offAll(config.EventRun.WIDGET_HIDE)
- ClientEvent.offAll(config.EventRun.SHOW_ZHAO_BU_TONG_FINISH_STATUS)
- ClientEvent.offAll(config.EventRun.ON_ZHAO_BU_TONG_ALL_FINISH)
- ClientEvent.offAll(config.EventRun.TOP_VIEW_CLOSE)
- ClientEvent.offAll(config.EventRun.TOP_VIEW_FINISH)
- ClientEvent.offAll(config.EventRun.TOP_VIEW_FAIL)
- ClientEvent.offAll(config.EventRun.TOP_VIEW_HIDE)
- ClientEvent.offAll(config.EventRun.ON_COUNT_DOWN_FAIL)
- ClientEvent.offAll(config.EventRun.ON_COUNT_DOWN_START)
- ClientEvent.offAll(config.EventRun.ON_SHOW_RULE_BTN)
- ClientEvent.offAll(config.EventRun.ON_BOSS_HURT)
- ClientEvent.on(config.EventRun.WIDGET_FINISH,this.onWidgetFinishEvent.bind(this),this)
- ClientEvent.on(config.EventRun.WIDGET_FAIL,this.onWidgetFailEvent.bind(this),this)
- ClientEvent.on(config.EventRun.TOP_VIEW_CLOSE,this.onUiCloseEvent.bind(this),this)
- ClientEvent.on(config.EventRun.TOP_VIEW_FINISH,this.onUiFinishEvent.bind(this),this)
- ClientEvent.on(config.EventRun.TOP_VIEW_FAIL,this.onUiFailEvent.bind(this),this)
- ClientEvent.on(config.EventRun.TOP_VIEW_HIDE,this.onUiHideEvent.bind(this),this)
- ClientEvent.on(config.EventRun.ON_COUNT_DOWN_FAIL,this.onCountDownFailEvent.bind(this),this)
- ClientEvent.on(config.EventRun.ON_COUNT_DOWN_START,this.onStartCountDownEvent.bind(this),this)
- }
- public initGR(gr:game_run){
- this.mGameRun = gr;
- gameManager.Singleton = this;
- this.mSceneManager.init(this)
- this.clearRes()
- }
- public clearRes(){
- gameManager.res_map.clear()
- gameManager.mp3_cache.clear()
- }
- public init(gr:game_run,data:scene_item_data[]){
- // this.mGameRun = gr;
- // gameManager.Singleton = this;
- // this.mSceneManager.init(this)
- // this.mCurSceneIndex = main.Singleton.edit_scene_view.getCurSelectSceneIndex()
-
- // this.mGameData = data;
- // if( this.mGameData.length<=0){
- // return tools.showToast("错误的场景信息")
- // }
- // this.startLevelGame()
- }
- public runGame(data:scene_item_data[]){
- this.mCurSceneIndex = 0;
- this.mGameData = data;
- if( this.mGameData.length<=0){
- return tools.showToast("错误的场景信息")
- }
- this.startLevelGame()
- }
- public onLaunch(call,delay=0.7){
- this.mGameRun.onlaunch(call)
- }
- public getTopFloorLayer():Node {
- return this.mGameRun.top_floor_layer;
- }
- FilterChildScene(data:scene_item_data[]){
- let temp_scene = []
- for (let index = 0; index < data.length; index++) {
- const element = data[index];
- if(!element.is_child_scene){
- temp_scene.push(element)
- }
- }
- return temp_scene;
- }
- protected onDestroy(): void {
- ClientEvent.off(config.EventRun.WIDGET_FINISH,this.onWidgetFinishEvent.bind(this),this)
- }
- public startLevelGame(){
- this.mGameRun.unInit()
- this.initEvent()
- // console.log("this.mGameData",this.mGameData,this.mCurSceneIndex)
- this.mSceneManager.startLevelGame(this.mGameData[this.mCurSceneIndex])
- taskServce.initTask(this.mGameData[this.mCurSceneIndex]._task_data)
- this.scheduleOnce(()=>{
- this.startGame()
- },0.5)
- if(gameManager.isPlayGameLevelMusic==false) {
- gameManager.isPlayGameLevelMusic = true
- if(gameManager.Singleton.getLevelData()){
- this.mSceneManager.stopMusic()
- this.mSceneManager.playMusic(this.mLevelData.piped_music,true)
- }
- }
- }
- public loadSceneTask(data: task_data) {
- this.mGameRun.loadSceneTask(data)
- }
- public loadScene(pages: scene_item_data[],type:number){
- this.mGameRun.loadSceneLayer(pages,type)
- }
- public loadUi(ui_widge_list:widget_item_data[]){
- this.mGameRun.loadUILayer(ui_widge_list)
- }
- public loadTextSound(ui_widge_list:widget_item_data[]){
- this.mGameRun.loadTextSound(ui_widge_list)
- }
- public loadQuestion(ui_widge_list:widget_item_data[]){
- this.mGameRun.initQuestionList(ui_widge_list)
- }
- public initCountDownList(ui_widge_list:widget_item_data[]){
- this.mGameRun.initCountDownList(ui_widge_list)
- }
- public initTaskUi(data:task_data){
- this.mGameRun.initTaskUi(data)
- }
- public startGame(){
- taskServce.startFirstEvent()
- }
- public showCheck(call){
- this.mGameRun.showCheck(call)
- }
- public showLoadingLevel(){
- this.mGameRun.showLoadingLevel()
- }
- public hideLoadingLevel(){
- this.mGameRun.hideLoadingLevel()
- }
- public showUnLockView(lock_one_call,lock_all_one_day){
- this.mGameRun.showUnLockView(lock_one_call,lock_all_one_day)
- }
- public static getWidgetList(scene_data:scene_item_data):widget_item_data[]{
- let temp:widget_item_data[] = []
- for (let index = 0; index < scene_data.page_widget_list.length; index++) {
- const data = scene_data.page_widget_list[index];
- if(data.type<=4 ){
- temp.push(data)
- }
- }
- return temp;
- }
- public static getUIWidgetList(scene_data:scene_item_data){
- let temp:widget_item_data[] = []
- for (let index = 0; index < scene_data.page_widget_list.length; index++) {
- const data = scene_data.page_widget_list[index];
- if(data.type===config.Widget_Type_List.UI_TOP){
- if(data.att.top_data!=null&&data.att.top_data.top_ui_type!=config.top_view_type.__null){
- temp.push(data)
- }
- }
- }
- return temp;
- }
- public isCurScenePageCheckWidgetFinish(widget_id:number){
- return this.mGameRun.isCurScenePageCheckWidgetFinish(widget_id);
- }
- public isCurScenePageCheckWidgetShow(widget_id:number){
- return this.mGameRun.isCurScenePageCheckWidgetShow(widget_id);
- }
- public static getQuestionwidgetList(scene_data:scene_item_data){
- let temp:widget_item_data[] = []
- for (let index = 0; index < scene_data.page_widget_list.length; index++) {
- const data = scene_data.page_widget_list[index];
- if(data.type===config.Widget_Type_List.QUESTION_SELECT){
- if(data.att.question_select!=null){
- temp.push(data)
- }
- }
- }
- return temp;
- }
- public static getTextSoundWidgetList(scene_data:scene_item_data){
- let temp:widget_item_data[] = []
- for (let index = 0; index < scene_data.page_widget_list.length; index++) {
- const data = scene_data.page_widget_list[index];
- if(data.type===config.Widget_Type_List.TEXT_SOUND){
- if(data.att.text_sound_data!=null){
- temp.push(data)
- }
- }
- }
- return temp;
- }
- public static getCountDownWidgetList(scene_data:scene_item_data){
- let temp:widget_item_data[] = []
- for (let index = 0; index < scene_data.page_widget_list.length; index++) {
- const data = scene_data.page_widget_list[index];
- if(data.type===config.Widget_Type_List.COUNT_DOWN){
- if(data.att.count_down!=null){
- temp.push(data)
- }
- }
- }
- return temp;
- }
- public static getCacheSpriteFrameByName(node:Node,sfName:string){
- let sf = gameManager.res_map.get(sfName)
- if(sf==null){
- if(node!=null){
- tools.loadUrl(sfName,node.getComponent(Sprite))
- }
- }
- return sf
- }
- public static getCacheSoundByName(sfName:string){
- // return control.mp3_cache.get(sfName)
- return gameManager.mp3_cache.get(sfName)
- }
- public static initUiBaseAtt(node:Node,att:ui_att_item){
- node.getComponent(UITransform).setContentSize(new Size(att.width,att.height))
- node.position = new Vec3(att.x,att.y);
- node.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(node,att.res)
- }
- onWidgetFinishEvent(widget_id:number, finish_event_item:event_item){
- taskServce.onWidgetFinishEvent(widget_id, finish_event_item)
- }
- onWidgetFailEvent(widget_id:number){
- taskServce.onWidgetFailEvent(widget_id)
- }
- onUiCloseEvent(event_id:number){
- taskServce.extEventByEventId(event_id)
- }
- onUiFinishEvent(event_id:number){
- taskServce.extEventByEventId(event_id)
- }
- onUiFailEvent(event_id:number){
- taskServce.extEventByEventId(event_id)
- }
- onUiHideEvent(widget_id:number) {
- taskServce.checkFinishZhaoXiJieWidget(widget_id)
- }
- onCountDownFailEvent(event_id:number){
- taskServce.extEventByEventId(event_id)
- }
- onStartCountDownEvent(event_id:number){
- taskServce.extEventByEventId(event_id)
- }
- exeEvent(event_id:number){
- taskServce.extEventByEventId(event_id)
- }
- exeSuccessTriggerEvent(trigger_event_id:number) {
- taskServce.exeSuccessTriggerEvent(trigger_event_id)
- }
- exeNextDelayEvent(event_item:event_item) {
- taskServce.exeNextDelayEvent(event_item)
- }
- showFindRuleTips(){
- this.mGameRun.showFindRuleTips()
- }
- showTips(){
- this.mGameRun.showTips()
- }
- showRule(){
- this.mGameRun.showRule()
- }
- getSceneManager(){
- return this.mSceneManager;
- }
- IsOpenRuleStatus(){
- return taskServce.guo_ju_qing_binding_event_id==-1;
- }
- //点击按钮音效
- public sys_click_button_music(){
- if(gameManager.sys_data!=null){
- this.mSysSound.playSound(gameManager.sys_data.content.sys_click_button_music)
- }
- }
- // //失败吓人音效
- // public sys_fail_scary_music(){
- // if(gameManager.sys_data!=null){
- // this.mSysSound.playSound(gameManager.sys_data.content.sys_fail_scary_music)
- // }
- // }
- //失败后攻击音效
- public sys_fail_attack_music(){
- if(gameManager.sys_data!=null){
- this.mSysSound.playSound(gameManager.sys_data.content.sys_fail_attack_music)
- }
- }
- //失败提示音效
- public sys_fail_prompt_music(){
- if(gameManager.sys_data!=null){
- this.mSysSound.playSound(gameManager.sys_data.content.sys_fail_prompt_music)
- }
- }
- //正确通关音效
- public sys_success_complete_music(){
- if(gameManager.sys_data!=null){
- this.mSysSound.playSound(gameManager.sys_data.content.sys_success_complete_music)
- }
- }
- //点击正确细节音效
- public sys_click_correct_detail_music(){
- if(gameManager.sys_data!=null){
- this.mSysSound.playSound(gameManager.sys_data.content.sys_click_correct_detail_music)
- }
- }
- public checkWidgetList(list:other_widget_finish_listen_item[]):number{
- let event_id = -1;
- for (let index = 0; index < list.length; index++) {
- const item = list[index];
- let isFinish = this.mGameRun.isCurScenePageCheckWidgetFinish(item.widget_id)
- if(!isFinish){
- event_id = item.event_id;
- break;
- }
- }
- return event_id;
- }
- public static getUserUnlockLevesData():UserUnlockLevesData{
- if(gameManager.g_userUnlockLevesData == null) {
- gameManager.g_userUnlockLevesData = new UserUnlockLevesData()
- }
- return gameManager.g_userUnlockLevesData;
- }
- public static setUserUnlockLevesData(data:any){
- if(gameManager.g_userUnlockLevesData == null) {
- gameManager.g_userUnlockLevesData = new UserUnlockLevesData()
- }
- if(data != null) {
- gameManager.g_userUnlockLevesData = data.content
- // console.log('g_userUnlockLevesData=',gameManager.g_userUnlockLevesData)
- }
- }
- public static LookVideoCallBack(call){
- if(call!=null){
- let ad_id = SdkUtil.getAdId(config.AD_TYPE.ADD_TIME)
- SdkUtil.showVideoAd(ad_id,(res)=>{
- if(res.isEnded){
- call()
- }
- // 统计-激励视频广告
- let level_id = gameManager.Singleton.getLevelData().id
- let collect_data = statisticsManager.get_collect_ads_data(level_id, res, config.STATISTICS_ACTION_TYPE.ADD_TIME)
- statisticsManager.request_collect_rewardVideoData(collect_data)
- })
- }
- }
- public getCurSceneLayerPage(){
- return this.mGameRun.getCurSceneLayerPage()
- }
-
- public static request_user_unlock_number_status(status = config.User_unlock_levels_number_status.GET, success_callback:any, fail_callback:any) {
- if(status != config.User_unlock_levels_number_status.GET) {
- gameManager.Singleton.showLoadingLevel()
- }
- http.run_post(http.user_unlock_number_status(),{'stype':status}, (err,data)=> {
- // console.log('err=',err,'status=',status,'解锁次数=',data)
- if(status != config.User_unlock_levels_number_status.GET) {
- gameManager.Singleton.hideLoadingLevel()
- }
- if(!err) {
- let _data = JSON.parse(data)
- if(_data.code==config.MSG_CODE.SUCCESS){
- gameManager.setUserUnlockLevesData(_data)
- success_callback(_data)
- } else{
- fail_callback()
- }
- } else {
- fail_callback()
- }
- })
- }
- }
|