xx 1 год назад
Родитель
Сommit
ee3d40f5b6

+ 219 - 15
assets/resources/prefabs/dialog.prefab

@@ -28,17 +28,17 @@
     "_active": true,
     "_components": [
       {
-        "__id__": 44
+        "__id__": 52
       },
       {
-        "__id__": 46
+        "__id__": 54
       },
       {
-        "__id__": 48
+        "__id__": 56
       }
     ],
     "_prefab": {
-      "__id__": 50
+      "__id__": 58
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -284,14 +284,14 @@
     "_active": true,
     "_components": [
       {
-        "__id__": 39
+        "__id__": 47
       },
       {
-        "__id__": 41
+        "__id__": 49
       }
     ],
     "_prefab": {
-      "__id__": 43
+      "__id__": 51
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -472,16 +472,19 @@
       },
       {
         "__id__": 28
+      },
+      {
+        "__id__": 36
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 36
+        "__id__": 44
       }
     ],
     "_prefab": {
-      "__id__": 38
+      "__id__": 46
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -908,6 +911,204 @@
     "targetOverrides": null,
     "nestedPrefabInstanceRoots": null
   },
+  {
+    "__type__": "cc.Node",
+    "_name": "btn_yes-001",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 19
+    },
+    "_children": [],
+    "_active": false,
+    "_components": [
+      {
+        "__id__": 37
+      },
+      {
+        "__id__": 39
+      },
+      {
+        "__id__": 41
+      }
+    ],
+    "_prefab": {
+      "__id__": 43
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 5.001,
+      "y": 0,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 0.3,
+      "y": 0.3,
+      "z": 1
+    },
+    "_mobility": 0,
+    "_layer": 33554432,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 36
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 38
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 258,
+      "height": 102
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "f4NynA+VlBzK5LYTTfc8L1"
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 36
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 40
+    },
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_spriteFrame": {
+      "__uuid__": "3da0abaf-e986-4046-8f63-94e3cf361c3b@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_type": 0,
+    "_fillType": 0,
+    "_sizeMode": 2,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
+    },
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_useGrayscale": false,
+    "_atlas": null,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "1eBTFCHHFB9ZkinbMpv50F"
+  },
+  {
+    "__type__": "cc.Button",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 36
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 42
+    },
+    "clickEvents": [],
+    "_interactable": true,
+    "_transition": 3,
+    "_normalColor": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_hoverColor": {
+      "__type__": "cc.Color",
+      "r": 211,
+      "g": 211,
+      "b": 211,
+      "a": 255
+    },
+    "_pressedColor": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_disabledColor": {
+      "__type__": "cc.Color",
+      "r": 124,
+      "g": 124,
+      "b": 124,
+      "a": 255
+    },
+    "_normalSprite": {
+      "__uuid__": "3da0abaf-e986-4046-8f63-94e3cf361c3b@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_hoverSprite": null,
+    "_pressedSprite": null,
+    "_disabledSprite": null,
+    "_duration": 0.1,
+    "_zoomScale": 1.1,
+    "_target": null,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "31kUVcFj5Fl4EgoQM+mM94"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "1bS9mRzUxAgKnkqnQ1Bdus",
+    "instance": null,
+    "targetOverrides": null,
+    "nestedPrefabInstanceRoots": null
+  },
   {
     "__type__": "cc.UITransform",
     "_name": "",
@@ -918,7 +1119,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 37
+      "__id__": 45
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -959,7 +1160,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 40
+      "__id__": 48
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -987,7 +1188,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 42
+      "__id__": 50
     },
     "_customMaterial": null,
     "_srcBlendFactor": 2,
@@ -1045,7 +1246,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 45
+      "__id__": 53
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -1073,7 +1274,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 47
+      "__id__": 55
     },
     "_alignFlags": 45,
     "_target": null,
@@ -1109,7 +1310,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 49
+      "__id__": 57
     },
     "lab_name": {
       "__id__": 13
@@ -1117,6 +1318,9 @@
     "btn_yes": {
       "__id__": 20
     },
+    "btn_one_yes": {
+      "__id__": 36
+    },
     "btn_not": {
       "__id__": 28
     },

+ 19 - 0
assets/script/dialog/dialog.ts

@@ -1,10 +1,12 @@
 import { _decorator, Component, Label, Node } from 'cc';
+import { gameManager } from '../gameManager';
 const { ccclass, property } = _decorator;
 
 @ccclass('dialog')
 export class dialog extends Component {
     @property(Node) lab_name;
     @property(Node) btn_yes;
+    @property(Node) btn_one_yes;
     @property(Node) btn_not;
     private m_call_yes = null;
     private m_call_not = null;
@@ -12,12 +14,14 @@ export class dialog extends Component {
         this.m_call_yes = call_yes;
         this.m_call_not = call_not;
         this.btn_yes.on(Node.EventType.TOUCH_START,()=>{
+            gameManager.playBtnSound()
             if(this.m_call_yes!=null){
                 this.m_call_yes()
             }
             this.close()
         },this);
         this.btn_not.on(Node.EventType.TOUCH_START,()=>{
+            gameManager.playBtnSound()
             if(this.m_call_not!=null){
                 this.m_call_not()
             }
@@ -26,6 +30,21 @@ export class dialog extends Component {
         this.lab_name.getComponent(Label).string = text;
     }
 
+    public showOne(text:string,call_yes){
+        this.m_call_yes = call_yes;
+        this.btn_not.active = false;
+        this.btn_yes.active = false;
+        this.btn_one_yes.active = true;
+        this.btn_one_yes.on(Node.EventType.TOUCH_START,()=>{
+            gameManager.playBtnSound()
+            if(this.m_call_yes!=null){
+                this.m_call_yes()
+            }
+            this.close()
+        },this);
+        this.lab_name.getComponent(Label).string = text;
+    }
+
     close(){
         this.node.removeFromParent()
     }

+ 3 - 18
assets/script/dialog/win.ts

@@ -35,36 +35,21 @@ export class win extends Component {
     }
 
     //双图找不同
-    public showZhaoBuTongView(data:server_shuang_tu_zhao_bu_tong_data_item,ordinary_call,double_call){
+    public showZhaoBuTongView(reward:number,data:server_shuang_tu_zhao_bu_tong_data_item,ordinary_call,double_call){
         this.m_double_call = double_call;
         this.m_ordinary_call = ordinary_call;
-        let list = data.reward.split(",");
-        let start = parseInt(list[0]);
-        let end = parseInt(list[1]);
-        let reward =  Util.getRandomInt(start,end);
-        gameManager.add_coin(reward);
         this.lab_reward_number.getComponent(Label).string = "+ " +reward+"";
     }
     //汉字找不同
-    public showHanZiView(data:server_han_zi_zhao_bu_tong_data_item,ordinary_call,double_call){
+    public showHanZiView(reward:number,data:server_han_zi_zhao_bu_tong_data_item,ordinary_call,double_call){
         this.m_double_call = double_call;
         this.m_ordinary_call = ordinary_call;
-        let list = data.reward.split(",");
-        let start = parseInt(list[0]);
-        let end = parseInt(list[1]);
-        let reward =  Util.getRandomInt(start,end);
-        gameManager.add_coin(reward);
         this.lab_reward_number.getComponent(Label).string = "+ " +reward+"";
     }
     //美女找不同
-    public showMeiNvView(data:server_mei_nv_zhao_xi_jie_data_item,ordinary_call,double_call){
+    public showMeiNvView(reward:number,data:server_mei_nv_zhao_xi_jie_data_item,ordinary_call,double_call){
         this.m_double_call = double_call;
         this.m_ordinary_call = ordinary_call;
-        let list = data.reward.split(",");
-        let start = parseInt(list[0]);
-        let end = parseInt(list[1]);
-        let reward =  Util.getRandomInt(start,end);
-        gameManager.add_coin(reward);
         this.lab_reward_number.getComponent(Label).string = "+ " +reward+"";
     }
 }

+ 19 - 7
assets/script/framework/audioManager.ts

@@ -2,6 +2,7 @@ import { Lodash } from './lodash';
 import { _decorator, assetManager, AudioClip } from "cc";
 import { StorageManager } from "./storageManager";
 import { ResourceUtil } from "./resourceUtil";
+import { gameManager } from '../gameManager';
 const { ccclass, property } = _decorator;
 @ccclass("AudioManager")
 export class AudioManager  {
@@ -73,16 +74,21 @@ export class AudioManager  {
         //     this.playClip(name, true); 
         // });     
 
-
-
-        assetManager.loadRemote(name,  (err: any, clip: AudioClip)=> {
+         let call_back = (err: any, clip: AudioClip)=> {
             let tmp = {} as any;
             tmp.clip = clip;
             tmp.loop = loop;
             tmp.isMusic = true;
             this.audios[name] = tmp;
             this.playClip(name, true); 
-        });
+        }
+        if(gameManager.mp3_cache.get(path)){
+            let clip = gameManager.mp3_cache.get(path);
+            call_back(null,clip)
+        }else{
+            assetManager.loadRemote(name, call_back );
+        }
+        
     }
 
     /**
@@ -124,8 +130,7 @@ export class AudioManager  {
         //         });
         //     })
         // });
-
-        assetManager.loadRemote(name,(err: any, clip: any)=> {
+        let call_back = (err: any, clip: any)=> {
             let tmp = {} as any;
             tmp.clip = clip;
             tmp.loop = loop;
@@ -146,7 +151,14 @@ export class AudioManager  {
                     return obj.clip === tmp.clip;
                 });
             })
-        });
+        }
+
+        if(gameManager.mp3_cache.get(path)){
+            let clip = gameManager.mp3_cache.get(path);
+            call_back(null,clip)
+        }else{
+            assetManager.loadRemote(name, call_back );
+        }
     }
 
     public playClip (name: string, isMusic?: boolean) {

+ 80 - 38
assets/script/gameManager.ts

@@ -23,7 +23,8 @@ export class gameManager extends Component {
     public static topViewList:Map<string,Node> = new Map();
     public static user_level_data:unlock_levels = new unlock_levels();
     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[] = [];
     start() {
 
@@ -98,7 +99,7 @@ export class gameManager extends Component {
         gameManager.waitLayer = node;
     }
 
-    public static sync_data(){
+    public static sync_data(call_back){
         let form_Data = null;
         if(sys.platform==sys.Platform.BYTEDANCE_MINI_GAME){
             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)
                 if(c__data.code==config.MSG_CODE.SUCCESS){
                     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(){
+        gameManager.hideLoading();
         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 play_item = gameManager.get_play_list_item_by_categoryid(categoryid);
         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 false;
@@ -290,7 +303,7 @@ export class gameManager extends Component {
 
     public static loadLevelImg(category_id,level,call_back){
         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)=>{
             if(!err){
                 let _data = JSON.parse(data)
@@ -310,13 +323,13 @@ export class gameManager extends Component {
                            }
                             tools.loadRemoteImg(data.img1,(sf:SpriteFrame)=>{
                                 sf.addRef();
-                                list.push(sf);
+                                list.set(data.img1,sf);
                                 img_count++;
                                 img_call_back();
                             })
                             tools.loadRemoteImg(data.img2,(sf)=>{
                                 sf.addRef();
-                                list.push(sf);
+                                list.set(data.img2,sf);
                                 img_count++;
                                 img_call_back();
                             })
@@ -333,19 +346,19 @@ export class gameManager extends Component {
                             }
                             tools.loadRemoteImg(data.default_img,(sf)=>{
                                 sf.addRef();
-                                list.push(sf);
+                                list.set(data.default_img,sf);
                                 img_count_font++;
                                 img_call_back_font();
                             })
                             tools.loadRemoteImg(data.find_img,(sf)=>{
                                 sf.addRef();
-                                list.push(sf);
+                                list.set(data.find_img,sf);
                                 img_count_font++;
                                 img_call_back_font();
                             })
                             tools.loadRemoteImg(data.d_img,(sf)=>{
                                 sf.addRef();
-                                list.push(sf);
+                                list.set(data.d_img,sf);
                                 img_count_font++;
                                 img_call_back_font();
                             })
@@ -362,7 +375,7 @@ export class gameManager extends Component {
                             }
                             tools.loadRemoteImg(data.img,(sf)=>{
                                 sf.addRef();
-                                list.push(sf);
+                                list.set(data.img,sf);
                                 img_count_component++;
                                 img_call_back_component();
                             })
@@ -371,7 +384,7 @@ export class gameManager extends Component {
                                 const element = data.component[index];
                                 tools.loadRemoteImg(element.img,(sf,id)=>{
                                     sf.addRef();
-                                    list.push(sf);
+                                    list.set(element.img,sf);
                                     img_count_component++;
                                     img_call_back_component();
                                 },element.id);
@@ -458,41 +471,70 @@ export class gameManager extends Component {
             }
         }
         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()
-        });
-        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()
-        });
-        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()
-        });
-        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()
-        });
-        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()
-        });
+        }
+   
     }
 
     public static decRefSf(categoryid:number){
         let levels_item = gameManager.get_cur_level_by_categoryid(categoryid);
         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}`,[]);
                 }
             }
         })

+ 1 - 1
assets/script/homepage/play_list_item.ts

@@ -26,7 +26,7 @@ export class play_list_item extends Component {
         },this);
 
         this.btn_lock_coin.on(Node.EventType.TOUCH_START,()=>{
-
+            gameManager.playBtnSound()
             if(gameManager.get_user_coin()>=this.m_data.coin_number){
                 tools.showDialog(`使用${this.m_data.coin_number}金币解锁${this.m_data.name}`,()=>{
                     gameManager.sub_coin(this.m_data.coin_number);

+ 69 - 41
assets/script/http/http.ts

@@ -5,45 +5,73 @@ const { ccclass, property } = _decorator;
 @ccclass('http')
 export class http extends Component {
     static get(url,call_back){
-        var xml =  new XMLHttpRequest()
-        xml.open('GET',config.domain+url)
-        xml.setRequestHeader('Content-Type','text/plain');
-        xml.send();
-   
-    //    var array:String[] = ['loadstart','abort', 'error', 'load', 'loadend', 'timeout'];
-    //    array.forEach(function (eventName) {
-    //        xml[('on' + eventName) as 'onloadstart' | 'onabort' | 'onerror' | 'onload' | 'onloadend' | 'ontimeout'] = function () {
-    //            var str =  '\nEvent : ' + eventName;
-    //            var lstr = ""
-    //            if (eventName === 'timeout') {
-    //                lstr += '(timeout)';
-    //            }
-    //            else if (eventName === 'loadend') {
-    //                lstr += '...loadend!';
-         
-    //            }else if (eventName === 'onerror') {
-   
-    //            }
-    //        };
-    //    });
+        try{
+            if(sys.platform==sys.Platform.BYTEDANCE_MINI_GAME){
+                // let new_data = {}
+                // _data.forEach((value: FormDataEntryValue, key: string, parent: FormData)=>{
+                //     new_data[key] = value;
+                // })
+                // console.log("传送的参数",_data)
+                const options = {
+                    url: config.domain+url, //请求地址
+                    method:  "GET",    //指定对应的网络请求方法,详见文档中method枚举值
+                    // dataType:  "json", // 指定返回数据的类型为 json。不填默认为json
+                    enableCache: false, //是否开启 cache ,不填默认为false
+                    // responseType:  "text", //期望响应的数据类型
+                    timeout:  60000, //超时时间,单位为毫秒(最大值 60000ms)
+                  }
+    
+                  let task = tt.request({ 
+                    ...options,
+                    success(res) { //请求成功回调
+                    //   console.log("请求成功", res.data);
+                        call_back(null,JSON.stringify(res.data));
+                    },
+                    fail(res) {//请求失败回调
+                        call_back( -1,null);
+                        console.log("请求失败", res.errMsg);
+                    },
+                    complete(res){ //请求结束回调
+                      console.log("调用接口结束",res.data)
+                    }
+                  });
+    
+            }else{
+                var xml =  new XMLHttpRequest()
+                xml.open('GET',config.domain+url)
+                xml.setRequestHeader('Content-Type','text/plain');
+                xml.send();
+                // Special event
+                xml.onreadystatechange = function () {
+    
+                    console.log("e === ",xml)
+                    if (xml.readyState === 4 && xml.status >= 200) {
+                        //label.string = handler(xml.responseText);
+                        call_back(null,xml.responseText);
+                    } else if (xml.status === 404) {
+                        call_back('404 page not found!',null);
+                    } 
+                    else if (xml.readyState === 3) {
+                        call_back('Request dealing!',null);
+                    } else if (xml.readyState === 2) {
+                        call_back('Request received!',null);
+                    } else if (xml.readyState === 1) {
+                        call_back('Server connection established! Request hasn\'t been received',null);
+                    } else if (xml.readyState === 0) {
+                        call_back( 'Request hasn\'t been initiated!',null);
+                    }else if (xml.readyState === 4 &&xml.status === 0) {
+                        call_back( -1,null);
+                    }
+            }
+           
+            };
+        }catch(e){
+            console.log("e === ",e)
+            call_back(-1,null)
+        }
+        
+
 
-       // Special event
-       xml.onreadystatechange = function () {
-           if (xml.readyState === 4 && xml.status >= 200) {
-               //label.string = handler(xml.responseText);
-               call_back(null,xml.responseText);
-           } else if (xml.status === 404) {
-               call_back('404 page not found!',null);
-           } else if (xml.readyState === 3) {
-               call_back('Request dealing!',null);
-           } else if (xml.readyState === 2) {
-               call_back('Request received!',null);
-           } else if (xml.readyState === 1) {
-               call_back('Server connection established! Request hasn\'t been received',null);
-           } else if (xml.readyState === 0) {
-               call_back( 'Request hasn\'t been initiated!',null);
-           }
-       };
    }
 
    static post(url,_data:any,call_back){
@@ -75,7 +103,7 @@ export class http extends Component {
                   call_back(null,JSON.stringify(res.data));
                 },
                 fail(res) {//请求失败回调
-                    call_back(res.errMsg,null);
+                    call_back( -1,null);
                     console.log("请求失败", res.errMsg);
        
                 },
@@ -89,10 +117,8 @@ export class http extends Component {
             xml.open('POST',config.domain+url)
             // xml.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
             xml.setRequestHeader('token',gameManager.userInfo.token);
-    
             xml.send(_data);
     
-    
             // Special event
             xml.onreadystatechange = function () {
                 if (xml.readyState === 4 && xml.status >= 200) {
@@ -112,6 +138,8 @@ export class http extends Component {
          
                 } else if (xml.readyState === 0) {
                     call_back( 'Request hasn\'t been initiated!',null);
+                }else if (xml.readyState === 4 &&xml.status === 0) {
+                    call_back( -1,null);
                 }
             };
         }

+ 11 - 3
assets/script/launch/view_launch.ts

@@ -182,9 +182,17 @@ export class launch_view extends Component {
 
         if(progress_number==70){
             this.isStop = true;
-            gameManager.loadSysMusic(()=>{
-                this.isStop = false;
-            })
+            let temp_count = 0;
+            let call = ()=>{
+                temp_count++;
+                if(temp_count>=4){
+                    this.isStop = false;
+                }   
+            }
+            gameManager.loadSysMusic(call);
+            gameManager.loadPlayMusicByCategoryId(config.PLAY_TYPE.MEI_NV_ZHAO_XI_JIE,call);
+            gameManager.loadPlayMusicByCategoryId(config.PLAY_TYPE.YI_QI_ZHAO_CHA,call);
+            gameManager.loadPlayMusicByCategoryId(config.PLAY_TYPE.HAN_ZI_ZHAO_BU_TONG,call);
         }
 
         if(progress_number==80){

+ 37 - 17
assets/script/play_list/zhaocha_component/view_game_play_mei_nv_zhao_xi_jie.ts

@@ -11,6 +11,7 @@ import { http } from '../../http/http';
 import { ClientEvent } from '../../framework/clientEvent';
 import { AudioManager } from '../../framework/audioManager';
 import { pause } from '../../dialog/pause';
+import { Util } from '../../framework/util';
 const { ccclass, property } = _decorator;
 
 @ccclass('view_game_play_mei_nv_zhao_xi_jie')
@@ -38,6 +39,8 @@ export class view_game_play_mei_nv_zhao_xi_jie extends Component {
     private time_all_count:number = 0;
     private err_node_1:Node = null;
     private isPause:boolean = false;
+    private reward:number = 0;
+    private isShowWin:boolean = false;
     start() {
         let self = this;
         this.btn_back.on(Node.EventType.TOUCH_START,()=>{
@@ -106,6 +109,7 @@ export class view_game_play_mei_nv_zhao_xi_jie extends Component {
             this.node.active = false;
         }
         let self = this;
+        self.isShowWin = false;
         gameManager.decRefSf(this.categoryid);
         self.sfList.clear()
         let call_back = ()=>{
@@ -119,7 +123,8 @@ export class view_game_play_mei_nv_zhao_xi_jie extends Component {
                 })
             }
         }
-        tools.loadRemoteImg(this.m_data.img,(sf)=>{
+        let levels_item = gameManager.get_cur_level_by_categoryid(this.categoryid);
+        tools.loadRemoteImgByCategoryid(this.categoryid,levels_item.level,this.m_data.img,(sf)=>{
             count++;
             self.img_sf= sf;
             call_back();
@@ -127,7 +132,7 @@ export class view_game_play_mei_nv_zhao_xi_jie extends Component {
 
         for (let index = 0; index < this.m_data.component.length; index++) {
             const element = this.m_data.component[index];
-            tools.loadRemoteImg(element.img,(sf,id)=>{
+            tools.loadRemoteImgByCategoryid(this.categoryid,levels_item.level,element.img,(sf,id)=>{
                 count++;
                 self.sfList.set(id ,sf);
                 call_back();
@@ -175,6 +180,12 @@ export class view_game_play_mei_nv_zhao_xi_jie extends Component {
         self.lab_coin.getComponent(Label).string = gameManager.get_user_coin()+"";
         self.lab_title.getComponent(Label).string = this.m_data.name;
         self.img.removeAllChildren();
+
+        let list = this.m_data.reward.split(",");
+        let start = parseInt(list[0]);
+        let end = parseInt(list[1]);
+        this.reward =  Util.getRandomInt(start,end);
+
         resources.load(config.PREFAB_PATH.circle, Prefab, (err, prefab) => {
             if(err){
                 return;
@@ -240,14 +251,15 @@ export class view_game_play_mei_nv_zhao_xi_jie extends Component {
             }
         }
 
-        if(this.checkAllAnswerFinish()){
+        if(this.checkAllAnswerFinish()&&!this.isShowWin){
             this.stop_time_count()
             if(gameManager.isFinishAllLevel(this.categoryid)){
                 tools.showToast("当前已是最后一关,敬请期待最新版本");
             }else{
                 gameManager.addTopView(config.PREFAB_PATH.win,(node:Node)=>{
+                    this.isShowWin = true;
                     gameManager.playWinSoundByCategoryId(this.categoryid)
-                    node.getComponent(win).showMeiNvView(this.m_data,this.onWinOrdinaryClick.bind(this),this.onWinDoubleClick.bind(this));
+                    node.getComponent(win).showMeiNvView(this.reward,this.m_data,this.onWinOrdinaryClick.bind(this),this.onWinDoubleClick.bind(this));
                 });
             }
 
@@ -270,20 +282,28 @@ export class view_game_play_mei_nv_zhao_xi_jie extends Component {
     }
 
     nextLevel(){
-        if(gameManager.next_level(this.categoryid)){
-            let levels_item = gameManager.get_cur_level_by_categoryid(this.categoryid);
-            gameManager.showLoading();
-            http.get(config.static_url.levels_info(this.categoryid,levels_item.level),(err,data)=>{
-
-                if(!err){
-                    let _data = JSON.parse(data)
-                    if(_data.code===config.MSG_CODE.SUCCESS){
-                        this.initView(_data.content,true);
+        let is_have_next = gameManager.next_level(this.categoryid,(is_sync:boolean)=>{
+            if(is_sync){
+                let levels_item = gameManager.get_cur_level_by_categoryid(this.categoryid);
+                gameManager.showLoading();
+                gameManager.add_coin(this.reward);
+                http.get(config.static_url.levels_info(this.categoryid,levels_item.level),(err,data)=>{
+                    if(!err){
+                        let _data = JSON.parse(data)
+                        if(_data.code===config.MSG_CODE.SUCCESS){
+                            this.initView(_data.content,true);
+                        }
                     }
-                }
-    
-            })
-        }else{  
+                })
+            }else{
+                gameManager.hideLoading()
+                tools.showDialogOne("请检查您的网络状态,重新连接",()=>{
+                    this.nextLevel()
+                })
+            }
+        })
+
+        if(!is_have_next){
             tools.showToast("当前已是最后一关,敬请期待最新版本");
         }
     }

+ 38 - 18
assets/script/play_list/zhaocha_font/view_game_play_han_zi_zhao_bu_tong.ts

@@ -10,6 +10,7 @@ import { win } from '../../dialog/win';
 import { ClientEvent } from '../../framework/clientEvent';
 import { AudioManager } from '../../framework/audioManager';
 import { pause } from '../../dialog/pause';
+import { Util } from '../../framework/util';
 const { ccclass, property } = _decorator;
 
 @ccclass('view_game_play_han_zi_zhao_bu_tong')
@@ -37,6 +38,8 @@ export class view_game_play_han_zi_zhao_bu_tong extends Component {
     private time_count:number = 0;
     private time_all_count:number = 0;
     private isPause:boolean = false;
+    private reward:number = 0;
+    private isShowWin:boolean = false;
     start() {
         let self = this;
         this.btn_back.on(Node.EventType.TOUCH_START,()=>{
@@ -77,7 +80,9 @@ export class view_game_play_han_zi_zhao_bu_tong extends Component {
             this.node.active = false;
         }
         let self = this;
+        self.isShowWin = false;
         gameManager.decRefSf(this.categoryid);
+        let levels_item = gameManager.get_cur_level_by_categoryid(this.categoryid);
         let call_back = ()=>{
             if(count>=3){
                 gameManager.loadPlayMusicByCategoryId(this.categoryid,()=>{
@@ -88,17 +93,17 @@ export class view_game_play_han_zi_zhao_bu_tong extends Component {
                 })
             }
         }
-        tools.loadRemoteImg(this.m_data.default_img,(sf)=>{
+        tools.loadRemoteImgByCategoryid(this.categoryid,levels_item.level,this.m_data.default_img,(sf)=>{
             count++;
             self.default_img= sf;
             call_back();
         })
-        tools.loadRemoteImg(this.m_data.find_img,(sf)=>{
+        tools.loadRemoteImgByCategoryid(this.categoryid,levels_item.level,this.m_data.find_img,(sf)=>{
             count++;
             self.find_img = sf;
             call_back();
         })
-        tools.loadRemoteImg(this.m_data.d_img,(sf)=>{
+        tools.loadRemoteImgByCategoryid(this.categoryid,levels_item.level,this.m_data.d_img,(sf)=>{
             count++;
             self.d_img = sf;
             call_back();
@@ -125,15 +130,17 @@ export class view_game_play_han_zi_zhao_bu_tong extends Component {
             this.error_sub_time()
             item.showErrStatus()
        }
-       if(this.checkAllAnswerFinish()){
+       if(this.checkAllAnswerFinish()&&!this.isShowWin){
             this.stop_time_count()
             if(gameManager.isFinishAllLevel(this.categoryid)){
                 tools.showToast("当前已是最后一关,敬请期待最新版本");
             }else{
                 gameManager.addTopView(config.PREFAB_PATH.win,(node:Node)=>{
+                    this.isShowWin = true;
                     gameManager.playWinSoundByCategoryId(this.categoryid);
-                    node.getComponent(win).showHanZiView(this.m_data,this.onWinOrdinaryClick.bind(this),this.onWinDoubleClick.bind(this));
+                    node.getComponent(win).showHanZiView(this.reward,this.m_data,this.onWinOrdinaryClick.bind(this),this.onWinDoubleClick.bind(this));
                 });
+             
             }
            
        }
@@ -186,6 +193,10 @@ export class view_game_play_han_zi_zhao_bu_tong extends Component {
         this.bottom_pos.removeAllChildren()
         this.left_pos.removeAllChildren()
         this.lab_title.getComponent(Label).string = this.m_data.name;
+        let list = this.m_data.reward.split(",");
+        let start = parseInt(list[0]);
+        let end = parseInt(list[1]);
+        this.reward =  Util.getRandomInt(start,end);
         if(this.m_data.content.length<=0){
             tools.showToast("关卡未配置数据!")
             return
@@ -247,20 +258,29 @@ export class view_game_play_han_zi_zhao_bu_tong extends Component {
         this.unscheduleAllCallbacks()
     }
     nextLevel(){
-        if(gameManager.next_level(this.categoryid)){
-            let levels_item = gameManager.get_cur_level_by_categoryid(this.categoryid);
-            gameManager.showLoading();
-            http.get(config.static_url.levels_info(this.categoryid,levels_item.level),(err,data)=>{
-
-                if(!err){
-                    let _data = JSON.parse(data)
-                    if(_data.code===config.MSG_CODE.SUCCESS){
-                        this.initView(_data.content,true);
-                    }
-                }
+        let is_have_next = gameManager.next_level(this.categoryid,(is_sync:boolean)=>{
+            if(is_sync){
+                let levels_item = gameManager.get_cur_level_by_categoryid(this.categoryid);
+                gameManager.showLoading();
+                gameManager.add_coin(this.reward);
+                http.get(config.static_url.levels_info(this.categoryid,levels_item.level),(err,data)=>{
     
-            })
-        }else{  
+                    if(!err){
+                        let _data = JSON.parse(data)
+                        if(_data.code===config.MSG_CODE.SUCCESS){
+                            this.initView(_data.content,true);
+                        }
+                    }
+                })
+            }else{
+                gameManager.hideLoading()
+                tools.showDialogOne("请检查您的网络状态,重新连接",()=>{
+                    this.nextLevel()
+                })
+            }
+        })
+
+        if(!is_have_next){
             tools.showToast("当前已是最后一关,敬请期待最新版本");
         }
     }

+ 36 - 17
assets/script/play_list/zhaocha_up_down/view_game_play_shuang_tu_zhao_bu_tong.ts

@@ -11,6 +11,7 @@ import { fail } from '../../dialog/fail';
 import { ClientEvent } from '../../framework/clientEvent';
 import { AudioManager } from '../../framework/audioManager';
 import { pause } from '../../dialog/pause';
+import { Util } from '../../framework/util';
 const { ccclass, property } = _decorator;
 
 @ccclass('view_game_play_shuang_tu_zhao_bu_tong')
@@ -42,6 +43,8 @@ export class view_game_play_shuang_tu_zhao_bu_tong extends Component {
     private err_node_2:Node = null;
     private isPause:boolean = false;
     private scale_multiple:number = 2;
+    private reward:number = 0;
+    private isShowWin:boolean = false;
     start() {
         let self = this;
         this.btn_back.on(Node.EventType.TOUCH_START,()=>{
@@ -172,6 +175,10 @@ export class view_game_play_shuang_tu_zhao_bu_tong extends Component {
         this.err_node_2  = null;
         this.cur_amplify_status = 0;
         this.updateAmplifyStatus()
+        let __list = this.m_data.reward.split(",");
+        let start = parseInt(__list[0]);
+        let end = parseInt(__list[1]);
+        this.reward =  Util.getRandomInt(start,end);
         if(this.m_data.content.length<=0){
             tools.showToast("关卡未配置数据!")
             return
@@ -236,14 +243,15 @@ export class view_game_play_shuang_tu_zhao_bu_tong extends Component {
             this.star_list.getComponent(star_list).showStartByNumber(count);
         }
 
-        if(this.checkAllAnswerFinish()){
+        if(this.checkAllAnswerFinish()&&!this.isShowWin){
             this.stop_time_count();
             if(gameManager.isFinishAllLevel(this.categoryid)){
                 tools.showToast("当前已是最后一关,敬请期待最新版本");
             }else{
                 gameManager.addTopView(config.PREFAB_PATH.win,(node:Node)=>{
                     gameManager.playWinSoundByCategoryId(this.categoryid);
-                    node.getComponent(win).showZhaoBuTongView(this.m_data,this.onWinOrdinaryClick.bind(this),this.onWinDoubleClick.bind(this));
+                    this.isShowWin = true;
+                    node.getComponent(win).showZhaoBuTongView(this.reward,this.m_data,this.onWinOrdinaryClick.bind(this),this.onWinDoubleClick.bind(this));
                 });
             }
 
@@ -280,20 +288,29 @@ export class view_game_play_shuang_tu_zhao_bu_tong extends Component {
     }
 
     nextLevel(){
-        if(gameManager.next_level(this.categoryid)){
-            let levels_item = gameManager.get_cur_level_by_categoryid(this.categoryid);
-            gameManager.showLoading();
-            http.get(config.static_url.levels_info(this.categoryid,levels_item.level),(err,data)=>{
-
-                if(!err){
-                    let _data = JSON.parse(data)
-                    if(_data.code===config.MSG_CODE.SUCCESS){
-                        this.initView(_data.content,true);
-                    }
-                }
+        let is_have_next = gameManager.next_level(this.categoryid,(is_sync:boolean)=>{
+            if(is_sync){
+                let levels_item = gameManager.get_cur_level_by_categoryid(this.categoryid);
+                gameManager.showLoading();
+                gameManager.add_coin(this.reward);
+                http.get(config.static_url.levels_info(this.categoryid,levels_item.level),(err,data)=>{
     
-            })
-        }else{  
+                    if(!err){
+                        let _data = JSON.parse(data)
+                        if(_data.code===config.MSG_CODE.SUCCESS){
+                            this.initView(_data.content,true);
+                        }
+                    }
+                })
+            }else{
+                gameManager.hideLoading()
+                tools.showDialogOne("请检查您的网络状态,重新连接",()=>{
+                    this.nextLevel()
+                })
+            }
+        })
+
+        if(!is_have_next){
             tools.showToast("当前已是最后一关,敬请期待最新版本");
         }
     }
@@ -336,6 +353,7 @@ export class view_game_play_shuang_tu_zhao_bu_tong extends Component {
             this.node.active = false;
         }
         let self = this;
+        self.isShowWin = false;
         gameManager.decRefSf(this.categoryid);
         let call_back = ()=>{
             if(count>=2){
@@ -351,12 +369,13 @@ export class view_game_play_shuang_tu_zhao_bu_tong extends Component {
                 })
             }
         }
-        tools.loadRemoteImg(this.m_data.img1,(sf)=>{
+        let levels_item = gameManager.get_cur_level_by_categoryid(this.categoryid);
+        tools.loadRemoteImgByCategoryid(this.categoryid,levels_item.level,this.m_data.img1,(sf)=>{
             count++;
             self.img_1_sf = sf;
             call_back();
         })
-        tools.loadRemoteImg(this.m_data.img2,(sf)=>{
+        tools.loadRemoteImgByCategoryid(this.categoryid,levels_item.level,this.m_data.img2,(sf)=>{
             count++;
             self.img_2_sf = sf;
             call_back();

+ 51 - 0
assets/script/tools.ts

@@ -40,6 +40,24 @@ export class tools  {
         });
     }
 
+
+    public static showDialogOne(text:string,call_yes=null){
+        if(gameManager.getTopLayer()==null){
+            console.log("gameManager.topLayer -- null!");
+            return;
+        }
+        resources.load(config.PREFAB_PATH.dialog, Prefab, (err, prefab) => {
+            if(err){
+                console.log("addTopView -- err::",err);
+                return;
+            }
+
+            let newNode:Node = instantiate(prefab);
+            newNode.parent = gameManager.getTopLayer();
+            newNode.getComponent(dialog).showOne(text,call_yes);
+        });
+    }
+
     public static loadRemoteImg(url,call_back,id=null){
         assetManager.loadRemote<ImageAsset>(url, (err, imageAsset2)=>{
             if (!err && imageAsset2) {        
@@ -57,6 +75,39 @@ export class tools  {
         
         });
     }
+    public static loadRemoteImgByCategoryid(categoryid:number,level:number,url,call_back,id=null){
+        let map = gameManager.cache.get(`${level}_${categoryid}`)
+        let isCache = false;
+        if(map!=null&&map.size>0){
+            if(map.get(url)){
+                isCache =true;
+                if(id!=null){
+                    call_back(map.get(url),id);
+                }else{
+                    call_back(map.get(url));
+                }
+            }
+        }
+
+        if(!isCache){
+            assetManager.loadRemote<ImageAsset>(url, (err, imageAsset2)=>{
+                if (!err && imageAsset2) {        
+                    const texture = new Texture2D();
+                    texture.image = imageAsset2;
+                    let spFrame2 = new SpriteFrame();     
+                    spFrame2.texture = texture;
+                    if(id!=null){
+                        call_back(spFrame2,id);
+                    }else{
+                        call_back(spFrame2);
+                    }
+                    
+                }
+            
+            });
+        }
+ 
+    }
 }