gameManager.ts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. import { _decorator, AudioClip, AudioSource, Component, Node, Size, Sprite, SpriteFrame, sys, UITransform, Vec3 } from 'cc';
  2. import { game_run } from './game_run';
  3. 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';
  4. import { config } from '../config';
  5. import { sceneManager } from './sceneManager';
  6. import { http } from '../http';
  7. import { tools } from '../tools';
  8. import { taskServce } from './TaskSchedule/taskServce';
  9. import { ClientEvent } from '../clientEvent';
  10. import { sysSound } from './sysSound';
  11. import { SdkUtil } from '../sdkUtil';
  12. import { statisticsManager } from '../statisticsManager';
  13. import { fail } from './ui/fail';
  14. const { ccclass, property } = _decorator;
  15. @ccclass('gameManager')
  16. export class gameManager extends Component {
  17. private mGameRun:game_run = null;
  18. private mGameData:scene_item_data[] = [];
  19. private mCurSceneIndex:number =0; //当前第几个场景
  20. public static Singleton:gameManager = null;
  21. private static g_userData:UserData;
  22. private static g_userUnlockLevesData:UserUnlockLevesData;
  23. public static res_map:Map<string,SpriteFrame> = new Map()
  24. public static mp3_cache:Map<string,AudioClip> = new Map()
  25. private mLevelData:LevelItemData = null;
  26. private static sys_data:sysMessage = null;
  27. private static isLoadingStatus:boolean = false;
  28. public static lookVideoAdsNumber:number = 0;
  29. public static isTestUser:boolean = false;
  30. @property(sceneManager) mSceneManager:sceneManager = null;
  31. @property(sysSound) mSysSound:sysSound = null;
  32. protected start(): void {
  33. gameManager.Singleton = this;
  34. }
  35. public static isFreeAds():boolean {
  36. if(sys.platform==sys.Platform.BYTEDANCE_MINI_GAME||sys.platform==sys.Platform.WECHAT_GAME) {
  37. if(gameManager.isTestUser==false) {
  38. return false
  39. }
  40. }
  41. return true
  42. }
  43. public static is24Free():boolean{
  44. if(gameManager.getStaticUserData().freeTime==undefined){
  45. gameManager.getStaticUserData().freeTime = 0;
  46. gameManager.saveUserData()
  47. }
  48. if(gameManager.getStaticUserData().freeTime!=0){
  49. let cur_time = new Date()
  50. let old_time = new Date(gameManager.getStaticUserData().freeTime)
  51. let timeDiff = cur_time.getTime() - old_time.getTime();
  52. // console.log("old",tools.getLocalTime(old))
  53. // console.log("cur",tools.getLocalTime(cur))
  54. var seconds = Math.floor(timeDiff / 1000);
  55. var minutes = Math.floor(seconds / 60);
  56. // var hours = Math.floor(minutes / 60);
  57. console.log("相隔几分钟",minutes)
  58. if(minutes>=1440){
  59. gameManager.getStaticUserData().freeTime = 0;
  60. gameManager.saveUserData()
  61. return false;
  62. }else{
  63. return true;
  64. }
  65. }
  66. return false;
  67. }
  68. public static setUser24Free(){
  69. gameManager.g_userData.freeTime = new Date().getTime()
  70. gameManager.saveUserData()
  71. }
  72. public static loadSceneRes(level_id:number,scene_num:number,cb){
  73. if(scene_num<1){
  74. return
  75. }
  76. gameManager.isLoadingStatus = true;
  77. let scene_count = 0;
  78. let start_loading_all_res =()=>{
  79. let count = 0;
  80. let num = 0;
  81. let load_call = ()=>{
  82. count++;
  83. // console.log("count",count,num,scene_count,scene_num)
  84. if(scene_count==scene_num){
  85. if(count>=num){
  86. gameManager.isLoadingStatus = false;
  87. console.log("完成全部加载!")
  88. }
  89. }
  90. }
  91. if(scene_num<=2){
  92. gameManager.isLoadingStatus = false;
  93. console.log("完成全部加载!")
  94. return
  95. }
  96. for (let i = 2; i <= scene_num; i++) {
  97. let url = http.get_level_resource(level_id,i)
  98. http.run_get_static(url,(err,data)=>{
  99. if(!err){
  100. let _data = JSON.parse(data)
  101. scene_count++;
  102. num += _data.content.length;
  103. if(scene_count==scene_num){
  104. if(num==0){
  105. gameManager.isLoadingStatus = false;
  106. console.log("完成全部加载!")
  107. return
  108. }else{
  109. if(count>=num){
  110. gameManager.isLoadingStatus = false;
  111. console.log("完成全部加载!")
  112. return
  113. }
  114. }
  115. }
  116. // console.log("run_get:",scene_count,_data.content.length,i)
  117. for (let index = 0; index < _data.content.length; index++) {
  118. const url:string = _data.content[index];
  119. load_res(url,load_call)
  120. }
  121. }else{
  122. tools.showToast(`获取关卡错误${err}`)
  123. }
  124. })
  125. }
  126. }
  127. // console.log("scene_num",scene_num)
  128. let load_res = (url:string,call)=>{
  129. let hz = url.substring(url.length-3,url.length);
  130. if(hz==="png"||hz==="jpg"){
  131. tools.loadSceneImg(url,(d)=>{
  132. first_load_res.delete(url)
  133. gameManager.res_map.set(d.url,d.sf)
  134. call()
  135. })
  136. }
  137. if(hz==="mp3"){
  138. tools.loadSceneMp3(url,(d)=>{
  139. first_load_res.delete(url)
  140. gameManager.mp3_cache.set(d.url,d.clip)
  141. call()
  142. })
  143. }
  144. }
  145. let first_finish_call = ()=>{
  146. first_load_res.forEach((v,k)=>{
  147. const url:string =k;
  148. load_res(url,()=>{
  149. if(first_load_res.size<=0){
  150. cb()
  151. start_loading_all_res()
  152. }
  153. })
  154. })
  155. }
  156. let first_count = 0;
  157. let first_load_res:Map<string,boolean> = new Map;
  158. for (let i = 0; i < 2; i++) {
  159. let url = http.get_level_resource(level_id,i)
  160. http.run_get_static(url,(err,data)=>{
  161. if(!err){
  162. let _data = JSON.parse(data)
  163. first_count++;
  164. for (let index = 0; index < _data.content.length; index++) {
  165. const url:string = _data.content[index];
  166. first_load_res.set(url,false)
  167. }
  168. if(first_count==2){
  169. scene_count=1;
  170. first_finish_call()
  171. }
  172. }
  173. })
  174. }
  175. }
  176. public setLevelData(data:LevelItemData){
  177. this.mLevelData = data;
  178. }
  179. public getLevelData(){
  180. return this.mLevelData;
  181. }
  182. public static setSysData(data:sysMessage){
  183. gameManager.sys_data = data;
  184. }
  185. public static getSysData(){
  186. return gameManager.sys_data;
  187. }
  188. public getSceneCurIndex():number {
  189. return this.mCurSceneIndex
  190. }
  191. public getSceneCurTotalCount():number {
  192. return this.mGameData.length
  193. }
  194. public static loadSceneMp3(){
  195. }
  196. public static getUserData():UserData{
  197. let str = sys.localStorage.getItem(config.USER_DATA)
  198. if(str==undefined||str==""||str==null){
  199. return null;
  200. }
  201. let user:UserData = JSON.parse(str)
  202. return user;
  203. }
  204. public static getStaticUserData(){
  205. return gameManager.g_userData
  206. }
  207. public static setUserData(user:UserData){
  208. gameManager.g_userData = user;
  209. gameManager.saveUserData()
  210. }
  211. public static saveUserData(){
  212. if(gameManager.g_userData!=null){
  213. sys.localStorage.setItem(config.USER_DATA, JSON.stringify(gameManager.g_userData));
  214. }
  215. }
  216. public static getZbOpenid(): string {
  217. let zb_openid = '';
  218. try {
  219. zb_openid = sys.localStorage.getItem(config.ZB_OPENID)
  220. } catch {
  221. console.log("getZbOpenid fail")
  222. }
  223. return zb_openid
  224. }
  225. public static setZbOpenid(id: String) {
  226. sys.localStorage.setItem(config.ZB_OPENID, id)
  227. }
  228. public reLife(){
  229. let ad_id = SdkUtil.getAdId(config.AD_TYPE.RE_LIFE)
  230. SdkUtil.showVideoAd(ad_id,(res)=>{
  231. if(res.isEnded){
  232. this.mGameRun.onlaunch(()=>{
  233. gameManager.Singleton.startLevelGame()
  234. })
  235. }
  236. // 统计-激励视频广告
  237. let level_id = gameManager.Singleton.getLevelData().id
  238. let collect_data = statisticsManager.get_collect_ads_data(level_id, res, config.STATISTICS_ACTION_TYPE.GUAN_KA_FU_HUO)
  239. statisticsManager.request_collect_rewardVideoData(collect_data)
  240. })
  241. }
  242. public reStartGame(){
  243. this.mGameRun.onlaunch(()=>{
  244. this.mCurSceneIndex = 0;
  245. gameManager.Singleton.startLevelGame()
  246. })
  247. }
  248. public levleIsUnLock(levle_id:number){
  249. let isunlock = false;
  250. for (let index = 0; index < gameManager.getStaticUserData().unlock_levels.length; index++) {
  251. const id = gameManager.getStaticUserData().unlock_levels[index];
  252. if(id==levle_id){
  253. isunlock = true;
  254. break;
  255. }
  256. }
  257. return isunlock
  258. }
  259. public unLockLevel(levle_id:number){
  260. let is_have = false;
  261. for (let index = 0; index < gameManager.getStaticUserData().unlock_levels.length; index++) {
  262. const id = gameManager.getStaticUserData().unlock_levels[index];
  263. if(id==levle_id){
  264. is_have = true;
  265. break;
  266. }
  267. }
  268. if(!is_have){
  269. gameManager.getStaticUserData().unlock_levels.push(levle_id)
  270. gameManager.saveUserData()
  271. gameManager.Singleton.sync_data()
  272. }
  273. }
  274. public sync_data(){
  275. let url = http.sync_data()
  276. let unlock_levels = gameManager.getStaticUserData().unlock_levels;
  277. http.run_post(url,{"unlock_levels":JSON.stringify(unlock_levels)},(err,data)=>{
  278. if(!err){
  279. // console.log("sync_data finish!"+JSON.stringify(unlock_levels));
  280. }
  281. })
  282. }
  283. public nextScene(){
  284. this.onLaunch(()=>{
  285. this.mCurSceneIndex++;
  286. let not_scene = false;
  287. if(this.mCurSceneIndex>=this.mGameData.length){
  288. not_scene = true;
  289. }
  290. if(!not_scene){
  291. this.mGameRun.unInit()
  292. this.startLevelGame()
  293. }else{
  294. // tools.showToast("没有场景了!")
  295. }
  296. })
  297. }
  298. public gameOver(){
  299. ClientEvent.dispatchEvent(config.EventRun.ON_WIN)
  300. }
  301. public gameFail() {
  302. console.log('游戏失败')
  303. }
  304. public gotoGameLevel() {
  305. SdkUtil.ttStartScreenRecording()
  306. statisticsManager.startRecordUserLevel()
  307. }
  308. public backGameList(status = config.BACK_GAME_STATUS.NORMAL){
  309. if(!gameManager.isLoadingStatus){
  310. this.unscheduleAllCallbacks()
  311. this.mGameRun.backGameList()
  312. gameManager.Singleton.mSceneManager.play_music()
  313. SdkUtil.ttStopScreenRecording(true)
  314. if(status == config.BACK_GAME_STATUS.WIN) {
  315. statisticsManager.uploadRecordUserLevel(true)
  316. } else {
  317. statisticsManager.uploadRecordUserLevel(false)
  318. }
  319. }else{
  320. console.log("没有全部加载完成!")
  321. }
  322. }
  323. public initEvent(){
  324. ClientEvent.offAll(config.EventRun.NOTICE_EVENT)
  325. ClientEvent.offAll(config.EventRun.WIDGET_FINISH)
  326. ClientEvent.offAll(config.EventRun.WIDGET_FAIL)
  327. ClientEvent.offAll(config.EventRun.ON_WIDGET_FINISH_COLLECT_EVENT)
  328. ClientEvent.offAll(config.EventRun.WIDGET_HIDE)
  329. ClientEvent.offAll(config.EventRun.SHOW_ZHAO_BU_TONG_FINISH_STATUS)
  330. ClientEvent.offAll(config.EventRun.ON_ZHAO_BU_TONG_ALL_FINISH)
  331. ClientEvent.offAll(config.EventRun.TOP_VIEW_CLOSE)
  332. ClientEvent.offAll(config.EventRun.TOP_VIEW_FINISH)
  333. ClientEvent.offAll(config.EventRun.TOP_VIEW_FAIL)
  334. ClientEvent.offAll(config.EventRun.ON_COUNT_DOWN_FAIL)
  335. ClientEvent.offAll(config.EventRun.ON_COUNT_DOWN_START)
  336. ClientEvent.offAll(config.EventRun.ON_SHOW_RULE_BTN)
  337. ClientEvent.offAll(config.EventRun.ON_BOSS_HURT)
  338. ClientEvent.on(config.EventRun.WIDGET_FINISH,this.onWidgetFinishEvent.bind(this),this)
  339. ClientEvent.on(config.EventRun.WIDGET_FAIL,this.onWidgetFailEvent.bind(this),this)
  340. ClientEvent.on(config.EventRun.TOP_VIEW_CLOSE,this.onUiCloseEvent.bind(this),this)
  341. ClientEvent.on(config.EventRun.TOP_VIEW_FINISH,this.onUiFinishEvent.bind(this),this)
  342. ClientEvent.on(config.EventRun.TOP_VIEW_FAIL,this.onUiFailEvent.bind(this),this)
  343. ClientEvent.on(config.EventRun.ON_COUNT_DOWN_FAIL,this.onCountDownFailEvent.bind(this),this)
  344. ClientEvent.on(config.EventRun.ON_COUNT_DOWN_START,this.onStartCountDownEvent.bind(this),this)
  345. }
  346. public initGR(gr:game_run){
  347. this.mGameRun = gr;
  348. gameManager.Singleton = this;
  349. this.mSceneManager.init(this)
  350. this.clearRes()
  351. }
  352. public clearRes(){
  353. gameManager.res_map.clear()
  354. gameManager.mp3_cache.clear()
  355. }
  356. public init(gr:game_run,data:scene_item_data[]){
  357. // this.mGameRun = gr;
  358. // gameManager.Singleton = this;
  359. // this.mSceneManager.init(this)
  360. // this.mCurSceneIndex = main.Singleton.edit_scene_view.getCurSelectSceneIndex()
  361. // this.mGameData = data;
  362. // if( this.mGameData.length<=0){
  363. // return tools.showToast("错误的场景信息")
  364. // }
  365. // this.startLevelGame()
  366. }
  367. public runGame(data:scene_item_data[]){
  368. this.mCurSceneIndex = 0;
  369. this.mGameData = data;
  370. if( this.mGameData.length<=0){
  371. return tools.showToast("错误的场景信息")
  372. }
  373. this.startLevelGame()
  374. }
  375. public onLaunch(call,delay=0.7){
  376. this.mGameRun.onlaunch(call)
  377. }
  378. public getTopFloorLayer():Node {
  379. return this.mGameRun.top_floor_layer;
  380. }
  381. FilterChildScene(data:scene_item_data[]){
  382. let temp_scene = []
  383. for (let index = 0; index < data.length; index++) {
  384. const element = data[index];
  385. if(!element.is_child_scene){
  386. temp_scene.push(element)
  387. }
  388. }
  389. return temp_scene;
  390. }
  391. protected onDestroy(): void {
  392. ClientEvent.off(config.EventRun.WIDGET_FINISH,this.onWidgetFinishEvent.bind(this),this)
  393. }
  394. public startLevelGame(){
  395. this.mGameRun.unInit()
  396. this.initEvent()
  397. // console.log("this.mGameData",this.mGameData,this.mCurSceneIndex)
  398. this.mSceneManager.startLevelGame(this.mGameData[this.mCurSceneIndex])
  399. taskServce.initTask(this.mGameData[this.mCurSceneIndex]._task_data)
  400. this.scheduleOnce(()=>{
  401. this.startGame()
  402. },0.5)
  403. if(gameManager.Singleton.getLevelData()){
  404. // this.mSceneManager.playMusic(this.mLevelData.piped_music,true)
  405. }
  406. }
  407. public loadSceneTask(data: task_data) {
  408. this.mGameRun.loadSceneTask(data)
  409. }
  410. public loadScene(pages: scene_item_data[],type:number){
  411. this.mGameRun.loadSceneLayer(pages,type)
  412. }
  413. public loadUi(ui_widge_list:widget_item_data[]){
  414. this.mGameRun.loadUILayer(ui_widge_list)
  415. }
  416. public loadTextSound(ui_widge_list:widget_item_data[]){
  417. this.mGameRun.loadTextSound(ui_widge_list)
  418. }
  419. public loadQuestion(ui_widge_list:widget_item_data[]){
  420. this.mGameRun.initQuestionList(ui_widge_list)
  421. }
  422. public initCountDownList(ui_widge_list:widget_item_data[]){
  423. this.mGameRun.initCountDownList(ui_widge_list)
  424. }
  425. public initTaskUi(data:task_data){
  426. this.mGameRun.initTaskUi(data)
  427. }
  428. public startGame(){
  429. taskServce.startFirstEvent()
  430. }
  431. public showCheck(call){
  432. this.mGameRun.showCheck(call)
  433. }
  434. public showLoadingLevel(){
  435. this.mGameRun.showLoadingLevel()
  436. }
  437. public hideLoadingLevel(){
  438. this.mGameRun.hideLoadingLevel()
  439. }
  440. public showUnLockView(lock_one_call,lock_all_one_day){
  441. this.mGameRun.showUnLockView(lock_one_call,lock_all_one_day)
  442. }
  443. public static getWidgetList(scene_data:scene_item_data):widget_item_data[]{
  444. let temp:widget_item_data[] = []
  445. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  446. const data = scene_data.page_widget_list[index];
  447. if(data.type<=4 ){
  448. temp.push(data)
  449. }
  450. }
  451. return temp;
  452. }
  453. public static getUIWidgetList(scene_data:scene_item_data){
  454. let temp:widget_item_data[] = []
  455. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  456. const data = scene_data.page_widget_list[index];
  457. if(data.type===config.Widget_Type_List.UI_TOP){
  458. if(data.att.top_data!=null&&data.att.top_data.top_ui_type!=config.top_view_type.__null){
  459. temp.push(data)
  460. }
  461. }
  462. }
  463. return temp;
  464. }
  465. public isCurScenePageCheckWidgetFinish(widget_id:number){
  466. return this.mGameRun.isCurScenePageCheckWidgetFinish(widget_id);
  467. }
  468. public isCurScenePageCheckWidgetShow(widget_id:number){
  469. return this.mGameRun.isCurScenePageCheckWidgetShow(widget_id);
  470. }
  471. public static getQuestionwidgetList(scene_data:scene_item_data){
  472. let temp:widget_item_data[] = []
  473. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  474. const data = scene_data.page_widget_list[index];
  475. if(data.type===config.Widget_Type_List.QUESTION_SELECT){
  476. if(data.att.question_select!=null){
  477. temp.push(data)
  478. }
  479. }
  480. }
  481. return temp;
  482. }
  483. public static getTextSoundWidgetList(scene_data:scene_item_data){
  484. let temp:widget_item_data[] = []
  485. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  486. const data = scene_data.page_widget_list[index];
  487. if(data.type===config.Widget_Type_List.TEXT_SOUND){
  488. if(data.att.text_sound_data!=null){
  489. temp.push(data)
  490. }
  491. }
  492. }
  493. return temp;
  494. }
  495. public static getCountDownWidgetList(scene_data:scene_item_data){
  496. let temp:widget_item_data[] = []
  497. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  498. const data = scene_data.page_widget_list[index];
  499. if(data.type===config.Widget_Type_List.COUNT_DOWN){
  500. if(data.att.count_down!=null){
  501. temp.push(data)
  502. }
  503. }
  504. }
  505. return temp;
  506. }
  507. public static getCacheSpriteFrameByName(node:Node,sfName:string){
  508. let sf = gameManager.res_map.get(sfName)
  509. if(sf==null){
  510. if(node!=null){
  511. tools.loadUrl(sfName,node.getComponent(Sprite))
  512. }
  513. }
  514. return sf
  515. }
  516. public static getCacheSoundByName(sfName:string){
  517. // return control.mp3_cache.get(sfName)
  518. return gameManager.mp3_cache.get(sfName)
  519. }
  520. public static initUiBaseAtt(node:Node,att:ui_att_item){
  521. node.getComponent(UITransform).setContentSize(new Size(att.width,att.height))
  522. node.position = new Vec3(att.x,att.y);
  523. node.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(node,att.res)
  524. }
  525. onWidgetFinishEvent(widget_id:number){
  526. taskServce.onWidgetFinishEvent(widget_id)
  527. }
  528. onWidgetFailEvent(widget_id:number){
  529. taskServce.onWidgetFailEvent(widget_id)
  530. }
  531. onUiCloseEvent(event_id:number){
  532. taskServce.extEventByEventId(event_id)
  533. }
  534. onUiFinishEvent(event_id:number){
  535. taskServce.extEventByEventId(event_id)
  536. }
  537. onUiFailEvent(event_id:number){
  538. taskServce.extEventByEventId(event_id)
  539. }
  540. onCountDownFailEvent(event_id:number){
  541. taskServce.extEventByEventId(event_id)
  542. }
  543. onStartCountDownEvent(event_id:number){
  544. taskServce.extEventByEventId(event_id)
  545. }
  546. exeEvent(event_id:number){
  547. taskServce.extEventByEventId(event_id)
  548. }
  549. exeSuccessTriggerEvent(trigger_event_id:number) {
  550. taskServce.exeSuccessTriggerEvent(trigger_event_id)
  551. }
  552. exeNextDelayEvent(event_item:event_item) {
  553. taskServce.exeNextDelayEvent(event_item)
  554. }
  555. showFindRuleTips(){
  556. this.mGameRun.showFindRuleTips()
  557. }
  558. showTips(){
  559. this.mGameRun.showTips()
  560. }
  561. showRule(){
  562. this.mGameRun.showRule()
  563. }
  564. getSceneManager(){
  565. return this.mSceneManager;
  566. }
  567. IsOpenRuleStatus(){
  568. return taskServce.guo_ju_qing_binding_event_id==-1;
  569. }
  570. //点击按钮音效
  571. public sys_click_button_music(){
  572. if(gameManager.sys_data!=null){
  573. this.mSysSound.playSound(gameManager.sys_data.content.sys_click_button_music)
  574. }
  575. }
  576. // //失败吓人音效
  577. // public sys_fail_scary_music(){
  578. // if(gameManager.sys_data!=null){
  579. // this.mSysSound.playSound(gameManager.sys_data.content.sys_fail_scary_music)
  580. // }
  581. // }
  582. //失败后攻击音效
  583. public sys_fail_attack_music(){
  584. if(gameManager.sys_data!=null){
  585. this.mSysSound.playSound(gameManager.sys_data.content.sys_fail_attack_music)
  586. }
  587. }
  588. //失败提示音效
  589. public sys_fail_prompt_music(){
  590. if(gameManager.sys_data!=null){
  591. this.mSysSound.playSound(gameManager.sys_data.content.sys_fail_prompt_music)
  592. }
  593. }
  594. //正确通关音效
  595. public sys_success_complete_music(){
  596. if(gameManager.sys_data!=null){
  597. this.mSysSound.playSound(gameManager.sys_data.content.sys_success_complete_music)
  598. }
  599. }
  600. //点击正确细节音效
  601. public sys_click_correct_detail_music(){
  602. if(gameManager.sys_data!=null){
  603. this.mSysSound.playSound(gameManager.sys_data.content.sys_click_correct_detail_music)
  604. }
  605. }
  606. public checkWidgetList(list:other_widget_finish_listen_item[]):number{
  607. let event_id = -1;
  608. for (let index = 0; index < list.length; index++) {
  609. const item = list[index];
  610. let isFinish = this.mGameRun.isCurScenePageCheckWidgetFinish(item.widget_id)
  611. if(!isFinish){
  612. event_id = item.event_id;
  613. break;
  614. }
  615. }
  616. return event_id;
  617. }
  618. public static getUserUnlockLevesData():UserUnlockLevesData{
  619. if(gameManager.g_userUnlockLevesData == null) {
  620. gameManager.g_userUnlockLevesData = new UserUnlockLevesData()
  621. }
  622. return gameManager.g_userUnlockLevesData;
  623. }
  624. public static setUserUnlockLevesData(data:any){
  625. if(gameManager.g_userUnlockLevesData == null) {
  626. gameManager.g_userUnlockLevesData = new UserUnlockLevesData()
  627. }
  628. if(data != null) {
  629. gameManager.g_userUnlockLevesData = data.content
  630. // console.log('g_userUnlockLevesData=',gameManager.g_userUnlockLevesData)
  631. }
  632. }
  633. public static LookVideoCallBack(call){
  634. if(call!=null){
  635. call()
  636. }
  637. }
  638. public getCurSceneLayerPage(){
  639. return this.mGameRun.getCurSceneLayerPage()
  640. }
  641. public setScheduleOnce(callback:any, delay?:number) {
  642. this.scheduleOnce(callback,delay)
  643. }
  644. public static request_user_unlock_number_status(status = config.User_unlock_levels_number_status.GET, success_callback:any, fail_callback:any) {
  645. if(status != config.User_unlock_levels_number_status.GET) {
  646. gameManager.Singleton.showLoadingLevel()
  647. }
  648. http.run_post(http.user_unlock_number_status(),{'stype':status}, (err,data)=> {
  649. // console.log('err=',err,'status=',status,'解锁次数=',data)
  650. if(status != config.User_unlock_levels_number_status.GET) {
  651. gameManager.Singleton.hideLoadingLevel()
  652. }
  653. if(!err) {
  654. let _data = JSON.parse(data)
  655. if(_data.code==config.MSG_CODE.SUCCESS){
  656. gameManager.setUserUnlockLevesData(_data)
  657. success_callback(_data)
  658. } else{
  659. fail_callback()
  660. }
  661. } else {
  662. fail_callback()
  663. }
  664. })
  665. }
  666. }