|
@@ -23,7 +23,8 @@ export class gameManager extends Component {
|
|
public static topViewList:Map<string,Node> = new Map();
|
|
public static topViewList:Map<string,Node> = new Map();
|
|
public static user_level_data:unlock_levels = new unlock_levels();
|
|
public static user_level_data:unlock_levels = new unlock_levels();
|
|
public static PreloadingLevelImgNumber:number = 0;//执行预加载的数量
|
|
public static PreloadingLevelImgNumber:number = 0;//执行预加载的数量
|
|
- public static cache:Map<string,SpriteFrame[]> = new Map();
|
|
|
|
|
|
+ public static cache:Map<string,Map<string,SpriteFrame>> = new Map();
|
|
|
|
+ public static mp3_cache:Map<string,AudioClip> = new Map();
|
|
public static test_user_list:string[] = [];
|
|
public static test_user_list:string[] = [];
|
|
start() {
|
|
start() {
|
|
|
|
|
|
@@ -98,7 +99,7 @@ export class gameManager extends Component {
|
|
gameManager.waitLayer = node;
|
|
gameManager.waitLayer = node;
|
|
}
|
|
}
|
|
|
|
|
|
- public static sync_data(){
|
|
|
|
|
|
+ public static sync_data(call_back){
|
|
let form_Data = null;
|
|
let form_Data = null;
|
|
if(sys.platform==sys.Platform.BYTEDANCE_MINI_GAME){
|
|
if(sys.platform==sys.Platform.BYTEDANCE_MINI_GAME){
|
|
form_Data = {"coin": gameManager.userInfo.coin+"","unlock_levels": gameManager.get_unlock_levels()}
|
|
form_Data = {"coin": gameManager.userInfo.coin+"","unlock_levels": gameManager.get_unlock_levels()}
|
|
@@ -115,7 +116,13 @@ export class gameManager extends Component {
|
|
console.log("c__data",c__data)
|
|
console.log("c__data",c__data)
|
|
if(c__data.code==config.MSG_CODE.SUCCESS){
|
|
if(c__data.code==config.MSG_CODE.SUCCESS){
|
|
ClientEvent.dispatchEvent(config.EVENT_MSG.ON_CHANGE_COIN_NUMBER);
|
|
ClientEvent.dispatchEvent(config.EVENT_MSG.ON_CHANGE_COIN_NUMBER);
|
|
|
|
+ call_back(true)
|
|
}
|
|
}
|
|
|
|
+ }else{
|
|
|
|
+ if(_err==-1){
|
|
|
|
+ call_back(false)
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
})
|
|
})
|
|
@@ -137,6 +144,7 @@ export class gameManager extends Component {
|
|
}
|
|
}
|
|
|
|
|
|
public static showLoading(){
|
|
public static showLoading(){
|
|
|
|
+ gameManager.hideLoading();
|
|
gameManager.addTopView(config.PREFAB_PATH.view_loading,null);
|
|
gameManager.addTopView(config.PREFAB_PATH.view_loading,null);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -161,13 +169,18 @@ export class gameManager extends Component {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public static next_level(categoryid:number):boolean{
|
|
|
|
|
|
+ public static next_level(categoryid:number,call_back):boolean{
|
|
let item = gameManager.get_cur_level_by_categoryid(categoryid);
|
|
let item = gameManager.get_cur_level_by_categoryid(categoryid);
|
|
let play_item = gameManager.get_play_list_item_by_categoryid(categoryid);
|
|
let play_item = gameManager.get_play_list_item_by_categoryid(categoryid);
|
|
if(item.level<play_item.barrier_number){
|
|
if(item.level<play_item.barrier_number){
|
|
- item.level+=1;
|
|
|
|
- gameManager.set_unlock_levels_data(item);
|
|
|
|
- gameManager.sync_data()
|
|
|
|
|
|
+ gameManager.sync_data((is_sync)=>{
|
|
|
|
+ if(is_sync){
|
|
|
|
+ item.level+=1;
|
|
|
|
+ gameManager.set_unlock_levels_data(item);
|
|
|
|
+ }
|
|
|
|
+ call_back(is_sync)
|
|
|
|
+
|
|
|
|
+ })
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
@@ -290,7 +303,7 @@ export class gameManager extends Component {
|
|
|
|
|
|
public static loadLevelImg(category_id,level,call_back){
|
|
public static loadLevelImg(category_id,level,call_back){
|
|
let key = `${category_id}_${level}`;
|
|
let key = `${category_id}_${level}`;
|
|
- let list = []
|
|
|
|
|
|
+ let list:Map<string,SpriteFrame> = new Map()
|
|
http.get(config.static_url.levels_info(category_id,level),(err,data)=>{
|
|
http.get(config.static_url.levels_info(category_id,level),(err,data)=>{
|
|
if(!err){
|
|
if(!err){
|
|
let _data = JSON.parse(data)
|
|
let _data = JSON.parse(data)
|
|
@@ -310,13 +323,13 @@ export class gameManager extends Component {
|
|
}
|
|
}
|
|
tools.loadRemoteImg(data.img1,(sf:SpriteFrame)=>{
|
|
tools.loadRemoteImg(data.img1,(sf:SpriteFrame)=>{
|
|
sf.addRef();
|
|
sf.addRef();
|
|
- list.push(sf);
|
|
|
|
|
|
+ list.set(data.img1,sf);
|
|
img_count++;
|
|
img_count++;
|
|
img_call_back();
|
|
img_call_back();
|
|
})
|
|
})
|
|
tools.loadRemoteImg(data.img2,(sf)=>{
|
|
tools.loadRemoteImg(data.img2,(sf)=>{
|
|
sf.addRef();
|
|
sf.addRef();
|
|
- list.push(sf);
|
|
|
|
|
|
+ list.set(data.img2,sf);
|
|
img_count++;
|
|
img_count++;
|
|
img_call_back();
|
|
img_call_back();
|
|
})
|
|
})
|
|
@@ -333,19 +346,19 @@ export class gameManager extends Component {
|
|
}
|
|
}
|
|
tools.loadRemoteImg(data.default_img,(sf)=>{
|
|
tools.loadRemoteImg(data.default_img,(sf)=>{
|
|
sf.addRef();
|
|
sf.addRef();
|
|
- list.push(sf);
|
|
|
|
|
|
+ list.set(data.default_img,sf);
|
|
img_count_font++;
|
|
img_count_font++;
|
|
img_call_back_font();
|
|
img_call_back_font();
|
|
})
|
|
})
|
|
tools.loadRemoteImg(data.find_img,(sf)=>{
|
|
tools.loadRemoteImg(data.find_img,(sf)=>{
|
|
sf.addRef();
|
|
sf.addRef();
|
|
- list.push(sf);
|
|
|
|
|
|
+ list.set(data.find_img,sf);
|
|
img_count_font++;
|
|
img_count_font++;
|
|
img_call_back_font();
|
|
img_call_back_font();
|
|
})
|
|
})
|
|
tools.loadRemoteImg(data.d_img,(sf)=>{
|
|
tools.loadRemoteImg(data.d_img,(sf)=>{
|
|
sf.addRef();
|
|
sf.addRef();
|
|
- list.push(sf);
|
|
|
|
|
|
+ list.set(data.d_img,sf);
|
|
img_count_font++;
|
|
img_count_font++;
|
|
img_call_back_font();
|
|
img_call_back_font();
|
|
})
|
|
})
|
|
@@ -362,7 +375,7 @@ export class gameManager extends Component {
|
|
}
|
|
}
|
|
tools.loadRemoteImg(data.img,(sf)=>{
|
|
tools.loadRemoteImg(data.img,(sf)=>{
|
|
sf.addRef();
|
|
sf.addRef();
|
|
- list.push(sf);
|
|
|
|
|
|
+ list.set(data.img,sf);
|
|
img_count_component++;
|
|
img_count_component++;
|
|
img_call_back_component();
|
|
img_call_back_component();
|
|
})
|
|
})
|
|
@@ -371,7 +384,7 @@ export class gameManager extends Component {
|
|
const element = data.component[index];
|
|
const element = data.component[index];
|
|
tools.loadRemoteImg(element.img,(sf,id)=>{
|
|
tools.loadRemoteImg(element.img,(sf,id)=>{
|
|
sf.addRef();
|
|
sf.addRef();
|
|
- list.push(sf);
|
|
|
|
|
|
+ list.set(element.img,sf);
|
|
img_count_component++;
|
|
img_count_component++;
|
|
img_call_back_component();
|
|
img_call_back_component();
|
|
},element.id);
|
|
},element.id);
|
|
@@ -458,41 +471,70 @@ export class gameManager extends Component {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let paly_item = gameManager.get_play_list_item_by_categoryid(id);
|
|
let paly_item = gameManager.get_play_list_item_by_categoryid(id);
|
|
- assetManager.loadRemote(paly_item.wf_fail_music, (err: any, clip: any)=> {
|
|
|
|
- clip.addRef()
|
|
|
|
|
|
+ if(!gameManager.mp3_cache.get(paly_item.wf_fail_music)){
|
|
|
|
+ assetManager.loadRemote(paly_item.wf_fail_music, (err: any, clip: any)=> {
|
|
|
|
+ clip.addRef()
|
|
|
|
+ gameManager.mp3_cache.set(paly_item.wf_fail_music,clip)
|
|
|
|
+ call()
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
call()
|
|
call()
|
|
- });
|
|
|
|
- assetManager.loadRemote(paly_item.wf_victory_music, (err: any, clip: any)=> {
|
|
|
|
- clip.addRef()
|
|
|
|
|
|
+ }
|
|
|
|
+ if(!gameManager.mp3_cache.get(paly_item.wf_victory_music)){
|
|
|
|
+ assetManager.loadRemote(paly_item.wf_victory_music, (err: any, clip: any)=> {
|
|
|
|
+ clip.addRef()
|
|
|
|
+ call()
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
call()
|
|
call()
|
|
- });
|
|
|
|
- assetManager.loadRemote(paly_item.wf_right_click_music, (err: any, clip: any)=> {
|
|
|
|
- clip.addRef()
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!gameManager.mp3_cache.get(paly_item.wf_right_click_music)){
|
|
|
|
+ assetManager.loadRemote(paly_item.wf_right_click_music, (err: any, clip: any)=> {
|
|
|
|
+ clip.addRef()
|
|
|
|
+ gameManager.mp3_cache.set(paly_item.wf_right_click_music,clip)
|
|
|
|
+ call()
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
call()
|
|
call()
|
|
- });
|
|
|
|
- assetManager.loadRemote(paly_item.wf_wrong_click_music, (err: any, clip: any)=> {
|
|
|
|
- clip.addRef()
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!gameManager.mp3_cache.get(paly_item.wf_wrong_click_music)){
|
|
|
|
+ assetManager.loadRemote(paly_item.wf_wrong_click_music, (err: any, clip: any)=> {
|
|
|
|
+ clip.addRef()
|
|
|
|
+ gameManager.mp3_cache.set(paly_item.wf_wrong_click_music,clip)
|
|
|
|
+ call()
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
call()
|
|
call()
|
|
- });
|
|
|
|
- assetManager.loadRemote(paly_item.wf_piped_music, (err: any, clip: any)=> {
|
|
|
|
- clip.addRef()
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!gameManager.mp3_cache.get(paly_item.wf_piped_music)){
|
|
|
|
+ assetManager.loadRemote(paly_item.wf_piped_music, (err: any, clip: any)=> {
|
|
|
|
+ clip.addRef()
|
|
|
|
+ gameManager.mp3_cache.set(paly_item.wf_piped_music,clip)
|
|
|
|
+ call()
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
call()
|
|
call()
|
|
- });
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
public static decRefSf(categoryid:number){
|
|
public static decRefSf(categoryid:number){
|
|
let levels_item = gameManager.get_cur_level_by_categoryid(categoryid);
|
|
let levels_item = gameManager.get_cur_level_by_categoryid(categoryid);
|
|
gameManager.cache.forEach((v,k)=>{
|
|
gameManager.cache.forEach((v,k)=>{
|
|
- let l = k.split("_");
|
|
|
|
- let level = parseInt(l[0]);
|
|
|
|
- let _categoryid = parseInt(l[1]);
|
|
|
|
- if(_categoryid==categoryid){
|
|
|
|
- if(level<levels_item.level){
|
|
|
|
- for (let index = 0; index < v.length; index++) {
|
|
|
|
- const element = v[index];
|
|
|
|
- element.decRef()
|
|
|
|
|
|
+ if(v!=null){
|
|
|
|
+ let l = k.split("_");
|
|
|
|
+ let level = parseInt(l[0]);
|
|
|
|
+ let _categoryid = parseInt(l[1]);
|
|
|
|
+ if(_categoryid==categoryid){
|
|
|
|
+ if(level<levels_item.level){
|
|
|
|
+ v.forEach((v1,k1)=>{
|
|
|
|
+ v1.decRef()
|
|
|
|
+ })
|
|
|
|
+ gameManager.cache.set(`${level}_${_categoryid}`,null);
|
|
}
|
|
}
|
|
- gameManager.cache.set(`${level}_${_categoryid}`,[]);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|