gameManager.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  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 static loadSceneMp3(){
  189. }
  190. public static getUserData():UserData{
  191. let str = sys.localStorage.getItem(config.USER_DATA)
  192. if(str==undefined||str==""||str==null){
  193. return null;
  194. }
  195. let user:UserData = JSON.parse(str)
  196. return user;
  197. }
  198. public static getStaticUserData(){
  199. return gameManager.g_userData
  200. }
  201. public static setUserData(user:UserData){
  202. gameManager.g_userData = user;
  203. gameManager.saveUserData()
  204. }
  205. public static saveUserData(){
  206. if(gameManager.g_userData!=null){
  207. sys.localStorage.setItem(config.USER_DATA, JSON.stringify(gameManager.g_userData));
  208. }
  209. }
  210. public static getZbOpenid(): string {
  211. let zb_openid = '';
  212. try {
  213. zb_openid = sys.localStorage.getItem(config.ZB_OPENID)
  214. } catch {
  215. console.log("getZbOpenid fail")
  216. }
  217. return zb_openid
  218. }
  219. public static setZbOpenid(id: String) {
  220. sys.localStorage.setItem(config.ZB_OPENID, id)
  221. }
  222. public reLife(){
  223. let ad_id = SdkUtil.getAdId(config.AD_TYPE.RE_LIFE)
  224. SdkUtil.showVideoAd(ad_id,(res)=>{
  225. if(res.isEnded){
  226. this.mGameRun.onlaunch(()=>{
  227. gameManager.Singleton.startLevelGame()
  228. })
  229. }
  230. // 统计-激励视频广告
  231. let level_id = gameManager.Singleton.getLevelData().id
  232. let collect_data = statisticsManager.get_collect_data(level_id, res, config.STATISTICS_ACTION_TYPE.GUAN_KA_FU_HUO)
  233. statisticsManager.request_collect_rewardVideoData(collect_data)
  234. })
  235. }
  236. public reStartGame(){
  237. this.mGameRun.onlaunch(()=>{
  238. this.mCurSceneIndex = 0;
  239. gameManager.Singleton.startLevelGame()
  240. })
  241. }
  242. public levleIsUnLock(levle_id:number){
  243. let isunlock = false;
  244. for (let index = 0; index < gameManager.getStaticUserData().unlock_levels.length; index++) {
  245. const id = gameManager.getStaticUserData().unlock_levels[index];
  246. if(id==levle_id){
  247. isunlock = true;
  248. break;
  249. }
  250. }
  251. return isunlock
  252. }
  253. public unLockLevel(levle_id:number){
  254. let is_have = false;
  255. for (let index = 0; index < gameManager.getStaticUserData().unlock_levels.length; index++) {
  256. const id = gameManager.getStaticUserData().unlock_levels[index];
  257. if(id==levle_id){
  258. is_have = true;
  259. break;
  260. }
  261. }
  262. if(!is_have){
  263. gameManager.getStaticUserData().unlock_levels.push(levle_id)
  264. gameManager.saveUserData()
  265. gameManager.Singleton.sync_data()
  266. }
  267. }
  268. public sync_data(){
  269. let url = http.sync_data()
  270. let unlock_levels = gameManager.getStaticUserData().unlock_levels;
  271. http.run_post(url,{"unlock_levels":JSON.stringify(unlock_levels)},(err,data)=>{
  272. if(!err){
  273. // console.log("sync_data finish!"+JSON.stringify(unlock_levels));
  274. }
  275. })
  276. }
  277. public nextScene(){
  278. this.onLaunch(()=>{
  279. this.mCurSceneIndex++;
  280. let not_scene = false;
  281. if(this.mCurSceneIndex>=this.mGameData.length){
  282. not_scene = true;
  283. }
  284. if(!not_scene){
  285. this.mGameRun.unInit()
  286. this.startLevelGame()
  287. }else{
  288. // tools.showToast("没有场景了!")
  289. }
  290. })
  291. }
  292. public gameOver(){
  293. ClientEvent.dispatchEvent(config.EventRun.ON_WIN)
  294. }
  295. public gotoGameLevel() {
  296. SdkUtil.ttStartScreenRecording()
  297. }
  298. public backGameList(){
  299. if(!gameManager.isLoadingStatus){
  300. this.unscheduleAllCallbacks()
  301. this.mGameRun.backGameList()
  302. gameManager.Singleton.mSceneManager.play_music()
  303. }else{
  304. console.log("没有全部加载完成!")
  305. }
  306. SdkUtil.ttStopScreenRecording(true)
  307. }
  308. public initEvent(){
  309. ClientEvent.offAll(config.EventRun.NOTICE_EVENT)
  310. ClientEvent.offAll(config.EventRun.WIDGET_FINISH)
  311. ClientEvent.offAll(config.EventRun.WIDGET_FAIL)
  312. ClientEvent.offAll(config.EventRun.ON_WIDGET_FINISH_COLLECT_EVENT)
  313. ClientEvent.offAll(config.EventRun.WIDGET_HIDE)
  314. ClientEvent.offAll(config.EventRun.SHOW_ZHAO_BU_TONG_FINISH_STATUS)
  315. ClientEvent.offAll(config.EventRun.ON_ZHAO_BU_TONG_ALL_FINISH)
  316. ClientEvent.offAll(config.EventRun.TOP_VIEW_CLOSE)
  317. ClientEvent.offAll(config.EventRun.TOP_VIEW_FINISH)
  318. ClientEvent.offAll(config.EventRun.TOP_VIEW_FAIL)
  319. ClientEvent.offAll(config.EventRun.ON_COUNT_DOWN_FAIL)
  320. ClientEvent.offAll(config.EventRun.ON_COUNT_DOWN_START)
  321. ClientEvent.offAll(config.EventRun.ON_SHOW_RULE_BTN)
  322. ClientEvent.offAll(config.EventRun.ON_BOSS_HURT)
  323. ClientEvent.on(config.EventRun.WIDGET_FINISH,this.onWidgetFinishEvent.bind(this),this)
  324. ClientEvent.on(config.EventRun.WIDGET_FAIL,this.onWidgetFailEvent.bind(this),this)
  325. ClientEvent.on(config.EventRun.TOP_VIEW_CLOSE,this.onUiCloseEvent.bind(this),this)
  326. ClientEvent.on(config.EventRun.TOP_VIEW_FINISH,this.onUiFinishEvent.bind(this),this)
  327. ClientEvent.on(config.EventRun.TOP_VIEW_FAIL,this.onUiFailEvent.bind(this),this)
  328. ClientEvent.on(config.EventRun.ON_COUNT_DOWN_FAIL,this.onCountDownFailEvent.bind(this),this)
  329. ClientEvent.on(config.EventRun.ON_COUNT_DOWN_START,this.onStartCountDownEvent.bind(this),this)
  330. }
  331. public initGR(gr:game_run){
  332. this.mGameRun = gr;
  333. gameManager.Singleton = this;
  334. this.mSceneManager.init(this)
  335. this.clearRes()
  336. }
  337. public clearRes(){
  338. gameManager.res_map.clear()
  339. gameManager.mp3_cache.clear()
  340. }
  341. public init(gr:game_run,data:scene_item_data[]){
  342. // this.mGameRun = gr;
  343. // gameManager.Singleton = this;
  344. // this.mSceneManager.init(this)
  345. // this.mCurSceneIndex = main.Singleton.edit_scene_view.getCurSelectSceneIndex()
  346. // this.mGameData = data;
  347. // if( this.mGameData.length<=0){
  348. // return tools.showToast("错误的场景信息")
  349. // }
  350. // this.startLevelGame()
  351. }
  352. public runGame(data:scene_item_data[]){
  353. this.mCurSceneIndex = 0;
  354. this.mGameData = data;
  355. if( this.mGameData.length<=0){
  356. return tools.showToast("错误的场景信息")
  357. }
  358. this.startLevelGame()
  359. }
  360. public onLaunch(call,delay=0.7){
  361. this.mGameRun.onlaunch(call)
  362. }
  363. public getTopFloorLayer():Node {
  364. return this.mGameRun.top_floor_layer;
  365. }
  366. FilterChildScene(data:scene_item_data[]){
  367. let temp_scene = []
  368. for (let index = 0; index < data.length; index++) {
  369. const element = data[index];
  370. if(!element.is_child_scene){
  371. temp_scene.push(element)
  372. }
  373. }
  374. return temp_scene;
  375. }
  376. protected onDestroy(): void {
  377. ClientEvent.off(config.EventRun.WIDGET_FINISH,this.onWidgetFinishEvent.bind(this),this)
  378. }
  379. public startLevelGame(){
  380. this.mGameRun.unInit()
  381. this.initEvent()
  382. // console.log("this.mGameData",this.mGameData,this.mCurSceneIndex)
  383. this.mSceneManager.startLevelGame(this.mGameData[this.mCurSceneIndex])
  384. taskServce.initTask(this.mGameData[this.mCurSceneIndex]._task_data)
  385. this.scheduleOnce(()=>{
  386. this.startGame()
  387. },0.5)
  388. if(gameManager.Singleton.getLevelData()){
  389. // this.mSceneManager.playMusic(this.mLevelData.piped_music,true)
  390. }
  391. }
  392. public loadSceneTask(data: task_data) {
  393. this.mGameRun.loadSceneTask(data)
  394. }
  395. public loadScene(pages: scene_item_data[],type:number){
  396. this.mGameRun.loadSceneLayer(pages,type)
  397. }
  398. public loadUi(ui_widge_list:widget_item_data[]){
  399. this.mGameRun.loadUILayer(ui_widge_list)
  400. }
  401. public loadTextSound(ui_widge_list:widget_item_data[]){
  402. this.mGameRun.loadTextSound(ui_widge_list)
  403. }
  404. public loadQuestion(ui_widge_list:widget_item_data[]){
  405. this.mGameRun.initQuestionList(ui_widge_list)
  406. }
  407. public initCountDownList(ui_widge_list:widget_item_data[]){
  408. this.mGameRun.initCountDownList(ui_widge_list)
  409. }
  410. public initTaskUi(data:task_data){
  411. this.mGameRun.initTaskUi(data)
  412. }
  413. public startGame(){
  414. taskServce.startFirstEvent()
  415. }
  416. public showCheck(call){
  417. this.mGameRun.showCheck(call)
  418. }
  419. public showLoadingLevel(){
  420. this.mGameRun.showLoadingLevel()
  421. }
  422. public hideLoadingLevel(){
  423. this.mGameRun.hideLoadingLevel()
  424. }
  425. public showUnLockView(lock_one_call,lock_all_one_day){
  426. this.mGameRun.showUnLockView(lock_one_call,lock_all_one_day)
  427. }
  428. public static getWidgetList(scene_data:scene_item_data):widget_item_data[]{
  429. let temp:widget_item_data[] = []
  430. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  431. const data = scene_data.page_widget_list[index];
  432. if(data.type<=4 ){
  433. temp.push(data)
  434. }
  435. }
  436. return temp;
  437. }
  438. public static getUIWidgetList(scene_data:scene_item_data){
  439. let temp:widget_item_data[] = []
  440. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  441. const data = scene_data.page_widget_list[index];
  442. if(data.type===config.Widget_Type_List.UI_TOP){
  443. if(data.att.top_data!=null&&data.att.top_data.top_ui_type!=config.top_view_type.__null){
  444. temp.push(data)
  445. }
  446. }
  447. }
  448. return temp;
  449. }
  450. public isCurScenePageCheckWidgetFinish(widget_id:number){
  451. return this.mGameRun.isCurScenePageCheckWidgetFinish(widget_id);
  452. }
  453. public isCurScenePageCheckWidgetShow(widget_id:number){
  454. return this.mGameRun.isCurScenePageCheckWidgetShow(widget_id);
  455. }
  456. public static getQuestionwidgetList(scene_data:scene_item_data){
  457. let temp:widget_item_data[] = []
  458. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  459. const data = scene_data.page_widget_list[index];
  460. if(data.type===config.Widget_Type_List.QUESTION_SELECT){
  461. if(data.att.question_select!=null){
  462. temp.push(data)
  463. }
  464. }
  465. }
  466. return temp;
  467. }
  468. public static getTextSoundWidgetList(scene_data:scene_item_data){
  469. let temp:widget_item_data[] = []
  470. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  471. const data = scene_data.page_widget_list[index];
  472. if(data.type===config.Widget_Type_List.TEXT_SOUND){
  473. if(data.att.text_sound_data!=null){
  474. temp.push(data)
  475. }
  476. }
  477. }
  478. return temp;
  479. }
  480. public static getCountDownWidgetList(scene_data:scene_item_data){
  481. let temp:widget_item_data[] = []
  482. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  483. const data = scene_data.page_widget_list[index];
  484. if(data.type===config.Widget_Type_List.COUNT_DOWN){
  485. if(data.att.count_down!=null){
  486. temp.push(data)
  487. }
  488. }
  489. }
  490. return temp;
  491. }
  492. public static getCacheSpriteFrameByName(node:Node,sfName:string){
  493. let sf = gameManager.res_map.get(sfName)
  494. if(sf==null){
  495. if(node!=null){
  496. tools.loadUrl(sfName,node.getComponent(Sprite))
  497. }
  498. }
  499. return sf
  500. }
  501. public static getCacheSoundByName(sfName:string){
  502. // return control.mp3_cache.get(sfName)
  503. return gameManager.mp3_cache.get(sfName)
  504. }
  505. public static initUiBaseAtt(node:Node,att:ui_att_item){
  506. node.getComponent(UITransform).setContentSize(new Size(att.width,att.height))
  507. node.position = new Vec3(att.x,att.y);
  508. node.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(node,att.res)
  509. }
  510. onWidgetFinishEvent(widget_id:number){
  511. taskServce.onWidgetFinishEvent(widget_id)
  512. }
  513. onWidgetFailEvent(widget_id:number){
  514. taskServce.onWidgetFailEvent(widget_id)
  515. }
  516. onUiCloseEvent(event_id:number){
  517. taskServce.extEventByEventId(event_id)
  518. }
  519. onUiFinishEvent(event_id:number){
  520. taskServce.extEventByEventId(event_id)
  521. }
  522. onUiFailEvent(event_id:number){
  523. taskServce.extEventByEventId(event_id)
  524. }
  525. onCountDownFailEvent(event_id:number){
  526. taskServce.extEventByEventId(event_id)
  527. }
  528. onStartCountDownEvent(event_id:number){
  529. taskServce.extEventByEventId(event_id)
  530. }
  531. exeEvent(event_id:number){
  532. taskServce.extEventByEventId(event_id)
  533. }
  534. exeSuccessTriggerEvent(trigger_event_id:number) {
  535. taskServce.exeSuccessTriggerEvent(trigger_event_id)
  536. }
  537. exeNextDelayEvent(event_item:event_item) {
  538. taskServce.exeNextDelayEvent(event_item)
  539. }
  540. showFindRuleTips(){
  541. this.mGameRun.showFindRuleTips()
  542. }
  543. showTips(){
  544. this.mGameRun.showTips()
  545. }
  546. showRule(){
  547. this.mGameRun.showRule()
  548. }
  549. getSceneManager(){
  550. return this.mSceneManager;
  551. }
  552. IsOpenRuleStatus(){
  553. return taskServce.guo_ju_qing_binding_event_id==-1;
  554. }
  555. //点击按钮音效
  556. public sys_click_button_music(){
  557. if(gameManager.sys_data!=null){
  558. this.mSysSound.playSound(gameManager.sys_data.content.sys_click_button_music)
  559. }
  560. }
  561. // //失败吓人音效
  562. // public sys_fail_scary_music(){
  563. // if(gameManager.sys_data!=null){
  564. // this.mSysSound.playSound(gameManager.sys_data.content.sys_fail_scary_music)
  565. // }
  566. // }
  567. //失败后攻击音效
  568. public sys_fail_attack_music(){
  569. if(gameManager.sys_data!=null){
  570. this.mSysSound.playSound(gameManager.sys_data.content.sys_fail_attack_music)
  571. }
  572. }
  573. //失败提示音效
  574. public sys_fail_prompt_music(){
  575. if(gameManager.sys_data!=null){
  576. this.mSysSound.playSound(gameManager.sys_data.content.sys_fail_prompt_music)
  577. }
  578. }
  579. //正确通关音效
  580. public sys_success_complete_music(){
  581. if(gameManager.sys_data!=null){
  582. this.mSysSound.playSound(gameManager.sys_data.content.sys_success_complete_music)
  583. }
  584. }
  585. //点击正确细节音效
  586. public sys_click_correct_detail_music(){
  587. if(gameManager.sys_data!=null){
  588. this.mSysSound.playSound(gameManager.sys_data.content.sys_click_correct_detail_music)
  589. }
  590. }
  591. public checkWidgetList(list:other_widget_finish_listen_item[]):number{
  592. let event_id = -1;
  593. for (let index = 0; index < list.length; index++) {
  594. const item = list[index];
  595. let isFinish = this.mGameRun.isCurScenePageCheckWidgetFinish(item.widget_id)
  596. if(!isFinish){
  597. event_id = item.event_id;
  598. break;
  599. }
  600. }
  601. return event_id;
  602. }
  603. public static getUserUnlockLevesData():UserUnlockLevesData{
  604. if(gameManager.g_userUnlockLevesData == null) {
  605. gameManager.g_userUnlockLevesData = new UserUnlockLevesData()
  606. }
  607. return gameManager.g_userUnlockLevesData;
  608. }
  609. public static setUserUnlockLevesData(data:any){
  610. if(gameManager.g_userUnlockLevesData == null) {
  611. gameManager.g_userUnlockLevesData = new UserUnlockLevesData()
  612. }
  613. if(data != null) {
  614. gameManager.g_userUnlockLevesData = data.content
  615. // console.log('g_userUnlockLevesData=',gameManager.g_userUnlockLevesData)
  616. }
  617. }
  618. public static request_user_unlock_number_status(status = config.User_unlock_levels_number_status.GET, success_callback:any, fail_callback:any) {
  619. if(status != config.User_unlock_levels_number_status.GET) {
  620. gameManager.Singleton.showLoadingLevel()
  621. }
  622. http.run_post(http.user_unlock_number_status(),{'stype':status}, (err,data)=> {
  623. // console.log('err=',err,'status=',status,'解锁次数=',data)
  624. if(status != config.User_unlock_levels_number_status.GET) {
  625. gameManager.Singleton.hideLoadingLevel()
  626. }
  627. if(!err) {
  628. let _data = JSON.parse(data)
  629. if(_data.code==config.MSG_CODE.SUCCESS){
  630. gameManager.setUserUnlockLevesData(_data)
  631. success_callback(_data)
  632. } else{
  633. fail_callback()
  634. }
  635. } else {
  636. fail_callback()
  637. }
  638. })
  639. }
  640. }