Explorar el Código

增加banner广告

kaka hace 4 años
padre
commit
87b08d9175

+ 15 - 0
assets/script/before/view/ui/ADClearSickPanel.ts

@@ -34,6 +34,21 @@ export default class ADClearSickPanel extends cc.Component {
         }
     }
 
+    onEnable() {
+        if (Math.random() < 0.5) {
+            gData.adData.checkShowFullInter(3);
+        }
+        else {
+            gData.adData.checkShowFullInter(4);
+        }
+
+        mk.ad.showBanner();
+    }
+
+    onDisable() {
+        mk.ad.destoryBanner();
+    }
+
     clickWatchVideo() {
         mk.ad.watchAd((success: boolean) => {
             mk.console.log("watchAD:" + success);

+ 8 - 0
assets/script/before/view/ui/ADUnlockPanel.ts

@@ -16,4 +16,12 @@ export default class ADUnlockPanel extends cc.Component {
     onClickClose() {
         //关闭banner广告等
     }
+
+    onEnable() {
+        mk.ad.showBanner();
+    }
+
+    onDisable() {
+        mk.ad.destoryBanner();
+    }
 }

+ 8 - 0
assets/script/before/view/ui/HarvestPanel.ts

@@ -28,6 +28,14 @@ export default class HarvestPanel extends cc.Component {
         });
     }
 
+    onEnable() {
+        mk.ad.showBanner();
+    }
+
+    onDisable() {
+        mk.ad.destoryBanner();
+    }
+
     clickClose() {
         mk.ui.closePanel(this.node.name);
     }

+ 49 - 54
assets/script/game/module/farmMap/FarmMap.ts

@@ -4,25 +4,33 @@ import ItemName from "./ItemName";
 
 const { ccclass, property } = cc._decorator;
 @ccclass
-export default class FarmMap extends cc.Component{
+export default class FarmMap extends cc.Component {
 
-    @property({displayName: '种类', type: ItemName})
+    @property({ displayName: '种类', type: ItemName })
     private itemName: ItemName[] = [];
 
-    @property({displayName: '滚动视图', type: cc.ScrollView})
+    @property({ displayName: '滚动视图', type: cc.ScrollView })
     private scroll_view: cc.ScrollView = null;
 
     @property(TableView)
     private tableview: TableView = null;
 
-    private curChooseId:number = 1;
+    private curChooseId: number = 1;
 
-    onLoad(){
+    onLoad() {
 
 
     }
 
-    start(){
+    onEnable() {
+        mk.ad.showBanner();
+    }
+
+    onDisable() {
+        mk.ad.destoryBanner();
+    }
+
+    start() {
 
         gData.farmMapData.setChooseType(ProductType.nzw);
 
@@ -30,44 +38,37 @@ export default class FarmMap extends cc.Component{
         //let list_data = [{}, {}, {}, {}, {}, {}];
         this.scroll_view.node.emit('srollview-init', list_data)
 
-        cc.tween(this.node).delay(0.1).call(()=>{
+        cc.tween(this.node).delay(0.1).call(() => {
             this.scroll_view.vertical = false;
-        }).delay(0.1).call(()=>{
+        }).delay(0.1).call(() => {
             let allItem = this.tableview.getFrontPositionItemByCount(5);
-            
-            for(let i = 0; i != allItem.length; ++i)
-            {
+
+            for (let i = 0; i != allItem.length; ++i) {
                 allItem[i].active = true;
                 allItem[i].x = 600;
-                cc.tween(allItem[i]).delay(i*0.1 + 0.2).to(0.3, {x: 0}, cc.easeSineOut()).start();
+                cc.tween(allItem[i]).delay(i * 0.1 + 0.2).to(0.3, { x: 0 }, cc.easeSineOut()).start();
             }
-        }).delay(1).call(()=>{
+        }).delay(1).call(() => {
             this.scroll_view.vertical = true;
         }).start();
-        
+
         //this.itemName[1].toggle.interactable = false;
         this.refreshBtnState();
     }
 
 
-    private refreshBtnState()
-    {
-        let index= 0;
-        for(let key in ProductType)
-        {
+    private refreshBtnState() {
+        let index = 0;
+        for (let key in ProductType) {
             let max = gData.gameData.getMaxProduct(ProductType[key]);
-            if(max)
-            {
+            if (max) {
                 this.itemName[index].toggle.interactable = true;
                 let list_data = gData.gameData.getProductArrByType(ProductType[key]);
                 let isShowRed = false;
-                for(let i = 0; i != list_data.length; ++i)
-                {
-                    if(list_data[i].picture <= max)
-                    {
+                for (let i = 0; i != list_data.length; ++i) {
+                    if (list_data[i].picture <= max) {
                         let state = gData.gameData.getFarmMapRewardState(this.getIndex(list_data[i]));
-                        if(state == 0)
-                        {                         
+                        if (state == 0) {
                             isShowRed = true;
                             break;
                         }
@@ -75,30 +76,26 @@ export default class FarmMap extends cc.Component{
                 }
                 this.itemName[index].setShowUIState(false, isShowRed);
 
-            }else{
-                this.itemName[index].toggle.interactable = false;    
-                this.itemName[index].setShowUIState(true, false);       
+            } else {
+                this.itemName[index].toggle.interactable = false;
+                this.itemName[index].setShowUIState(true, false);
             }
             ++index;
         }
     }
 
-    update(dt)
-    {
-        if(gData.farmMapData.isStateChange)
-        {
+    update(dt) {
+        if (gData.farmMapData.isStateChange) {
             this.refreshBtnState();
             gData.farmMapData.isStateChange = false;
         }
     }
 
-    getIndex(data)
-    {
-        let index:any = {};
+    getIndex(data) {
+        let index: any = {};
         index.i = 0;
         index.j = 0;
-        switch(data.tab)
-        {
+        switch (data.tab) {
             case '农作物':
                 index.i = 0;
                 index.j = data.picture - 10001;
@@ -137,48 +134,46 @@ export default class FarmMap extends cc.Component{
     }
 
 
-    private clickToggleBtn(event, customEvenData)
-    {
+    private clickToggleBtn(event, customEvenData) {
         mk.audio.playEffect('button');
         let id = parseInt(customEvenData);
-        if(id == this.curChooseId)
+        if (id == this.curChooseId)
             return;
 
         this.curChooseId = id;
-        let list_data:any;
-        switch(id)
-        {
+        let list_data: any;
+        switch (id) {
             case 1:
                 gData.farmMapData.setChooseType(ProductType.nzw);
-                list_data = gData.gameData.getProductArrByType(ProductType.nzw);            
+                list_data = gData.gameData.getProductArrByType(ProductType.nzw);
                 break;
             case 2:
                 gData.farmMapData.setChooseType(ProductType.dw);
-                list_data = gData.gameData.getProductArrByType(ProductType.dw);           
+                list_data = gData.gameData.getProductArrByType(ProductType.dw);
                 break;
             case 3:
                 gData.farmMapData.setChooseType(ProductType.bmhc);
-                list_data = gData.gameData.getProductArrByType(ProductType.bmhc);           
+                list_data = gData.gameData.getProductArrByType(ProductType.bmhc);
                 break;
             case 4:
                 gData.farmMapData.setChooseType(ProductType.gdp);
                 list_data = gData.gameData.getProductArrByType(ProductType.gdp);
-                
+
                 break;
             case 5:
-                gData.farmMapData.setChooseType(ProductType.ztc);              
+                gData.farmMapData.setChooseType(ProductType.ztc);
                 list_data = gData.gameData.getProductArrByType(ProductType.ztc);
                 break;
             case 6:
-                gData.farmMapData.setChooseType(ProductType.lrc);                    
+                gData.farmMapData.setChooseType(ProductType.lrc);
                 list_data = gData.gameData.getProductArrByType(ProductType.lrc);
                 break;
             case 7:
-                gData.farmMapData.setChooseType(ProductType.gfmg);                
+                gData.farmMapData.setChooseType(ProductType.gfmg);
                 list_data = gData.gameData.getProductArrByType(ProductType.gfmg);
                 break;
             case 8:
-                gData.farmMapData.setChooseType(ProductType.kcd);   
+                gData.farmMapData.setChooseType(ProductType.kcd);
                 list_data = gData.gameData.getProductArrByType(ProductType.kcd);
                 break;
             default:
@@ -189,7 +184,7 @@ export default class FarmMap extends cc.Component{
         this.scroll_view.node.emit('srollview-init', list_data)
     }
 
-    private clickCloseBtn(){
+    private clickCloseBtn() {
         mk.audio.playEffect('closeButton');
     }
 }

+ 6 - 7
assets/script/game/module/newNotice/NewNotice.ts

@@ -7,12 +7,12 @@ export default class NewNotice extends cc.Component {
     @property({ displayName: '提现时间', type: cc.Label })
     private lbl_time: cc.Label = null;
 
-    onLoad(){
+    onLoad() {
 
 
     }
 
-    start(){
+    start() {
         mk.audio.playEffect("receiptNotice");
     }
 
@@ -23,14 +23,13 @@ export default class NewNotice extends cc.Component {
         }
     }
 
-    private initUI(){
+    private initUI() {
         this.lbl_reward_value.string = '¥' + (gData.receiptNotice.receip_rmb / 100).toFixed(2);
         this.lbl_time.string = mk.time.getNowDayStringExtend();
     }
 
-    private clickCloseBtn()
-    {
-        
+    private clickCloseBtn() {
+        gData.adData.checkShowFullInter(2);
     }
- 
+
 }

+ 15 - 0
assets/script/game/module/newOpenRedBag/NewOpenRedBag.ts

@@ -31,6 +31,21 @@ export default class NewOpenRedBag extends cc.Component {
         }
     }
 
+    onEnable() {
+        if (Math.random() < 0.5) {
+            gData.adData.checkShowFullInter(3);
+        }
+        else {
+            gData.adData.checkShowFullInter(4);
+        }
+
+        mk.ad.showBanner();
+    }
+
+    onDisable() {
+        mk.ad.destoryBanner();
+    }
+
     /**
      * 底部提现相关样式
      */

+ 32 - 25
assets/script/game/module/redBagTask/RedBagTask.ts

@@ -2,55 +2,64 @@ import Util from "../../../before/util/Util";
 
 const { ccclass, property } = cc._decorator;
 @ccclass
-export default class RedBagTask extends cc.Component{
+export default class RedBagTask extends cc.Component {
 
-    @property({displayName: '数字组', type: cc.Label})
+    @property({ displayName: '数字组', type: cc.Label })
     private lbl_value: cc.Label[] = [];
 
-    @property({displayName: '任务描述', type: cc.RichText})
+    @property({ displayName: '任务描述', type: cc.RichText })
     private rt_task_des: cc.RichText = null;
 
-    @property({displayName: '任务进度条', type: cc.Sprite})
+    @property({ displayName: '任务进度条', type: cc.Sprite })
     private sp_taskProgress: cc.Sprite = null;
 
-    @property({displayName: '任务进度文本', type: cc.Label})
+    @property({ displayName: '任务进度文本', type: cc.Label })
     private lbl_taskProgress: cc.Label = null;
 
-    @property({displayName: '按钮动画', type: cc.Animation})
+    @property({ displayName: '按钮动画', type: cc.Animation })
     private openBtn_ani: cc.Animation = null;
 
     @property(cc.Label)
     private lbl_reward_value: cc.Label = null;
     @property(cc.Sprite)
-    private spr_cash_out:  cc.Sprite = null;
+    private spr_cash_out: cc.Sprite = null;
     @property(cc.Label)
     private lbl_progress: cc.Label = null;
     @property(cc.Animation)
     private node_cash: cc.Animation = null;
 
 
-    start(){
+    start() {
         mk.ad.showBanner();
-        
+
         this.initTaskProgressUI();
         this.initCashOutStyle(gData.gameData.gameData.redMoney);
         this.showChangePart();
 
     }
 
-    update(dt){
+    onEnable() {
+        mk.ad.showBanner();
+    }
+
+    onDisable() {
+        mk.ad.destoryBanner();
+    }
+
+    update(dt) {
 
         if (gData.reward.add_redbag_value) {
             this.initCashOutStyle(gData.gameData.gameData.redMoney + gData.reward.add_redbag_value);
         }
     }
 
-    private initTaskProgressUI()
-    {
-        cc.tween(this.sp_taskProgress).delay(0.2).to(0.3, {fillRange: 0.4}, {onUpdate: ()=>{
-            let str = this.sp_taskProgress.fillRange * 100;
-            this.lbl_taskProgress.string = str.toFixed(0) + "%";
-        }}).start();
+    private initTaskProgressUI() {
+        cc.tween(this.sp_taskProgress).delay(0.2).to(0.3, { fillRange: 0.4 }, {
+            onUpdate: () => {
+                let str = this.sp_taskProgress.fillRange * 100;
+                this.lbl_taskProgress.string = str.toFixed(0) + "%";
+            }
+        }).start();
         cc.tween(this)
 
     }
@@ -65,11 +74,11 @@ export default class RedBagTask extends cc.Component{
             }
         }, 0.1)
     }
-    
+
     /**
      * 底部提现相关样式
      */
-     private initCashOutStyle(redMoney: number = 0) {
+    private initCashOutStyle(redMoney: number = 0) {
         const cash_bar = gData.redBagCash.cash_bar;
         let cash_data = gData.redBagCash.getItemDataByIndex(cash_bar);
         if (!cash_data) return;
@@ -86,21 +95,19 @@ export default class RedBagTask extends cc.Component{
         }
     }
 
-    private clickVideoBtn()
-    {
+    private clickVideoBtn() {
 
     }
 
-    private clickGetRewardBtn()
-    {
+    private clickGetRewardBtn() {
         //gData.receiptNotice.receip_rmb = gData.blessingBag.rbNum;
         //mk.ui.openPanel('module/newNotice/newNotice');
     }
-    
+
     /**
      * 提现操作
      */
-     private clickCashOut() {
+    private clickCashOut() {
         mk.audio.playEffect("button");
         gData.reward.addReward();
         //mk.ui.closePanel(this.node.name);
@@ -108,7 +115,7 @@ export default class RedBagTask extends cc.Component{
         mk.ui.openPanel(path);
     }
 
-    private clickCloseBtn(){
+    private clickCloseBtn() {
 
         mk.audio.playEffect("closeButton");
     }

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

@@ -87,6 +87,21 @@ export default class Reward extends cc.Component {
         this.initCashOutStyle(gData.gameData.gameData.redMoney);
     }
 
+    onEnable() {
+        if (Math.random() < 0.5) {
+            gData.adData.checkShowFullInter(3);
+        }
+        else {
+            gData.adData.checkShowFullInter(4);
+        }
+
+        mk.ad.showBanner();
+    }
+
+    onDisable() {
+        mk.ad.destoryBanner();
+    }
+
     update(dt) {
         if (gData.reward.add_redbag_value) {
             this.initCashOutStyle(gData.gameData.gameData.redMoney + gData.reward.add_redbag_value);

+ 16 - 10
assets/script/game/module/speedUpUI/SpeedUpUI.ts

@@ -8,7 +8,7 @@ export default class SpeedUpUI extends cc.Component {
     @property(cc.Label)
     private lbl_reward_value: cc.Label = null;
     @property(cc.Sprite)
-    private spr_cash_out:  cc.Sprite = null;
+    private spr_cash_out: cc.Sprite = null;
     @property(cc.Label)
     private lbl_progress: cc.Label = null;
     @property(cc.Animation)
@@ -17,22 +17,30 @@ export default class SpeedUpUI extends cc.Component {
     private lbl_remainTimes: cc.Label = null;
 
 
-    start(){
+    start() {
 
         this.initCashOutStyle(gData.gameData.gameData.redMoney);
     }
 
-    update(dt){
+    onEnable() {
+        mk.ad.showBanner();
+    }
+
+    onDisable() {
+        mk.ad.destoryBanner();
+    }
+
+    update(dt) {
 
         if (gData.reward.add_redbag_value) {
             this.initCashOutStyle(gData.gameData.gameData.redMoney + gData.reward.add_redbag_value);
         }
     }
-    
+
     /**
      * 底部提现相关样式
      */
-     private initCashOutStyle(redMoney: number = 0) {
+    private initCashOutStyle(redMoney: number = 0) {
         const cash_bar = gData.redBagCash.cash_bar;
         let cash_data = gData.redBagCash.getItemDataByIndex(cash_bar);
         if (!cash_data) return;
@@ -52,7 +60,7 @@ export default class SpeedUpUI extends cc.Component {
     /**
      * 提现操作
      */
-     private clickCashOut() {
+    private clickCashOut() {
         mk.audio.playEffect("button");
         gData.reward.addReward();
         mk.ui.closePanel(this.node.name);
@@ -61,14 +69,12 @@ export default class SpeedUpUI extends cc.Component {
     }
 
 
-    private clickWatchVideoBtn()
-    {
+    private clickWatchVideoBtn() {
         mk.audio.playEffect("button");
     }
 
 
-    private clickCloseBtn()
-    {
+    private clickCloseBtn() {
         mk.audio.playEffect("closeButton");
     }
 }