gameManager.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  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, 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.offAll(config.EventRun.MORE_SCENE_DIRECTION_BUTTON_CLICK_FINISH)
  324. ClientEvent.on(config.EventRun.WIDGET_FINISH,this.onWidgetFinishEvent.bind(this),this)
  325. ClientEvent.on(config.EventRun.WIDGET_FAIL,this.onWidgetFailEvent.bind(this),this)
  326. ClientEvent.on(config.EventRun.TOP_VIEW_CLOSE,this.onUiCloseEvent.bind(this),this)
  327. ClientEvent.on(config.EventRun.TOP_VIEW_FINISH,this.onUiFinishEvent.bind(this),this)
  328. ClientEvent.on(config.EventRun.TOP_VIEW_FAIL,this.onUiFailEvent.bind(this),this)
  329. ClientEvent.on(config.EventRun.ON_COUNT_DOWN_FAIL,this.onCountDownFailEvent.bind(this),this)
  330. ClientEvent.on(config.EventRun.ON_COUNT_DOWN_START,this.onStartCountDownEvent.bind(this),this)
  331. ClientEvent.on(config.EventRun.MORE_SCENE_DIRECTION_BUTTON_CLICK_FINISH,this.onMoreSceneDirectionButtonClickEvent.bind(this),this)
  332. }
  333. public initGR(gr:game_run){
  334. this.mGameRun = gr;
  335. gameManager.Singleton = this;
  336. this.mSceneManager.init(this)
  337. this.clearRes()
  338. }
  339. public clearRes(){
  340. gameManager.res_map.clear()
  341. gameManager.mp3_cache.clear()
  342. }
  343. public init(gr:game_run,data:scene_item_data[]){
  344. // this.mGameRun = gr;
  345. // gameManager.Singleton = this;
  346. // this.mSceneManager.init(this)
  347. // this.mCurSceneIndex = main.Singleton.edit_scene_view.getCurSelectSceneIndex()
  348. // this.mGameData = data;
  349. // if( this.mGameData.length<=0){
  350. // return tools.showToast("错误的场景信息")
  351. // }
  352. // this.startLevelGame()
  353. }
  354. public runGame(data:scene_item_data[]){
  355. this.mCurSceneIndex = 0;
  356. this.mGameData = data;
  357. if( this.mGameData.length<=0){
  358. return tools.showToast("错误的场景信息")
  359. }
  360. this.startLevelGame()
  361. }
  362. public onLaunch(call){
  363. this.mGameRun.onlaunch(call)
  364. }
  365. public getTopFloorLayer():Node {
  366. return this.mGameRun.top_floor_layer;
  367. }
  368. FilterChildScene(data:scene_item_data[]){
  369. let temp_scene = []
  370. for (let index = 0; index < data.length; index++) {
  371. const element = data[index];
  372. if(!element.is_child_scene){
  373. temp_scene.push(element)
  374. }
  375. }
  376. return temp_scene;
  377. }
  378. protected onDestroy(): void {
  379. ClientEvent.off(config.EventRun.WIDGET_FINISH,this.onWidgetFinishEvent.bind(this),this)
  380. }
  381. public startLevelGame(){
  382. this.mGameRun.unInit()
  383. this.initEvent()
  384. // console.log("this.mGameData",this.mGameData,this.mCurSceneIndex)
  385. this.mSceneManager.startLevelGame(this.mGameData[this.mCurSceneIndex])
  386. taskServce.initTask(this.mGameData[this.mCurSceneIndex]._task_data)
  387. this.scheduleOnce(()=>{
  388. this.startGame()
  389. },0.5)
  390. if(gameManager.Singleton.getLevelData()){
  391. // this.mSceneManager.playMusic(this.mLevelData.piped_music,true)
  392. }
  393. }
  394. public loadSceneTask(data: task_data) {
  395. this.mGameRun.loadSceneTask(data)
  396. }
  397. public loadScene(pages: scene_item_data[],type:number){
  398. this.mGameRun.loadSceneLayer(pages,type)
  399. }
  400. public loadUi(ui_widge_list:widget_item_data[]){
  401. this.mGameRun.loadUILayer(ui_widge_list)
  402. }
  403. public loadTextSound(ui_widge_list:widget_item_data[]){
  404. this.mGameRun.loadTextSound(ui_widge_list)
  405. }
  406. public loadQuestion(ui_widge_list:widget_item_data[]){
  407. this.mGameRun.initQuestionList(ui_widge_list)
  408. }
  409. public initCountDownList(ui_widge_list:widget_item_data[]){
  410. this.mGameRun.initCountDownList(ui_widge_list)
  411. }
  412. public initTaskUi(data:task_data){
  413. this.mGameRun.initTaskUi(data)
  414. }
  415. public startGame(){
  416. taskServce.startFirstEvent()
  417. }
  418. public showCheck(call){
  419. this.mGameRun.showCheck(call)
  420. }
  421. public showLoadingLevel(){
  422. this.mGameRun.showLoadingLevel()
  423. }
  424. public hideLoadingLevel(){
  425. this.mGameRun.hideLoadingLevel()
  426. }
  427. public showUnLockView(lock_one_call,lock_all_one_day){
  428. this.mGameRun.showUnLockView(lock_one_call,lock_all_one_day)
  429. }
  430. public static getWidgetList(scene_data:scene_item_data):widget_item_data[]{
  431. let temp:widget_item_data[] = []
  432. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  433. const data = scene_data.page_widget_list[index];
  434. if(data.type<=4 ){
  435. temp.push(data)
  436. }
  437. }
  438. return temp;
  439. }
  440. public static getUIWidgetList(scene_data:scene_item_data){
  441. let temp:widget_item_data[] = []
  442. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  443. const data = scene_data.page_widget_list[index];
  444. if(data.type===config.Widget_Type_List.UI_TOP){
  445. if(data.att.top_data!=null&&data.att.top_data.top_ui_type!=config.top_view_type.__null){
  446. temp.push(data)
  447. }
  448. }
  449. }
  450. return temp;
  451. }
  452. public isCurScenePageCheckWidgetFinish(widget_id:number){
  453. return this.mGameRun.isCurScenePageCheckWidgetFinish(widget_id);
  454. }
  455. public isCurScenePageCheckWidgetShow(widget_id:number){
  456. return this.mGameRun.isCurScenePageCheckWidgetShow(widget_id);
  457. }
  458. public static getQuestionwidgetList(scene_data:scene_item_data){
  459. let temp:widget_item_data[] = []
  460. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  461. const data = scene_data.page_widget_list[index];
  462. if(data.type===config.Widget_Type_List.QUESTION_SELECT){
  463. if(data.att.question_select!=null){
  464. temp.push(data)
  465. }
  466. }
  467. }
  468. return temp;
  469. }
  470. public static getTextSoundWidgetList(scene_data:scene_item_data){
  471. let temp:widget_item_data[] = []
  472. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  473. const data = scene_data.page_widget_list[index];
  474. if(data.type===config.Widget_Type_List.TEXT_SOUND){
  475. if(data.att.text_sound_data!=null){
  476. temp.push(data)
  477. }
  478. }
  479. }
  480. return temp;
  481. }
  482. public static getCountDownWidgetList(scene_data:scene_item_data){
  483. let temp:widget_item_data[] = []
  484. for (let index = 0; index < scene_data.page_widget_list.length; index++) {
  485. const data = scene_data.page_widget_list[index];
  486. if(data.type===config.Widget_Type_List.COUNT_DOWN){
  487. if(data.att.count_down!=null){
  488. temp.push(data)
  489. }
  490. }
  491. }
  492. return temp;
  493. }
  494. public static getCacheSpriteFrameByName(node:Node,sfName:string){
  495. let sf = gameManager.res_map.get(sfName)
  496. if(sf==null){
  497. if(node!=null){
  498. tools.loadUrl(sfName,node.getComponent(Sprite))
  499. }
  500. }
  501. return sf
  502. }
  503. public static getCacheSoundByName(sfName:string){
  504. // return control.mp3_cache.get(sfName)
  505. return gameManager.mp3_cache.get(sfName)
  506. }
  507. public static initUiBaseAtt(node:Node,att:ui_att_item){
  508. node.getComponent(UITransform).setContentSize(new Size(att.width,att.height))
  509. node.position = new Vec3(att.x,att.y);
  510. node.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(node,att.res)
  511. }
  512. onWidgetFinishEvent(widget_id:number){
  513. taskServce.onWidgetFinishEvent(widget_id)
  514. }
  515. onWidgetFailEvent(widget_id:number){
  516. taskServce.onWidgetFailEvent(widget_id)
  517. }
  518. onUiCloseEvent(event_id:number){
  519. taskServce.extEventByEventId(event_id)
  520. }
  521. onUiFinishEvent(event_id:number){
  522. taskServce.extEventByEventId(event_id)
  523. }
  524. onUiFailEvent(event_id:number){
  525. taskServce.extEventByEventId(event_id)
  526. }
  527. onCountDownFailEvent(event_id:number){
  528. taskServce.extEventByEventId(event_id)
  529. }
  530. onStartCountDownEvent(event_id:number){
  531. taskServce.extEventByEventId(event_id)
  532. }
  533. exeEvent(event_id:number){
  534. taskServce.extEventByEventId(event_id)
  535. }
  536. onMoreSceneDirectionButtonClickEvent(event_id:number){
  537. taskServce.extEventByEventId(event_id)
  538. }
  539. showFindRuleTips(){
  540. this.mGameRun.showFindRuleTips()
  541. }
  542. showTips(){
  543. this.mGameRun.showTips()
  544. }
  545. showRule(){
  546. this.mGameRun.showRule()
  547. }
  548. getSceneManager(){
  549. return this.mSceneManager;
  550. }
  551. IsOpenRuleStatus(){
  552. return taskServce.guo_ju_qing_binding_event_id==-1;
  553. }
  554. //点击按钮音效
  555. public sys_click_button_music(){
  556. if(gameManager.sys_data!=null){
  557. this.mSysSound.playSound(gameManager.sys_data.content.sys_click_button_music)
  558. }
  559. }
  560. // //失败吓人音效
  561. // public sys_fail_scary_music(){
  562. // if(gameManager.sys_data!=null){
  563. // this.mSysSound.playSound(gameManager.sys_data.content.sys_fail_scary_music)
  564. // }
  565. // }
  566. //失败后攻击音效
  567. public sys_fail_attack_music(){
  568. if(gameManager.sys_data!=null){
  569. this.mSysSound.playSound(gameManager.sys_data.content.sys_fail_attack_music)
  570. }
  571. }
  572. //失败提示音效
  573. public sys_fail_prompt_music(){
  574. if(gameManager.sys_data!=null){
  575. this.mSysSound.playSound(gameManager.sys_data.content.sys_fail_prompt_music)
  576. }
  577. }
  578. //正确通关音效
  579. public sys_success_complete_music(){
  580. if(gameManager.sys_data!=null){
  581. this.mSysSound.playSound(gameManager.sys_data.content.sys_success_complete_music)
  582. }
  583. }
  584. //点击正确细节音效
  585. public sys_click_correct_detail_music(){
  586. if(gameManager.sys_data!=null){
  587. this.mSysSound.playSound(gameManager.sys_data.content.sys_click_correct_detail_music)
  588. }
  589. }
  590. public checkWidgetList(list:other_widget_finish_listen_item[]):number{
  591. let event_id = -1;
  592. for (let index = 0; index < list.length; index++) {
  593. const item = list[index];
  594. let isFinish = this.mGameRun.isCurScenePageCheckWidgetFinish(item.widget_id)
  595. if(!isFinish){
  596. event_id = item.event_id;
  597. break;
  598. }
  599. }
  600. return event_id;
  601. }
  602. public static getUserUnlockLevesData():UserUnlockLevesData{
  603. if(gameManager.g_userUnlockLevesData == null) {
  604. gameManager.g_userUnlockLevesData = new UserUnlockLevesData()
  605. }
  606. return gameManager.g_userUnlockLevesData;
  607. }
  608. public static setUserUnlockLevesData(data:any){
  609. if(gameManager.g_userUnlockLevesData == null) {
  610. gameManager.g_userUnlockLevesData = new UserUnlockLevesData()
  611. }
  612. if(data != null) {
  613. gameManager.g_userUnlockLevesData = data.content
  614. // console.log('g_userUnlockLevesData=',gameManager.g_userUnlockLevesData)
  615. }
  616. }
  617. public static request_user_unlock_number_status(status = config.User_unlock_levels_number_status.GET, success_callback:any, fail_callback:any) {
  618. if(status != config.User_unlock_levels_number_status.GET) {
  619. gameManager.Singleton.showLoadingLevel()
  620. }
  621. http.run_post(http.user_unlock_number_status(),{'stype':status}, (err,data)=> {
  622. // console.log('err=',err,'status=',status,'解锁次数=',data)
  623. if(status != config.User_unlock_levels_number_status.GET) {
  624. gameManager.Singleton.hideLoadingLevel()
  625. }
  626. if(!err) {
  627. let _data = JSON.parse(data)
  628. if(_data.code==config.MSG_CODE.SUCCESS){
  629. gameManager.setUserUnlockLevesData(_data)
  630. success_callback(_data)
  631. } else{
  632. fail_callback()
  633. }
  634. } else {
  635. fail_callback()
  636. }
  637. })
  638. }
  639. }