Просмотр исходного кода

Merge branch 'master' of http://git.mokasz.com/zouyong/mk_framework into master

fengcong 5 лет назад
Родитель
Сommit
13f5e14acc

Разница между файлами не показана из-за своего большого размера
+ 298 - 238
assets/resources/module/blessingBag/blessingBag.prefab


Разница между файлами не показана из-за своего большого размера
+ 244 - 182
assets/resources/module/cashPro/cashPro.prefab


+ 34 - 9
assets/script/game/component/TableView.ts

@@ -4,17 +4,20 @@ const { ccclass, property } = cc._decorator;
 /** 动态加载的滚动列表
  * - 滑动列表动态加载
  * - 支持多种类型预制体混合滚动 
+ * 
  * - item脚本需要有函数 setItemData 用于接收数据
+ * 
  * - 多个prefab混合时,要为每条item指定 pfbType
+ * 
  * - item、content锚点y需要为1其他为0.5
  * @author 薛鸿潇
 */
 @ccclass
 export default class TableView extends cc.Component {
 
-    @property({ displayName: '预制条目', type: [cc.Prefab] })
+    @property({ displayName: '预制条目', tooltip: '脚本必须实现 setItemData 方法用于接收数据!', type: [cc.Prefab] })
     private pre_item: cc.Prefab[] = [];
-    @property({ displayName: '脚本名', type: [cc.String] })
+    @property({ displayName: '脚本名', tooltip: '脚本必须实现 setItemData 方法用于接收数据!', type: [cc.String] })
     private scr_item: string[] = [];
     /** 间距 */
     @property({ displayName: '间距' })
@@ -65,6 +68,7 @@ export default class TableView extends cc.Component {
             this.itemNode[i] = cc.instantiate(this.item[i]);
         }
         this.node.on('srollview-init', this.init, this);
+        this.node.on('srollview-update', this.updateList, this);
     }
 
     /**
@@ -99,11 +103,31 @@ export default class TableView extends cc.Component {
         // cc.log('tableView结束:' + this.testTime());
     }
 
-    /** 
-     * 刷新列表 
-     * 仅更新data数据
-    */
-    private updateList() {
+    /**
+     * 刷新列表
+     * - 仅支持使用1种预制体时,更新data数据
+     * @param itemData 
+     */
+    public updateList(itemData: Array<any>) {
+        this.itemData = itemData;
+        const old_count = this.itemArr.length;
+        for (let i = 0; i < old_count; i++) {
+            if (this.itemData[i]) {
+                if (!this.itemArr[i]) {
+                    let y = 0;
+                    if (i > 0) {
+                        y = this.itemArr[i - 1].y - this.itemArr[i - 1].height - this.itemInterval;// 下一条目纵坐标
+                    }
+                    let item_node = this.addItemNode(i, y);
+                    this.updateContentHeigh(this.itemArr[i].height - item_node.y);
+                }
+                let comp_script = this.itemArr[i].getComponent(this.scr_item[this.itemData[i].pfbType || 0]);
+                comp_script && comp_script.setItemData(this.itemData[i], this);
+            } else {
+                this.itemArr[i].destroy();
+                this.itemArr[i] = null;
+            }
+        }
 
     }
 
@@ -142,8 +166,8 @@ export default class TableView extends cc.Component {
             if (i > 0) {
                 y = this.itemArr[i - 1].y - this.itemArr[i - 1].height - this.itemInterval;// 下一条目纵坐标
             }
-            this.addItemNode(i, y);
-            this.updateContentHeigh(this.itemArr[i].height - y);
+            let item_node = this.addItemNode(i, y);
+            this.updateContentHeigh(this.itemArr[i].height - item_node.y);
         }
     }
 
@@ -168,6 +192,7 @@ export default class TableView extends cc.Component {
         let comp_script = item.getComponent(this.scr_item[pfbType]);
         comp_script && comp_script.setItemData(this.itemData[i], this);
         this.itemArr.push(item);
+        return item;
         // cc.log('生成itemNode' + i);
     }
 

+ 28 - 22
assets/script/game/module/module/blessingBag/BlessingBag.ts

@@ -5,7 +5,6 @@
 
 import { AdFun } from "../../../data/AdData";
 import { cashProType } from "../../../data/module/CashProData";
-import BlessingBagItem from "./BlessingBagItem";
 
 
 const { ccclass, property } = cc._decorator;
@@ -71,12 +70,12 @@ export default class BlessingBag extends cc.Component {
     /**红包页面类型 1 大额 2 任务*/
     private rbPanelType: number = 0;
 
-    private adrbArray: BlessingBagItem[] = [];
+    private adrbArray = [];
 
     private isPlayInitAni = true;
 
     onLoad() {
-        // this.testNode.active = gData.gameData.configs.globalCfg.VideoRedBagEmpty == 1;
+        this.testNode.active = gData.gameData.configs.globalCfg.VideoRedBagEmpty == 1;
     }
 
     onEnable() {
@@ -84,13 +83,13 @@ export default class BlessingBag extends cc.Component {
         this.isPlayInitAni = true;
     }
 
-    onDisable() {
-        if (this.adrbArray.length >= 4) {
-            for (let i = 0; i < this.adrbArray.length; i++) {
-                this.adrbArray[i].OnExit();
-            }
-        }
-    }
+    // onDisable() {
+    //     if (this.adrbArray.length >= 4) {
+    //         for (let i = 0; i < this.adrbArray.length; i++) {
+    //             this.adrbArray[i].OnExit();
+    //         }
+    //     }
+    // }
 
     update(dt) {
         this.PlayMoneyAniUpdate(dt);
@@ -160,18 +159,29 @@ export default class BlessingBag extends cc.Component {
         if (this.adrbArray.length < 4) {
             this.adrbArray = [];
             this.itemContent.removeAllChildren();
+
             for (let i = 0; i < data.redMonies.length; i++) {
-                let copyitem = cc.instantiate(this.blassingBagItem);
-                copyitem.active = true;
-                this.itemContent.addChild(copyitem);
-                let copySrc = copyitem.getComponent(BlessingBagItem);
-                copySrc.Init(data.redMonies[i], gData.blessingBag.isPlayAniUpdate, this.isPlayInitAni);
-                this.adrbArray.push(copySrc);
+                let obj = {
+                    data: data.redMonies[i],
+                    isPlayAniUpdate: gData.blessingBag.isPlayAniUpdate,
+                    isPlayInitAni: this.isPlayInitAni
+                }
+                this.adrbArray.push(obj);
             }
+            this.itemContent.emit('srollview-init', this.adrbArray);
         } else {
+            this.adrbArray = [];
+
             for (let i = 0; i < data.redMonies.length; i++) {
-                this.adrbArray[i].Init(data.redMonies[i], gData.blessingBag.isPlayAniUpdate, this.isPlayInitAni);
+                let obj = {
+                    data: data.redMonies[i],
+                    isPlayAniUpdate: gData.blessingBag.isPlayAniUpdate,
+                    isPlayInitAni: this.isPlayInitAni
+                }
+                this.adrbArray.push(obj);
             }
+            //刷新
+
         }
 
         this.isPlayInitAni = false;
@@ -304,12 +314,8 @@ export default class BlessingBag extends cc.Component {
         }
     }
 
-    Click_RedCodeBtn() {
-        // UIMng.Ins.AsyncGetPanel(PanelType.RedCodeListPanel, (panel) => {
-        //     panel.OnEnter(60);
-        // });
-    }
 
+    /** 点击帮助回调 */
     clickHelpCallBack() {
         gData.help.getDescContent(this.node.name)
     }

+ 10 - 1
assets/script/game/module/module/blessingBag/BlessingBagItem.ts

@@ -6,7 +6,7 @@
 const { ccclass, property } = cc._decorator;
 
 @ccclass
-export default class BlessingBagItem extends cc.Component {
+export default class BlessingBagItem extends cc.Component{
 
     @property(cc.Label)
     txtNum: cc.Label = null;
@@ -35,6 +35,15 @@ export default class BlessingBagItem extends cc.Component {
 
     isPlayAni: boolean = false;
 
+    /**
+     * list_data
+     * @param data item数据
+     */
+    public async setItemData(bData) {
+        let data = bData.item_data;
+        this.Init(data.data, data.isPlayAniUpdate, data.isPlayInitAni);
+    }
+
     Init(data: any, isPlayAni: boolean = false, isPlayInitAni: boolean = false) {
         this.data = data;
         this.txtNum.string = data.redMoney + "元";

+ 1 - 0
assets/script/game/module/module/cashPro/CashPro.ts

@@ -85,6 +85,7 @@ export default class CashPro extends cc.Component {
 
     showCashPro() {
         this.cashPro.active = true;
+        mk.tween.moveTo(this.cashPro, 0.3, cc.v2(1000, 0), cc.v2(0, 0));
         this.labMoney.string = `¥${this.money}`
     }
 

Некоторые файлы не были показаны из-за большого количества измененных файлов