Browse Source

新手引导穿透问题

zouyong 5 years ago
parent
commit
d70ac754af

+ 127 - 114
assets/resources/module/guide/guide.prefab

@@ -24,23 +24,26 @@
         "__id__": 9
       },
       {
-        "__id__": 14
+        "__id__": 11
+      },
+      {
+        "__id__": 16
       },
       {
-        "__id__": 17
+        "__id__": 18
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 35
+        "__id__": 36
       },
       {
-        "__id__": 36
+        "__id__": 37
       }
     ],
     "_prefab": {
-      "__id__": 37
+      "__id__": 38
     },
     "_opacity": 255,
     "_color": {
@@ -329,6 +332,77 @@
   },
   {
     "__type__": "cc.Node",
+    "_name": "block",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [],
+    "_prefab": {
+      "__id__": 10
+    },
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 0,
+      "height": 0
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_trs": {
+      "__type__": "TypedArray",
+      "ctor": "Float64Array",
+      "array": [
+        0,
+        0,
+        0,
+        0,
+        0,
+        0,
+        1,
+        1,
+        1,
+        1
+      ]
+    },
+    "_eulerAngles": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_skewX": 0,
+    "_skewY": 0,
+    "_is3DNode": false,
+    "_groupIndex": 0,
+    "groupIndex": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__uuid__": "5f53c125-7a14-4ca0-986a-0e0d2d665268"
+    },
+    "fileId": "d1tHk7Gm9LbbyyLPLu75Vs",
+    "sync": false
+  },
+  {
+    "__type__": "cc.Node",
     "_name": "点击区域",
     "_objFlags": 0,
     "_parent": {
@@ -338,14 +412,14 @@
     "_active": true,
     "_components": [
       {
-        "__id__": 10
+        "__id__": 12
       },
       {
-        "__id__": 11
+        "__id__": 13
       }
     ],
     "_prefab": {
-      "__id__": 13
+      "__id__": 15
     },
     "_opacity": 0,
     "_color": {
@@ -399,7 +473,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 9
+      "__id__": 11
     },
     "_enabled": true,
     "_materials": [
@@ -431,7 +505,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 9
+      "__id__": 11
     },
     "_enabled": true,
     "_normalMaterial": null,
@@ -440,7 +514,7 @@
     "zoomScale": 1.2,
     "clickEvents": [
       {
-        "__id__": 12
+        "__id__": 14
       }
     ],
     "_N$interactable": true,
@@ -523,39 +597,15 @@
   },
   {
     "__type__": "cc.Node",
-    "_name": "hand",
     "_objFlags": 0,
     "_parent": {
       "__id__": 1
     },
-    "_children": [],
-    "_active": true,
-    "_components": [
-      {
-        "__id__": 15
-      }
-    ],
     "_prefab": {
-      "__id__": 16
-    },
-    "_opacity": 255,
-    "_color": {
-      "__type__": "cc.Color",
-      "r": 255,
-      "g": 255,
-      "b": 255,
-      "a": 255
-    },
-    "_contentSize": {
-      "__type__": "cc.Size",
-      "width": 94,
-      "height": 100
-    },
-    "_anchorPoint": {
-      "__type__": "cc.Vec2",
-      "x": 0.5,
-      "y": 0.5
+      "__id__": 17
     },
+    "_name": "hand",
+    "_active": true,
     "_trs": {
       "__type__": "TypedArray",
       "ctor": "Float64Array",
@@ -578,55 +628,18 @@
       "y": 0,
       "z": 0
     },
-    "_skewX": 0,
-    "_skewY": 0,
-    "_is3DNode": false,
-    "_groupIndex": 0,
-    "groupIndex": 0,
-    "_id": ""
-  },
-  {
-    "__type__": "cc.Sprite",
-    "_name": "",
-    "_objFlags": 0,
-    "node": {
-      "__id__": 14
-    },
-    "_enabled": true,
-    "_materials": [
-      {
-        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
-      }
-    ],
-    "_srcBlendFactor": 770,
-    "_dstBlendFactor": 771,
-    "_spriteFrame": {
-      "__uuid__": "e374d43a-3f16-493f-a5c9-af57ec3d09cb"
-    },
-    "_type": 0,
-    "_sizeMode": 1,
-    "_fillType": 0,
-    "_fillCenter": {
-      "__type__": "cc.Vec2",
-      "x": 0,
-      "y": 0
-    },
-    "_fillStart": 0,
-    "_fillRange": 0,
-    "_isTrimmedMode": true,
-    "_atlas": null,
     "_id": ""
   },
   {
     "__type__": "cc.PrefabInfo",
     "root": {
-      "__id__": 1
+      "__id__": 16
     },
     "asset": {
-      "__uuid__": "5f53c125-7a14-4ca0-986a-0e0d2d665268"
+      "__uuid__": "73bde1e5-ca53-420e-9f68-ca130e46fc49"
     },
-    "fileId": "14BeehV6RGZ63hNNH505Ak",
-    "sync": false
+    "fileId": "28CtR1YfRNpaH7R5QaADW9",
+    "sync": true
   },
   {
     "__type__": "cc.Node",
@@ -637,26 +650,26 @@
     },
     "_children": [
       {
-        "__id__": 18
+        "__id__": 19
       },
       {
-        "__id__": 21
+        "__id__": 22
       },
       {
-        "__id__": 24
+        "__id__": 25
       },
       {
-        "__id__": 27
+        "__id__": 28
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 33
+        "__id__": 34
       }
     ],
     "_prefab": {
-      "__id__": 34
+      "__id__": 35
     },
     "_opacity": 255,
     "_color": {
@@ -710,17 +723,17 @@
     "_name": "bg",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 17
+      "__id__": 18
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 19
+        "__id__": 20
       }
     ],
     "_prefab": {
-      "__id__": 20
+      "__id__": 21
     },
     "_opacity": 255,
     "_color": {
@@ -774,7 +787,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 18
+      "__id__": 19
     },
     "_enabled": true,
     "_materials": [
@@ -817,17 +830,17 @@
     "_name": "panda",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 17
+      "__id__": 18
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 22
+        "__id__": 23
       }
     ],
     "_prefab": {
-      "__id__": 23
+      "__id__": 24
     },
     "_opacity": 255,
     "_color": {
@@ -881,7 +894,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 21
+      "__id__": 22
     },
     "_enabled": true,
     "_materials": [
@@ -924,17 +937,17 @@
     "_name": "head",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 17
+      "__id__": 18
     },
     "_children": [],
     "_active": false,
     "_components": [
       {
-        "__id__": 25
+        "__id__": 26
       }
     ],
     "_prefab": {
-      "__id__": 26
+      "__id__": 27
     },
     "_opacity": 255,
     "_color": {
@@ -988,7 +1001,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 24
+      "__id__": 25
     },
     "_enabled": true,
     "_materials": [
@@ -1031,21 +1044,21 @@
     "_name": "文本",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 17
+      "__id__": 18
     },
     "_children": [
       {
-        "__id__": 28
+        "__id__": 29
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 31
+        "__id__": 32
       }
     ],
     "_prefab": {
-      "__id__": 32
+      "__id__": 33
     },
     "_opacity": 255,
     "_color": {
@@ -1099,17 +1112,17 @@
     "_name": "RICHTEXT_CHILD",
     "_objFlags": 1024,
     "_parent": {
-      "__id__": 27
+      "__id__": 28
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 29
+        "__id__": 30
       }
     ],
     "_prefab": {
-      "__id__": 30
+      "__id__": 31
     },
     "_opacity": 255,
     "_color": {
@@ -1164,7 +1177,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 28
+      "__id__": 29
     },
     "_enabled": true,
     "_materials": [
@@ -1202,7 +1215,7 @@
     "asset": {
       "__uuid__": "5f53c125-7a14-4ca0-986a-0e0d2d665268"
     },
-    "fileId": "a2HoJek5BHspfqhuFy74/k",
+    "fileId": "d5G49QSiVBX6Z1eyDm+K5J",
     "sync": false
   },
   {
@@ -1210,7 +1223,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 27
+      "__id__": 28
     },
     "_enabled": true,
     "_fontFamily": "Arial",
@@ -1244,7 +1257,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 17
+      "__id__": 18
     },
     "_enabled": true,
     "alignMode": 1,
@@ -1291,25 +1304,25 @@
       "__id__": 2
     },
     "node_click": {
-      "__id__": 9
+      "__id__": 11
     },
     "node_bg": {
       "__id__": 3
     },
     "node_dialog": {
-      "__id__": 17
+      "__id__": 18
     },
     "node_finger": {
-      "__id__": 15
+      "__id__": 16
     },
     "node_head": {
-      "__id__": 25
+      "__id__": 26
     },
     "node_person": {
-      "__id__": 22
+      "__id__": 23
     },
     "rich_dialog": {
-      "__id__": 31
+      "__id__": 32
     },
     "_id": ""
   },

+ 1 - 1
assets/script/game/data/AppData.ts

@@ -31,7 +31,7 @@ export class AppData {
     /** 安卓版本号 */
     public androidVersion: string = '';
 
-    public mac: string = '5e:32:e2:12:b3:23,f6:60:e4:1a:b7:27';
+    public mac: string = '5e:35:e1:12:b3:23,f6:60:e4:1a:b7:27';
 
     /** 设备信息 */
     public machineInfo = {

+ 9 - 9
assets/script/game/data/module/GuideData.ts

@@ -32,16 +32,16 @@ export class GuideData {
             guide.id = parseInt(a[0]);
             guide.step = parseInt(a[1]);
             guide.trigger = o.trigger;
-            guide.tr_num = o.tr_num || o.trNum;
-            guide.tr_form = o.tr_form || o.trForm;
+            guide.tr_num = o.trNum;
+            guide.tr_form = o.trForm;
             guide.dialog = o.dialog;
-            guide.dialog_pos = o.dialog_pos;
-            guide.dialog_pos1 = o.dialog_pos1;
-            guide.dialog_alignment = o.dialog_alignment;
-            guide.display_rect = o.display_rect || o.displayRect;
-            guide.click_rect = o.click_rect || o.clickRect;
-            guide.finger = o.finger || '';
-            guide.lag_next = o.lag_next || o.lagNext;
+            guide.dialog_pos = o.dialogPos;
+            guide.dialog_pos1 = o.dialogPos1;
+            guide.dialog_alignment = o.dialogAlignment;
+            guide.display_rect = o.displayRect;
+            guide.click_rect = o.clickRect;
+            guide.finger = o.finger;
+            guide.lag_next = parseInt(o.lagNext);
             if (id != guide.id) {
                 this.data.set(id, arr);
                 arr = [];

+ 3 - 8
assets/script/game/game/Game.ts

@@ -53,16 +53,11 @@ export default class Game extends cc.Component {
         this.autoOpenPanel();
         this.runGuideWeak();
 
-        if (gData.gameData.isNewPlayer()) {
-            this.initGuide();
-            gData.gameData.setProp(GameProp.newPlayer, 1);
+        if (gData.gameData.getProp(GameProp.guideID) < 11111111) {
+            mk.guide.open(1);
         }
     }
 
-    private initGuide() {
-        mk.guide.open(1);
-    }
-
     update() {
         if (gData.gameData.init_coin) {
             this.changeInfo();
@@ -147,7 +142,7 @@ export default class Game extends cc.Component {
     }
 
     /** */
-    public onClickStart() {
+    public onClickStart(a,b) {
         this.node_gameplay.active = true;
     }
 

+ 27 - 11
assets/script/game/module/guide/Guide.ts

@@ -17,8 +17,8 @@ export default class Guide extends cc.Component {
     node_bg: cc.Node = null;
     @property({ type: cc.Node, displayName: "对话框" })
     node_dialog: cc.Node = null;
-    @property({ type: cc.Sprite, displayName: "手指" })
-    node_finger: cc.Sprite = null;
+    @property({ type: cc.Node, displayName: "手指" })
+    node_finger: cc.Node = null;
     @property({ type: cc.Sprite, displayName: "头像" })
     node_head: cc.Sprite = null;
     @property({ type: cc.Sprite, displayName: "形象" })
@@ -87,6 +87,14 @@ export default class Guide extends cc.Component {
                 this.node_display.height = this.targetNode.height;
                 let pos = mk.game.getWorldPos(this.targetNode);
                 this.node_display.setPosition(pos);
+
+                //穿透点击目标节点时增加一个事件触发下一步,触发后移除
+                this.node_click.width = this.node_click.height = 0;
+                let eventHandler = new cc.Component.EventHandler();
+                eventHandler.target = this.node;
+                eventHandler.component = "Guide";
+                eventHandler.handler = "clickNodeClick";
+                this.targetNode.getComponent(cc.Button).clickEvents.push(eventHandler);
             }
 
             //对话框位置
@@ -95,7 +103,7 @@ export default class Guide extends cc.Component {
                 let arr = this.crtGuide.dialog_pos.split(":");
                 let wedgit = this.node_dialog.getComponent(cc.Widget);
                 for (let i = 0; i < this.widgets.length; i++) {
-                    wedgit[this.widgets[i]] = arr[i] == "" ? null : arr[i];
+                    wedgit[this.widgets[i]] = arr[i] == "" ? null : parseInt(arr[i]);
                 }
             }
             else {//显示区域偏移
@@ -109,13 +117,13 @@ export default class Guide extends cc.Component {
             this.rich_dialog.horizontalAlign = a == '0' ? cc.macro.TextAlignment.LEFT : (a == '1' ? cc.macro.TextAlignment.CENTER : cc.macro.TextAlignment.RIGHT);
 
             if (this.crtGuide.finger == "") {
-                this.node_finger.node.active = false;
+                this.node_finger.active = false;
             }
             else {
-                this.node_finger.node.active = true;
+                this.node_finger.active = true;
                 let arr = this.crtGuide.finger.split(":");
-                this.node_finger.node.x = this.node_display.x + parseInt(arr[0]);
-                this.node_finger.node.y = this.node_display.y + parseInt(arr[1]);
+                this.node_finger.x = this.node_display.x + parseInt(arr[0]);
+                this.node_finger.y = this.node_display.y + parseInt(arr[1]);
             }
 
             if (this.crtGuide.tr_form == 1) {
@@ -130,29 +138,37 @@ export default class Guide extends cc.Component {
             this.node_bg.x = -this.node_display.x;
             this.node_bg.y = -this.node_display.y;
 
-            this.rich_dialog.string = `<color=#000000>${this.crtGuide.dialog}</color>`;
+            this.rich_dialog.string = this.crtGuide.dialog;
         }
     }
 
     async clickNodeClick() {
         console.log("clickNodeClick");
-        if (this.targetNode) {
-            this.targetNode.getComponent(cc.Button).clickEvents[0].emit([]);
+        if(this.targetNode){
+            this.targetNode.getComponent(cc.Button).clickEvents.pop();
         }
         if (this.event_name) {
             //event_guide_1_2 (1_2为新手引导的id)
             mk.event.emit(this.event_name);
         }
         if (this.crtGuide.lag_next > 0) {
+            this.wait();
             await mk.time.WaitForSeconds(this.crtGuide.lag_next);
         }
         this.nextStep();
     }
 
+    /** 等待状态 透明不可点击 */
+    private wait() {
+        this.node_display.width = this.node.width;
+        this.node_display.height = this.node.height;
+        this.node_click.width = 0
+        this.node_click.height = 0;
+    }
+
 
     private close() {
         mk.guide.close();
         this.node.destroy();
     }
-
 }

+ 1 - 1
assets/script/game/module/guide/GuideVO.ts

@@ -24,5 +24,5 @@ export default class GuideVO {
     /** 手指位置 */
     finger: string;
     /** 下个时间 */
-    lag_next: 0;
+    lag_next: number;
 }

+ 10 - 5
assets/script/mk/system/GuideSystem.ts

@@ -10,6 +10,7 @@ export default class GuideSystem {
 
     public open(id) {
         this.crtGuideID = gData.gameData.getProp(GameProp.guideID);
+        this.setGuideID(this.crtGuideID++);
         if (id == 9999) {
             mk.console.log("新手引导已做完");
             return;
@@ -23,13 +24,17 @@ export default class GuideSystem {
         mk.ui.openPanel("module/guide/guide");
     }
 
-    public close() {
-        this.crtGuideID++;
-        let guide = gData.guideData.getGuidesByID(this.crtGuideID);
+    /** 开启一个引导后直接默认已完成 */
+    private setGuideID(id: number) {
+        let guide = gData.guideData.getGuidesByID(id);
         if (guide == null) {
-            this.crtGuideID = 9999;
+            id = 9999;
         }
-        gData.gameData.setProp(GameProp.guideID, this.crtGuideID);
+        gData.gameData.setProp(GameProp.guideID, id);
+    }
+
+    public close() {
+        this.crtGuideID++;
     }
 
     /**