Explorar el Código

红包界面客户端逻辑

薛鸿潇 hace 5 años
padre
commit
9dc247f227

+ 21 - 1
assets/resources/module/reward/RewardOpen.anim

@@ -3,7 +3,7 @@
   "_name": "RewardOpen",
   "_name": "RewardOpen",
   "_objFlags": 0,
   "_objFlags": 0,
   "_native": "",
   "_native": "",
-  "_duration": 0.3333333333333333,
+  "_duration": 0.5833333333333334,
   "sample": 60,
   "sample": 60,
   "speed": 1,
   "speed": 1,
   "wrapMode": 1,
   "wrapMode": 1,
@@ -35,6 +35,26 @@
           }
           }
         }
         }
       ]
       ]
+    },
+    "paths": {
+      "红包白纸": {
+        "props": {
+          "y": [
+            {
+              "frame": 0.3333333333333333,
+              "value": 200
+            },
+            {
+              "frame": 0.5,
+              "value": 520
+            },
+            {
+              "frame": 0.5833333333333334,
+              "value": 420
+            }
+          ]
+        }
+      }
     }
     }
   },
   },
   "events": []
   "events": []

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 113 - 421
assets/resources/module/reward/reward.prefab


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

@@ -76,5 +76,5 @@ export enum AdFun {
     settlement = 3,     //关卡结算视频
     settlement = 3,     //关卡结算视频
     turntable = 4,      //转盘视频
     turntable = 4,      //转盘视频
     sign = 5,           //签到视频
     sign = 5,           //签到视频
-    bigCash = 6,         //福袋视频
+    bigCash = 6,        //福袋视频
 }
 }

+ 18 - 1
assets/script/game/data/module/RewardData.ts

@@ -5,6 +5,10 @@ import { Data } from "../../../mk/data/Data";
  * @author 邹勇 薛鸿潇
  * @author 邹勇 薛鸿潇
  */
  */
 export class RewardData extends Data {
 export class RewardData extends Data {
+    /** 
+     * 标志位 
+     * - 初始化红包封面样式
+    */
     public init_luck_style: boolean = false;
     public init_luck_style: boolean = false;
 
 
     /** 默认幸运红包 */
     /** 默认幸运红包 */
@@ -19,5 +23,18 @@ export class RewardData extends Data {
     }
     }
 
 
     /** 奖励列表 */
     /** 奖励列表 */
-    data: any;
+    data: Array<DataType> = [];
+    /** 
+     * 标志位 
+     * - 初始化提现样式
+    */
+    public init_cash_style: boolean = true;
+}
+type DataType = {
+    /** 奖励类型 */
+    rewardType: number,
+    /** 奖励数量 */
+    rewardNum: number,
+    /** 玩家剩余数量 */
+    rewardTotal: number
 }
 }

+ 85 - 9
assets/script/game/module/module/reward/Reward.ts

@@ -1,3 +1,4 @@
+import { AdFun } from "../../../data/AdData";
 
 
 const { ccclass, property } = cc._decorator;
 const { ccclass, property } = cc._decorator;
 /**
 /**
@@ -7,14 +8,22 @@ const { ccclass, property } = cc._decorator;
 @ccclass
 @ccclass
 export default class Reward extends cc.Component {
 export default class Reward extends cc.Component {
 
 
-    @property({ displayName: '按钮看视频', type: cc.Button })
-    private btn_watch_video: cc.Button = null;
-
     @property({ displayName: '幸运红包', type: cc.Node })
     @property({ displayName: '幸运红包', type: cc.Node })
     private node_luck: cc.Node = null;
     private node_luck: cc.Node = null;
     @property({ displayName: '通关红包', type: cc.Node })
     @property({ displayName: '通关红包', type: cc.Node })
     private node_mission: cc.Node = null;
     private node_mission: cc.Node = null;
-
+    @property({ displayName: '开红包动画', type: cc.Animation })
+    private anim_open_redbag: cc.Animation = null;
+    @property({ displayName: '按钮看视频', type: cc.Button })
+    private btn_watch_video: cc.Button = null;
+    @property({ displayName: '红包图标', type: cc.Node })
+    private node_redBag: cc.Node = null;
+    @property({ displayName: '金猪图标', type: cc.Node })
+    private node_pig: cc.Node = null;
+    @property({ displayName: '奖励数量', type: cc.Label })
+    private lbl_reward_value: cc.Label = null;
+
+    // 底部提现相关
     @property({ displayName: 'spr提现进度', type: cc.Sprite })
     @property({ displayName: 'spr提现进度', type: cc.Sprite })
     private spr_cash_out: cc.Sprite = null;
     private spr_cash_out: cc.Sprite = null;
     @property({ displayName: 'lbl提现进度', type: cc.Label })
     @property({ displayName: 'lbl提现进度', type: cc.Label })
@@ -23,11 +32,18 @@ export default class Reward extends cc.Component {
     private lbl_cash: cc.Label = null;
     private lbl_cash: cc.Label = null;
 
 
 
 
-    @property({ displayName: '开红包动画', type: cc.Animation })
-    private anim_open_redbag: cc.Animation = null;
 
 
     onLoad() {
     onLoad() {
-
+        this.lbl_reward_value.string = '0';
+        // 测试数据
+        gData.reward.data.push({
+            /** 奖励类型 */
+            rewardType: 1,
+            /** 奖励数量 */
+            rewardNum: 100,
+            /** 玩家剩余数量 */
+            rewardTotal: 0
+        })
     }
     }
 
 
     start() {
     start() {
@@ -37,8 +53,20 @@ export default class Reward extends cc.Component {
 
 
     update(dt) {
     update(dt) {
         if (gData.reward.init_luck_style) {
         if (gData.reward.init_luck_style) {
-            gData.reward.init_luck_style = false;
+            gData.reward.init_luck_style = null;
             this.initLid();
             this.initLid();
+            return;
+        }
+        if (gData.reward.init_cash_style) {
+            gData.reward.init_cash_style = null;
+            this.initCashOutStyle();
+            return;
+        }
+        if (gData.reward.adData) {
+            // 展示奖励
+            this.watchVideoCall();
+            gData.reward.adData = null;
+            return;
         }
         }
     }
     }
 
 
@@ -56,14 +84,62 @@ export default class Reward extends cc.Component {
     }
     }
 
 
     /**
     /**
+     * 底部提现相关样式
+     */
+    private initCashOutStyle() {
+        // 测试数据
+        this.lbl_cash.string = 0.0 + '元';
+        this.lbl_cash_out.string = 0 + '/' + 100;
+        this.spr_cash_out.fillRange = 0.8;
+    }
+
+    /**
      * 看广告
      * 看广告
      */
      */
     private clickWatchVideo() {
     private clickWatchVideo() {
         cc.log('看广告请求');
         cc.log('看广告请求');
+        if (gData.reward.data[0].rewardType === 1) {
+            gData.adData.watchVideo(AdFun.settlement)// 关卡结算视频
+        } else {
+            gData.adData.watchVideo(AdFun.bubble);// 气泡视频
+        }
+        // 测试数据
+        gData.reward.adData = gData.reward.data;
+    }
+
+    /**
+     * 看广告回调:开奖
+     */
+    private watchVideoCall() {
+        gData.reward.data = gData.reward.adData;
+        // 数据排序:多条奖励,只展示红包,把红包放在首位
+        const r_count = gData.reward.adData.length;
+        if (r_count >= 2) {
+            for (let i = 0; i < r_count; i++) {
+                if (gData.reward.adData[i].rewardType === 1) {
+                    let new_data = gData.reward.adData.splice(i, 1);
+                    gData.reward.adData.unshift(new_data);
+                    break;
+                }
+            }
+        }
+
+        // 图标展示
+        if (gData.reward.data[0].rewardType === 1) {
+            this.node_redBag.active = true;
+            this.node_pig.active = false;
+        } else {
+            this.node_redBag.active = false;
+            this.node_pig.active = true;
+        }
+        let rewardNum = gData.reward.data[0].rewardNum || 0;
+        this.lbl_reward_value.string = `${rewardNum}`;
+
+        // 动画
         this.anim_open_redbag.play();
         this.anim_open_redbag.play();
         this.node_luck.active = false;
         this.node_luck.active = false;
         this.node_mission.active = false;
         this.node_mission.active = false;
-        this.btn_watch_video.node.active = false;;
+        this.btn_watch_video.node.active = false;
     }
     }
 
 
     /**
     /**

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio