Kaynağa Gözat

领取通关红包添加开红包动画。

薛鸿潇 5 yıl önce
ebeveyn
işleme
cfa8961cef

+ 129 - 3
tower_sanguo/assets/resources/module/checkpointRedBag/btn_chPo_RedBag.prefab

@@ -19,19 +19,22 @@
     "_children": [
       {
         "__id__": 2
+      },
+      {
+        "__id__": 5
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 5
+        "__id__": 8
       },
       {
-        "__id__": 6
+        "__id__": 9
       }
     ],
     "_prefab": {
-      "__id__": 7
+      "__id__": 10
     },
     "_opacity": 255,
     "_color": {
@@ -188,6 +191,123 @@
     "sync": false
   },
   {
+    "__type__": "cc.Node",
+    "_name": "node_icon",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": false,
+    "_components": [
+      {
+        "__id__": 6
+      }
+    ],
+    "_prefab": {
+      "__id__": 7
+    },
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 149,
+      "height": 163
+    },
+    "_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__": "sp.Skeleton",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 5
+    },
+    "_enabled": true,
+    "_materials": [
+      {
+        "__uuid__": "7afd064b-113f-480e-b793-8817d19f63c3"
+      }
+    ],
+    "paused": false,
+    "defaultSkin": "default",
+    "defaultAnimation": "animation2",
+    "_preCacheMode": 0,
+    "_cacheMode": 0,
+    "loop": true,
+    "premultipliedAlpha": true,
+    "timeScale": 1,
+    "_accTime": 0,
+    "_playCount": 0,
+    "_frameCache": null,
+    "_curFrame": null,
+    "_skeletonCache": null,
+    "_animationName": "animation2",
+    "_animationQueue": [],
+    "_headAniInfo": null,
+    "_playTimes": 0,
+    "_isAniComplete": true,
+    "_N$skeletonData": {
+      "__uuid__": "2ffff260-0fab-4a51-b498-6a721c853e12"
+    },
+    "_N$_defaultCacheMode": 0,
+    "_N$debugSlots": false,
+    "_N$debugBones": false,
+    "_N$debugMesh": false,
+    "_N$useTint": false,
+    "_N$enableBatch": false,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__uuid__": "ef403a09-ba55-46d1-8932-8b2dbb804639"
+    },
+    "fileId": "79gMNcFQNOsZKIPOc78LVn",
+    "sync": false
+  },
+  {
     "__type__": "cc.Button",
     "_name": "",
     "_objFlags": 0,
@@ -265,6 +385,12 @@
       "__id__": 1
     },
     "_enabled": true,
+    "node_icon": {
+      "__id__": 5
+    },
+    "hb520": {
+      "__id__": 2
+    },
     "_id": ""
   },
   {

+ 3 - 1
tower_sanguo/assets/scripts/module/checkpointRedBag/CheckpointRedBagBtn.ts

@@ -50,6 +50,8 @@ export default class CheckpointRedBagBtn extends cc.Component {
         GameController.audioM.playEffect(AUDIO_TYPE.button);
         if (CheckpointRedBagModle.redbag_data.cur_count > 0) {
             GameController.http.getStageReward();
+        } else {
+            GameController.uiM.showToast('挂机可以获得红包')
         }
     }
     /** 看视频领取通关红包回调 */
@@ -118,7 +120,7 @@ export default class CheckpointRedBagBtn extends cc.Component {
             if (this.curValue == this.targetProgress) {
                 this.lbl_chPo_count.string = `${this.targetProgress}`;
             } else {
-                this.lbl_chPo_count.string = `${this.curValue.toFixed(2)}`;
+                this.lbl_chPo_count.string = `${this.curValue.toFixed(0)}`;
             }
         }
     }

+ 14 - 4
tower_sanguo/assets/scripts/module/checkpointRedBag/CheckpointRedBagItem.ts

@@ -6,6 +6,10 @@ const { ccclass, property } = cc._decorator;
 
 @ccclass
 export default class CheckpointRedBagItem extends cc.Component {
+    @property(cc.Node)
+    private node_icon: cc.Node = null!;
+    @property(cc.Node)
+    private hb520: cc.Node = null!;
     /** 按钮组件 */
     private comp_btn: cc.Button = null!;
     /** 定时的生命 
@@ -24,7 +28,8 @@ export default class CheckpointRedBagItem extends cc.Component {
     }
 
     start() {
-
+        this.node_icon.active = false;
+        this.hb520.active = true;
     }
     private flyNode() {
         if (this.anim_playing) return;
@@ -35,13 +40,18 @@ export default class CheckpointRedBagItem extends cc.Component {
         let end_node_pos = this.comp_main.node.convertToNodeSpaceAR(end_world_pos);
 
         let start_pos = cc.tween().to(0.5, { position: end_node_pos }, { easing: 'sineOut' });
-        let dt1 = cc.tween().delay(0.1);
-        let scale1 = cc.tween().to(0.1, { scale: 0 });
+        let call0 = cc.tween().call(() => {
+            // 展示树立红包的样式
+            this.node_icon.active = true;
+            this.hb520.active = false;
+        });
+        let dt1 = cc.tween().delay(0.5);
+        let scale1 = cc.tween().to(0.2, { scale: 0 });
         let call1 = cc.tween().call(() => {
             this.node.destroy();
             XXEvent.emit('event-get-checkpoint-redbag');
         });
-        cc.tween(this.node).then(start_pos).then(dt1).then(scale1).then(call1).start();
+        cc.tween(this.node).then(start_pos).then(call0).then(dt1).then(scale1).then(call1).start();
     }
     private onNewMissionStart() {
         this.flyNode();

+ 38 - 4
tower_sanguo/assets/scripts/module/checkpointRedBag/CheckpointRedBagModle.ts

@@ -1,6 +1,8 @@
-import { PLAYERPROP } from "../../data/GameDefinition";
+import { ViewZorder } from "../../../MOKA/data/ViewZOrder";
+import { PLAYERPROP, RewardState } from "../../data/GameDefinition";
 import GameController from "../../GameController";
 import MainUI from "../main/MainUI";
+import RedEnvelopesUI from "../redEnvelopes/RedEnvelopesUI";
 import CheckpointRedBagBtn from "./CheckpointRedBagBtn";
 
 /**
@@ -96,7 +98,7 @@ export default class CheckpointRedBagModle {
     /** 掉落请求回调 
      *  - 服务端回复
         "StageRewardNum": Integer, (用户通关红包当前数量)
-        "StageRewardRedBag": Integer, (用户打开通关红包币数量)
+        "StageRewardRedBag": Integer, (用户看视频打开通关红包,拿到的红包币数量)
         "StageRewardDrop": Integer, (用户当天红包掉落次数)
         "stageRewardLastTime": Long, (用户最后更新通关红包的时间)
         "stageRewardVideoTime": Integer (用户通关红包视频次数)
@@ -141,13 +143,15 @@ export default class CheckpointRedBagModle {
         this.redbag_data.cur_count += 1;
         this.saveCheckpointRedBag();
     }
+    /** 用户看视频打开通关红包,拿到的红包币数量 */
+    private static StageRewardRedBag: number = 0;
     /** 数量减少 */
     public static onReciveTVRewardCall(reply) {
         cc.log('领取通关红包币结果:', reply)
         let data = reply.data;
         if (data && data.code === 1) {
             let data2 = data.data;
-            // this.redbag_data.cur_count = data2.StageRewardNum;
+            this.StageRewardRedBag = data2.StageRewardRedBag;
             this.redbag_data.cumulative_count = data2.StageRewardDrop;
             this.lookVideoCall();
         } else {
@@ -161,7 +165,37 @@ export default class CheckpointRedBagModle {
         if (!this.comp_main) this.comp_main = GameController.uiM.getUI(MainUI);
         this.redbag_data.cur_count--;
         this.saveCheckpointRedBag();
+        // this.flyNode();
+        this.openRedBagAni();
+    }
+    /** 开红包动画 */
+    private static openRedBagAni() {
+        const world_pos = this.comp_main.btn_chPo_RedBag.node.parent.convertToWorldSpaceAR(this.comp_main.btn_chPo_RedBag.node.getPosition());
+        let reward_data = {
+            /** 活跃宝箱id */
+            id: PLAYERPROP.REDBAG,
+            /** 光圈起始位置【世界坐标】,有值则代表有移动效果 */
+            move_start_pos: world_pos,
+            count: this.StageRewardRedBag,
+            /** 起始缩放 */
+            move_start_scale: 0.08,
+            /** 存在双倍 */
+            exist_double: false,
+            tv_box_state: RewardState.lock,
+            /** 普通奖励状态 */
+            task_box_state: RewardState.unlock,
+            /** 不要在界面内加属性 */
+            addProp: true,
+            /** 界面关闭回调 */
+            close_call: () => {
+                this.flyNode();
+            }
 
+        }
+        GameController.uiM.openUI(RedEnvelopesUI, null, ViewZorder.UI, null, null, reward_data);
+    }
+    /** 飞item动画 */
+    private static flyNode() {
         let start_node_pos = new cc.Vec2(0, -200);
 
         let end_world_pos = this.comp_main.node_hb.node.parent.convertToWorldSpaceAR(this.comp_main.node_hb.node.getPosition());
@@ -175,7 +209,7 @@ export default class CheckpointRedBagModle {
             end_pos: end_node_pos,
             complete_call: () => {
                 // 玩家红包币增加
-                GameController.gameData.player.setProp(PLAYERPROP.CHECKPOINT_REGBAG_DATA, 1, true);
+                GameController.gameData.player.setProp(PLAYERPROP.REDBAG, this.StageRewardRedBag, true);
             },
         }
         // 发起飞item事件

+ 24 - 4
tower_sanguo/assets/scripts/module/redEnvelopes/RedEnvelopesUI.ts

@@ -57,6 +57,10 @@ export default class RedEnvelopesUI extends BaseUI {
         tv_box_state: RewardState.none,
         /** 普通奖励状态 */
         task_box_state: RewardState.none,
+        /** 不要在界面内加属性 */
+        addProp: true,
+        /** 关闭回调 */
+        close_call: null,
 
     };
     onLoad() {
@@ -121,6 +125,9 @@ export default class RedEnvelopesUI extends BaseUI {
         if (this.ui_data.exist_double) this.reward_data.exist_double = this.ui_data.exist_double;
         if (this.ui_data.tv_box_state) this.reward_data.tv_box_state = this.ui_data.tv_box_state;
         if (this.ui_data.task_box_state) this.reward_data.task_box_state = this.ui_data.task_box_state;
+        if (this.ui_data.close_call) this.reward_data.close_call = this.ui_data.close_call;
+        if (this.ui_data.addProp) this.reward_data.addProp = this.ui_data.addProp;
+        
         cc.log(this.ui_data)
     }
     /** 初始化样式 */
@@ -176,6 +183,11 @@ export default class RedEnvelopesUI extends BaseUI {
         }
     }
     private onClickDoubleReceive() {
+        if (this.ui_data.addProp) {
+            // 不要走活跃宝箱相关的逻辑
+            this.close();
+            return;
+        }
         let c_data = {
             isDouble: 0,
             taskId: this.reward_data.id
@@ -195,7 +207,7 @@ export default class RedEnvelopesUI extends BaseUI {
             cc.log(reply)
             let s_data = reply.data;
             if (s_data && s_data.code === 1) {
-                GameController.gameData.updateProp(PLAYERPROP.REDBAG, count, true);
+                GameController.gameData.player.setProp(PLAYERPROP.REDBAG, count, true);
                 if (this.reward_data.exist_double && this.reward_data.tv_box_state === RewardState.unlock) {
                     this.reward_data.tv_box_state = RewardState.none;
                     this.reward_data.task_box_state = RewardState.none;
@@ -208,7 +220,11 @@ export default class RedEnvelopesUI extends BaseUI {
         })
     }
     private onClickReceive() {
-        
+        if (this.ui_data.addProp) {
+            // 不要走活跃宝箱相关的逻辑
+            this.close();
+            return;
+        }
         let c_data = {
             isDouble: 0,
             taskId: this.reward_data.id
@@ -219,13 +235,13 @@ export default class RedEnvelopesUI extends BaseUI {
             if (s_data && s_data.code === 1) {
                 let count = this.reward_data.count;
                 cc.log('普通领取%o', count);
-                GameController.gameData.updateProp(PLAYERPROP.REDBAG, count, true);
+                GameController.gameData.player.setProp(PLAYERPROP.REDBAG, count, true);
                 this.reward_data.exist_double = false;
                 this.node_tv.active = true
                 this.lbl_btn_desc.string = '再次领取';// 看视频
                 this.btn_double_receive.node.active = true;
                 this.btn_receive.node.active = false;
-                
+
                 this.reward_data.task_box_state = RewardState.none;
                 XXEvent.emit('ui-task-updata-active', this.reward_data);
             }
@@ -233,5 +249,9 @@ export default class RedEnvelopesUI extends BaseUI {
         })
 
     }
+    onDestroy(){
+        this.reward_data.close_call && this.reward_data.close_call();
+        super.onDestroy();
+    }
     // update (dt) {}
 }