Przeglądaj źródła

拆分出幸运红包,通关红包

薛鸿潇 5 lat temu
rodzic
commit
bebec8a67c

+ 1 - 1
assets/resources/game/prefab/redbagitem.prefab

@@ -413,7 +413,7 @@
       "__id__": 1
     },
     "_enabled": true,
-    "panel_name": "module/reward/reward",
+    "panel_name": "module/reward/rewardLuck",
     "open_type": 0,
     "transition_type": 0,
     "onComplete": [],

+ 65 - 208
assets/resources/module/reward/reward.prefab

@@ -24,20 +24,20 @@
     "_active": true,
     "_components": [
       {
-        "__id__": 121
+        "__id__": 119
       },
       {
-        "__id__": 122
+        "__id__": 120
       },
       {
-        "__id__": 123
+        "__id__": 121
       },
       {
-        "__id__": 124
+        "__id__": 122
       }
     ],
     "_prefab": {
-      "__id__": 125
+      "__id__": 123
     },
     "_opacity": 255,
     "_color": {
@@ -101,17 +101,17 @@
         "__id__": 35
       },
       {
-        "__id__": 102
+        "__id__": 100
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 119
+        "__id__": 117
       }
     ],
     "_prefab": {
-      "__id__": 120
+      "__id__": 118
     },
     "_opacity": 255,
     "_color": {
@@ -1338,17 +1338,17 @@
         "__id__": 75
       },
       {
-        "__id__": 93
+        "__id__": 91
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 100
+        "__id__": 98
       }
     ],
     "_prefab": {
-      "__id__": 101
+      "__id__": 99
     },
     "_opacity": 255,
     "_color": {
@@ -2644,7 +2644,7 @@
   },
   {
     "__type__": "cc.Node",
-    "_name": "背景",
+    "_name": "幸运盖子",
     "_objFlags": 0,
     "_parent": {
       "__id__": 67
@@ -2722,7 +2722,7 @@
     "_srcBlendFactor": 770,
     "_dstBlendFactor": 771,
     "_spriteFrame": {
-      "__uuid__": "2656930f-e43a-4b90-8851-a2d73f503477"
+      "__uuid__": "565ece1e-8fa1-4afa-a106-8d0309447708"
     },
     "_type": 0,
     "_sizeMode": 1,
@@ -2746,7 +2746,7 @@
     "asset": {
       "__uuid__": "14193c60-068a-42b4-92cf-a6cb623fe40f"
     },
-    "fileId": "41TZ+HoCtPlL/wYBfxmqk2",
+    "fileId": "5etDwhMEtNNJo9GIJqYC4G",
     "sync": false
   },
   {
@@ -2778,13 +2778,13 @@
         "__id__": 82
       },
       {
-        "__id__": 87
+        "__id__": 86
       }
     ],
     "_active": false,
     "_components": [],
     "_prefab": {
-      "__id__": 92
+      "__id__": 90
     },
     "_opacity": 255,
     "_color": {
@@ -2952,7 +2952,7 @@
   },
   {
     "__type__": "cc.Node",
-    "_name": "背景",
+    "_name": "通关盖子",
     "_objFlags": 0,
     "_parent": {
       "__id__": 75
@@ -3030,7 +3030,7 @@
     "_srcBlendFactor": 770,
     "_dstBlendFactor": 771,
     "_spriteFrame": {
-      "__uuid__": "565ece1e-8fa1-4afa-a106-8d0309447708"
+      "__uuid__": "2656930f-e43a-4b90-8851-a2d73f503477"
     },
     "_type": 0,
     "_sizeMode": 1,
@@ -3054,7 +3054,7 @@
     "asset": {
       "__uuid__": "14193c60-068a-42b4-92cf-a6cb623fe40f"
     },
-    "fileId": "4bLhmIh/BCOJaAWq7rQcRt",
+    "fileId": "7fm2Wve9JFH4spJ+FP6dj5",
     "sync": false
   },
   {
@@ -3072,13 +3072,10 @@
       },
       {
         "__id__": 84
-      },
-      {
-        "__id__": 85
       }
     ],
     "_prefab": {
-      "__id__": 86
+      "__id__": 85
     },
     "_opacity": 255,
     "_color": {
@@ -3160,74 +3157,6 @@
     "_id": ""
   },
   {
-    "__type__": "cc.Button",
-    "_name": "",
-    "_objFlags": 0,
-    "node": {
-      "__id__": 82
-    },
-    "_enabled": true,
-    "_normalMaterial": null,
-    "_grayMaterial": null,
-    "duration": 0.1,
-    "zoomScale": 1.2,
-    "clickEvents": [],
-    "_N$interactable": true,
-    "_N$enableAutoGrayEffect": false,
-    "_N$transition": 3,
-    "transition": 3,
-    "_N$normalColor": {
-      "__type__": "cc.Color",
-      "r": 255,
-      "g": 255,
-      "b": 255,
-      "a": 255
-    },
-    "_N$pressedColor": {
-      "__type__": "cc.Color",
-      "r": 211,
-      "g": 211,
-      "b": 211,
-      "a": 255
-    },
-    "pressedColor": {
-      "__type__": "cc.Color",
-      "r": 211,
-      "g": 211,
-      "b": 211,
-      "a": 255
-    },
-    "_N$hoverColor": {
-      "__type__": "cc.Color",
-      "r": 255,
-      "g": 255,
-      "b": 255,
-      "a": 255
-    },
-    "hoverColor": {
-      "__type__": "cc.Color",
-      "r": 255,
-      "g": 255,
-      "b": 255,
-      "a": 255
-    },
-    "_N$disabledColor": {
-      "__type__": "cc.Color",
-      "r": 124,
-      "g": 124,
-      "b": 124,
-      "a": 255
-    },
-    "_N$normalSprite": null,
-    "_N$pressedSprite": null,
-    "pressedSprite": null,
-    "_N$hoverSprite": null,
-    "hoverSprite": null,
-    "_N$disabledSprite": null,
-    "_N$target": null,
-    "_id": ""
-  },
-  {
     "__type__": "cdc50kCRVVBa5gcp4XXxVO+",
     "_name": "",
     "_objFlags": 0,
@@ -3238,7 +3167,7 @@
     "node_panel": {
       "__id__": 1
     },
-    "transition_type": 0,
+    "transition_type": 3,
     "onComplete": [],
     "_id": ""
   },
@@ -3264,17 +3193,14 @@
     "_active": true,
     "_components": [
       {
-        "__id__": 88
-      },
-      {
-        "__id__": 89
+        "__id__": 87
       },
       {
-        "__id__": 90
+        "__id__": 88
       }
     ],
     "_prefab": {
-      "__id__": 91
+      "__id__": 89
     },
     "_opacity": 255,
     "_color": {
@@ -3328,7 +3254,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 87
+      "__id__": 86
     },
     "_enabled": true,
     "_materials": [
@@ -3356,87 +3282,17 @@
     "_id": ""
   },
   {
-    "__type__": "cc.Button",
-    "_name": "",
-    "_objFlags": 0,
-    "node": {
-      "__id__": 87
-    },
-    "_enabled": true,
-    "_normalMaterial": null,
-    "_grayMaterial": null,
-    "duration": 0.1,
-    "zoomScale": 1.2,
-    "clickEvents": [],
-    "_N$interactable": true,
-    "_N$enableAutoGrayEffect": false,
-    "_N$transition": 3,
-    "transition": 3,
-    "_N$normalColor": {
-      "__type__": "cc.Color",
-      "r": 255,
-      "g": 255,
-      "b": 255,
-      "a": 255
-    },
-    "_N$pressedColor": {
-      "__type__": "cc.Color",
-      "r": 211,
-      "g": 211,
-      "b": 211,
-      "a": 255
-    },
-    "pressedColor": {
-      "__type__": "cc.Color",
-      "r": 211,
-      "g": 211,
-      "b": 211,
-      "a": 255
-    },
-    "_N$hoverColor": {
-      "__type__": "cc.Color",
-      "r": 255,
-      "g": 255,
-      "b": 255,
-      "a": 255
-    },
-    "hoverColor": {
-      "__type__": "cc.Color",
-      "r": 255,
-      "g": 255,
-      "b": 255,
-      "a": 255
-    },
-    "_N$disabledColor": {
-      "__type__": "cc.Color",
-      "r": 124,
-      "g": 124,
-      "b": 124,
-      "a": 255
-    },
-    "_N$normalSprite": null,
-    "_N$pressedSprite": null,
-    "pressedSprite": null,
-    "_N$hoverSprite": null,
-    "hoverSprite": null,
-    "_N$disabledSprite": null,
-    "_N$target": {
-      "__id__": 1
-    },
-    "_id": ""
-  },
-  {
     "__type__": "cdc50kCRVVBa5gcp4XXxVO+",
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 87
+      "__id__": 86
     },
     "_enabled": true,
     "node_panel": {
       "__id__": 1
     },
-    "transition_type": 0,
+    "transition_type": 3,
     "onComplete": [],
     "_id": ""
   },
@@ -3471,17 +3327,17 @@
     },
     "_children": [
       {
-        "__id__": 94
+        "__id__": 92
       }
     ],
     "_active": false,
     "_components": [
       {
-        "__id__": 97
+        "__id__": 95
       }
     ],
     "_prefab": {
-      "__id__": 99
+      "__id__": 97
     },
     "_opacity": 255,
     "_color": {
@@ -3535,17 +3391,17 @@
     "_name": "动画",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 93
+      "__id__": 91
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 95
+        "__id__": 93
       }
     ],
     "_prefab": {
-      "__id__": 96
+      "__id__": 94
     },
     "_opacity": 255,
     "_color": {
@@ -3599,7 +3455,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 94
+      "__id__": 92
     },
     "_enabled": true,
     "_materials": [
@@ -3652,7 +3508,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 93
+      "__id__": 91
     },
     "_enabled": true,
     "_normalMaterial": null,
@@ -3661,7 +3517,7 @@
     "zoomScale": 1.2,
     "clickEvents": [
       {
-        "__id__": 98
+        "__id__": 96
       }
     ],
     "_N$interactable": true,
@@ -3779,25 +3635,25 @@
     },
     "_children": [
       {
-        "__id__": 103
+        "__id__": 101
       },
       {
-        "__id__": 106
+        "__id__": 104
       },
       {
-        "__id__": 109
+        "__id__": 107
       },
       {
-        "__id__": 112
+        "__id__": 110
       },
       {
-        "__id__": 115
+        "__id__": 113
       }
     ],
     "_active": true,
     "_components": [],
     "_prefab": {
-      "__id__": 118
+      "__id__": 116
     },
     "_opacity": 255,
     "_color": {
@@ -3851,17 +3707,17 @@
     "_name": "星星",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 102
+      "__id__": 100
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 104
+        "__id__": 102
       }
     ],
     "_prefab": {
-      "__id__": 105
+      "__id__": 103
     },
     "_opacity": 255,
     "_color": {
@@ -3915,7 +3771,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 103
+      "__id__": 101
     },
     "_enabled": true,
     "_materials": [
@@ -3958,17 +3814,17 @@
     "_name": "星星",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 102
+      "__id__": 100
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 107
+        "__id__": 105
       }
     ],
     "_prefab": {
-      "__id__": 108
+      "__id__": 106
     },
     "_opacity": 255,
     "_color": {
@@ -4022,7 +3878,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 106
+      "__id__": 104
     },
     "_enabled": true,
     "_materials": [
@@ -4065,17 +3921,17 @@
     "_name": "星星",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 102
+      "__id__": 100
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 110
+        "__id__": 108
       }
     ],
     "_prefab": {
-      "__id__": 111
+      "__id__": 109
     },
     "_opacity": 255,
     "_color": {
@@ -4129,7 +3985,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 109
+      "__id__": 107
     },
     "_enabled": true,
     "_materials": [
@@ -4172,17 +4028,17 @@
     "_name": "星星",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 102
+      "__id__": 100
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 113
+        "__id__": 111
       }
     ],
     "_prefab": {
-      "__id__": 114
+      "__id__": 112
     },
     "_opacity": 255,
     "_color": {
@@ -4236,7 +4092,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 112
+      "__id__": 110
     },
     "_enabled": true,
     "_materials": [
@@ -4279,17 +4135,17 @@
     "_name": "星星",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 102
+      "__id__": 100
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 116
+        "__id__": 114
       }
     ],
     "_prefab": {
-      "__id__": 117
+      "__id__": 115
     },
     "_opacity": 255,
     "_color": {
@@ -4343,7 +4199,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 115
+      "__id__": 113
     },
     "_enabled": true,
     "_materials": [
@@ -4465,6 +4321,7 @@
       "__id__": 1
     },
     "_enabled": true,
+    "lid_type": 0,
     "node_luck": {
       "__id__": 67
     },
@@ -4472,10 +4329,10 @@
       "__id__": 75
     },
     "anim_open_redbag": {
-      "__id__": 100
+      "__id__": 98
     },
     "btn_watch_video": {
-      "__id__": 97
+      "__id__": 95
     },
     "node_redBag": {
       "__id__": 43

+ 9 - 35
assets/script/game/data/module/RewardData.ts

@@ -7,43 +7,17 @@ import { Data } from "../../../mk/data/Data";
 export class RewardData extends Data {
     /** 
      * 标志位 
-     * - 初始化红包封面样式
-    */
-    public init_luck_style: boolean = false;
-
-    /** 默认幸运红包 */
-    private _lid_type: LidType = LidType.none;
-    /** 是幸运红包 不是通关红包 */
-    set lid_type(value: LidType) {
-        this._lid_type = value;
-        this.init_luck_style = true;
-    }
-    get lid_type(): LidType {
-        return this._lid_type;
-    }
-
-    /** 奖励列表 */
-    data: Array<any> = [];
-    /** 
-     * 标志位 
      * - 初始化提现样式
     */
     public init_cash_style: boolean = true;
 
-    /** 
-     * 盖子类型
-     * - 外部赋值 lid_type 时,使用此变量赋值
-     */
-    public type_lid: typeof LidType = LidType
-}
-/**
- * 盖子类型
- */
-enum LidType {
-    /** 无盖子 */
-    none = 0,
-    /** 幸运红包盖子 */
-    luck = 1,
-    /** 通关红包盖子 */
-    mission = 2
+    private _data: Array<any> = [];
+    /** 奖励列表 */
+    set data(value: Array<any>) {
+        this._data = value;
+        this.init_cash_style = true;
+    }
+    get data(): Array<any> {
+        return this._data;
+    }
 }

+ 1 - 1
assets/script/game/game/Game.ts

@@ -56,7 +56,7 @@ export default class Game extends cc.Component {
         cc.tween(this.btn_getRed3).delay(0.6).to(2, { y: -50 }).to(2, { y: -150 }).union().repeatForever().start();
     }
 
-    private initInfo(){
+    private initInfo() {
         this.lbl_redMoney.string = gData.gameData.gameData.redMoney + "";
         this.lbl_rmb.string = gData.gameData.gameData.piggyBank + "";
     }

+ 1 - 1
assets/script/game/module/redBagCash/RedBagCash.ts

@@ -17,7 +17,7 @@ export default class RedBagCash extends cc.Component {
 
     private tableview: TableView = null;
     onLoad() {
-        gData.gameData.gameData.redMoney = 10200;// 测试数据,数据正确后请删除
+        // gData.gameData.gameData.redMoney = 10200;// 测试数据,数据正确后请删除
         this.tableview = this.sroll_view.getComponent('TableView');
     }
 

+ 28 - 15
assets/script/game/module/reward/Reward.ts

@@ -3,12 +3,26 @@ import { RewardType } from "../../data/GameData";
 
 const { ccclass, property } = cc._decorator;
 /**
+ * 盖子类型
+ */
+enum LidType {
+    /** 无盖子 */
+    none = 0,
+    /** 幸运红包盖子 */
+    luck = 1,
+    /** 通关红包盖子 */
+    mission = 2
+}
+/**
  * 获取奖励界面-红包
  * @author 薛鸿潇
  */
 @ccclass
 export default class Reward extends cc.Component {
 
+
+    @property({ displayName: '红包类型', type: cc.Enum(LidType), tooltip: 'none无类型,luck幸运红包,mission通关红包' })
+    private lid_type: LidType = LidType.none;
     @property({ displayName: '幸运红包', type: cc.Node })
     private node_luck: cc.Node = null;
     @property({ displayName: '通关红包', type: cc.Node })
@@ -44,11 +58,6 @@ export default class Reward extends cc.Component {
     }
 
     update(dt) {
-        if (gData.reward.init_luck_style) {
-            gData.reward.init_luck_style = null;
-            this.initLid();
-            return;
-        }
         if (gData.reward.init_cash_style) {
             gData.reward.init_cash_style = null;
             this.initCashOutStyle();
@@ -66,18 +75,21 @@ export default class Reward extends cc.Component {
      * 初始化封面样式
      */
     private initLid() {
-        if (gData.reward.lid_type === gData.reward.type_lid.none) {// 无盖子样式
+        if (this.lid_type === LidType.none) {// 无盖子样式
             this.node_luck.active = false;
             this.node_mission.active = false;
+            this.btn_watch_video.node.active = false;
             this.watchVideoCall();
             mk.audio.playEffect("rewardOpen");
-        } else if (gData.reward.lid_type === gData.reward.type_lid.luck) {
-            this.node_luck.active = false;
-            this.node_mission.active = true;
+        } else if (this.lid_type === LidType.luck) {
+            this.node_luck.active = true;
+            this.node_mission.active = false;
+            this.btn_watch_video.node.active = true;
             mk.audio.playEffect("reward");
-        } else if (gData.reward.lid_type === gData.reward.type_lid.mission) {
+        } else if (this.lid_type === LidType.mission) {
             this.node_luck.active = false;
             this.node_mission.active = true;
+            this.btn_watch_video.node.active = true;
             mk.audio.playEffect("reward");
         }
     }
@@ -86,9 +98,10 @@ export default class Reward extends cc.Component {
      * 底部提现相关样式
      */
     private initCashOutStyle() {
-        const cash_bar = gData.redBagCash.cash_bar
-        let cash_data = gData.redBagCash.getItemDataByIndex(cash_bar)
-        
+        const cash_bar = gData.redBagCash.cash_bar;
+        let cash_data = gData.redBagCash.getItemDataByIndex(cash_bar);
+        if (!cash_data) return;
+
         this.lbl_cash.string = cash_data.money + '元';
         this.lbl_cash_out.string = gData.gameData.gameData.redMoney + '/' + cash_data.type_value;
         this.spr_cash_out.fillRange = gData.gameData.gameData.redMoney / cash_data.type_value;
@@ -99,7 +112,7 @@ export default class Reward extends cc.Component {
      */
     private clickWatchVideo() {
         cc.log('看广告请求');
-        if (gData.reward.data[0].rewardType === 1) {
+        if (gData.reward.data[0] && gData.reward.data[0].rewardType === 1) {
             gData.adData.watchVideo(AdFun.settlement)// 关卡结算视频
         } else {
             gData.adData.watchVideo(AdFun.bubble);// 气泡视频
@@ -165,7 +178,7 @@ export default class Reward extends cc.Component {
 
     }
 
-    onDestroy(){
+    onDestroy() {
         mk.audio.playEffect("rewardClose");
     }