|
@@ -1,14 +1,16 @@
|
|
|
-import { _decorator, Component, instantiate, Node, Prefab, resources, sys } from 'cc';
|
|
|
-import { server_han_zi_zhao_bu_tong_data, server_mei_nv_zhao_xi_jie_data, server_play_list_data, server_shuang_tu_zhao_bu_tong_data, server_user_info, unlock_levels, unlock_levels_item } from './data/server_play_list_data';
|
|
|
+import { _decorator, assetManager, AudioClip, Component, instantiate, Node, Prefab, resources, SpriteFrame, sys } from 'cc';
|
|
|
+import { server_han_zi_zhao_bu_tong_data, server_mei_nv_zhao_xi_jie_data, server_play_info, server_play_list_data, server_shuang_tu_zhao_bu_tong_data, server_sys_info, server_user_info, unlock_levels, unlock_levels_item } from './data/server_play_list_data';
|
|
|
import { config } from './config';
|
|
|
import { ClientEvent } from './framework/clientEvent';
|
|
|
import { http } from './http/http';
|
|
|
import { StorageManager } from './framework/storageManager';
|
|
|
import { tools } from './tools';
|
|
|
+import { AudioManager } from './framework/audioManager';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('gameManager')
|
|
|
export class gameManager extends Component {
|
|
|
+ public static g_server_sys_info:server_sys_info = new server_sys_info();
|
|
|
public static g_server_play_list_data:server_play_list_data = new server_play_list_data();
|
|
|
// public static g_server_shuang_tu_zhao_bu_tong_data:server_shuang_tu_zhao_bu_tong_data = new server_shuang_tu_zhao_bu_tong_data();
|
|
|
// public static g_server_han_zi_zhao_bu_tong_data:server_han_zi_zhao_bu_tong_data = new server_han_zi_zhao_bu_tong_data();
|
|
@@ -226,8 +228,9 @@ export class gameManager extends Component {
|
|
|
console.log("set_server_user_data::",data);
|
|
|
}
|
|
|
|
|
|
- public static set_server_play_list_data(data){
|
|
|
- gameManager.g_server_play_list_data.list = data;
|
|
|
+ public static set_server_play_list_data(data:server_play_info){
|
|
|
+ gameManager.g_server_play_list_data.list = data.wf_list;
|
|
|
+ gameManager.g_server_sys_info = data.sys_info;
|
|
|
ClientEvent.dispatchEvent(config.EVENT_MSG.ON_INIT_GAME_LIST);
|
|
|
console.log("set_server_play_list_data::",data);
|
|
|
}
|
|
@@ -288,11 +291,13 @@ export class gameManager extends Component {
|
|
|
call_back();
|
|
|
}
|
|
|
}
|
|
|
- tools.loadRemoteImg(data.img1,(sf)=>{
|
|
|
+ tools.loadRemoteImg(data.img1,(sf:SpriteFrame)=>{
|
|
|
+ sf.addRef();
|
|
|
img_count++;
|
|
|
img_call_back();
|
|
|
})
|
|
|
tools.loadRemoteImg(data.img2,(sf)=>{
|
|
|
+ sf.addRef();
|
|
|
img_count++;
|
|
|
img_call_back();
|
|
|
})
|
|
@@ -307,14 +312,17 @@ export class gameManager extends Component {
|
|
|
}
|
|
|
}
|
|
|
tools.loadRemoteImg(data.default_img,(sf)=>{
|
|
|
+ sf.addRef();
|
|
|
img_count_font++;
|
|
|
img_call_back_font();
|
|
|
})
|
|
|
tools.loadRemoteImg(data.find_img,(sf)=>{
|
|
|
+ sf.addRef();
|
|
|
img_count_font++;
|
|
|
img_call_back_font();
|
|
|
})
|
|
|
tools.loadRemoteImg(data.d_img,(sf)=>{
|
|
|
+ sf.addRef();
|
|
|
img_count_font++;
|
|
|
img_call_back_font();
|
|
|
})
|
|
@@ -329,6 +337,7 @@ export class gameManager extends Component {
|
|
|
}
|
|
|
}
|
|
|
tools.loadRemoteImg(data.img,(sf)=>{
|
|
|
+ sf.addRef();
|
|
|
img_count_component++;
|
|
|
img_call_back_component();
|
|
|
})
|
|
@@ -336,6 +345,7 @@ export class gameManager extends Component {
|
|
|
for (let index = 0; index < data.component.length; index++) {
|
|
|
const element = data.component[index];
|
|
|
tools.loadRemoteImg(element.img,(sf,id)=>{
|
|
|
+ sf.addRef();
|
|
|
img_count_component++;
|
|
|
img_call_back_component();
|
|
|
},element.id);
|
|
@@ -348,11 +358,101 @@ export class gameManager extends Component {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- // public static set_server_shuang_tu_zhao_bu_tong_data(data){
|
|
|
- // gameManager.g_server_shuang_tu_zhao_bu_tong_data.list = data;
|
|
|
- // console.log("set_server_shuang_tu_zhao_bu_tong_data::",data);
|
|
|
- // }
|
|
|
+ //通用的关闭按钮点击音效
|
|
|
+ public static playCloseBtnSound( loop:boolean = false){
|
|
|
+ let path = gameManager.g_server_sys_info.sys_click_button_music;
|
|
|
+ AudioManager.instance.playSound(path,loop)
|
|
|
+ }
|
|
|
+ //通用的按钮点击音效
|
|
|
+ public static playBtnSound( loop:boolean = false){
|
|
|
+ let path = gameManager.g_server_sys_info.sys_close_button_music;
|
|
|
+ AudioManager.instance.playSound(path,loop)
|
|
|
+ }
|
|
|
+ //每个玩法的胜利音效
|
|
|
+ public static playWinSoundByCategoryId(id:number, loop:boolean = false){
|
|
|
+ let paht = gameManager.get_play_list_item_by_categoryid(id).wf_victory_music;
|
|
|
+ AudioManager.instance.playSound(paht,loop)
|
|
|
+ }
|
|
|
+ //每个玩法的失败音效
|
|
|
+ public static playFailSoundByCategoryId(id:number, loop:boolean = false){
|
|
|
+ let paht = gameManager.get_play_list_item_by_categoryid(id).wf_fail_music;
|
|
|
+ AudioManager.instance.playSound(paht,loop)
|
|
|
+ }
|
|
|
+
|
|
|
+ //每个玩法的正确音效
|
|
|
+ public static playRightSoundByCategoryId(id:number, loop:boolean = false){
|
|
|
+ let paht = gameManager.get_play_list_item_by_categoryid(id).wf_right_click_music;
|
|
|
+ AudioManager.instance.playSound(paht,loop)
|
|
|
+ }
|
|
|
+ //每个玩法的错误音效
|
|
|
+ public static playErrSoundByCategoryId(id:number, loop:boolean = false){
|
|
|
+ let paht = gameManager.get_play_list_item_by_categoryid(id).wf_wrong_click_music;
|
|
|
+ AudioManager.instance.playSound(paht,loop)
|
|
|
+ }
|
|
|
+
|
|
|
+ //每个玩法的背景音乐
|
|
|
+ public static playGamePlayMusicByCategoryId(id:number, loop:boolean = false){
|
|
|
+ let path = gameManager.get_play_list_item_by_categoryid(id).wf_piped_music;
|
|
|
+ AudioManager.instance.playMusic(path,loop)
|
|
|
+ }
|
|
|
+ //主页的背景音乐
|
|
|
+ public static playMainMusic(loop:boolean = false){
|
|
|
+ let path = gameManager.g_server_sys_info.sys_piped_music;
|
|
|
+ AudioManager.instance.playMusic(path,loop)
|
|
|
+ }
|
|
|
+
|
|
|
+ public static loadSysMusic(call_back){
|
|
|
+ let count = 0;
|
|
|
+ let call = ()=>{
|
|
|
+ count++;
|
|
|
+ if(count>=3){
|
|
|
+ call_back()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ assetManager.loadRemote(gameManager.g_server_sys_info.sys_click_button_music, (err: any, clip: AudioClip)=> {
|
|
|
+ clip.addRef()
|
|
|
+ call()
|
|
|
+ });
|
|
|
+ assetManager.loadRemote(gameManager.g_server_sys_info.sys_close_button_music, (err: any, clip: AudioClip)=> {
|
|
|
+ clip.addRef()
|
|
|
+ call()
|
|
|
+ });
|
|
|
+ assetManager.loadRemote(gameManager.g_server_sys_info.sys_piped_music, (err: any, clip: AudioClip)=> {
|
|
|
+ clip.addRef()
|
|
|
+ call()
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
+ public static loadPlayMusicByCategoryId(id,call_back){
|
|
|
+ let count = 0;
|
|
|
+ let call = ()=>{
|
|
|
+ count++;
|
|
|
+ if(count>=5){
|
|
|
+ call_back()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let paly_item = gameManager.get_play_list_item_by_categoryid(id);
|
|
|
+ assetManager.loadRemote(paly_item.wf_fail_music, (err: any, clip: any)=> {
|
|
|
+ clip.addRef()
|
|
|
+ call()
|
|
|
+ });
|
|
|
+ assetManager.loadRemote(paly_item.wf_victory_music, (err: any, clip: any)=> {
|
|
|
+ clip.addRef()
|
|
|
+ call()
|
|
|
+ });
|
|
|
+ assetManager.loadRemote(paly_item.wf_right_click_music, (err: any, clip: any)=> {
|
|
|
+ clip.addRef()
|
|
|
+ call()
|
|
|
+ });
|
|
|
+ assetManager.loadRemote(paly_item.wf_wrong_click_music, (err: any, clip: any)=> {
|
|
|
+ clip.addRef()
|
|
|
+ call()
|
|
|
+ });
|
|
|
+ assetManager.loadRemote(paly_item.wf_piped_music, (err: any, clip: any)=> {
|
|
|
+ clip.addRef()
|
|
|
+ call()
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
// public static set_server_han_zi_zhao_bu_tong_data(data){
|
|
|
// gameManager.g_server_han_zi_zhao_bu_tong_data.list = data;
|