| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- /** 清除害虫 */
- import { BannerAdType, InterAdType, ProductType, VideoAdType } from "../../../game/data/GameData";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class ADClearSickPanel extends cc.Component {
- @property({ type: cc.Label, tooltip: "标题" }) labTitle: cc.Label = null;
- @property({ type: cc.Label, tooltip: "描述" }) labDes: cc.Label = null;
- @property({ type: cc.Sprite, tooltip: "故障图标" }) sp: cc.Sprite = null;
- @property({ type: cc.Label, tooltip: "按钮文字" }) labBtn: cc.Label = null;
- async onLoad() {
- switch (gData.adClearSickData.tab) {
- case ProductType.nzw:
- this.labTitle.string = '农作物生虫了,无法收获';
- this.labDes.string = '看视频消灭害虫';
- this.labBtn.string = '消灭害虫';
- this.sp.spriteFrame = await mk.loader.load('game/coregame/texture/warning/warning_1', cc.SpriteFrame);
- break;
- case ProductType.dw:
- this.labTitle.string = '动物生病了,无法收获';
- this.labDes.string = '看视频恢复健康';
- this.labBtn.string = '恢复健康';
- this.sp.spriteFrame = await mk.loader.load('game/coregame/texture/warning/warning_2', cc.SpriteFrame);
- break;
- default:
- this.labTitle.string = '商铺停电了,无法收获';
- this.labDes.string = '看视频恢复供电';
- this.labBtn.string = '恢复供电';
- this.sp.spriteFrame = await mk.loader.load('game/coregame/texture/warning/warning_3', cc.SpriteFrame);
- break;
- }
- }
- onEnable() {
- gData.adData.checkPopInter(InterAdType.interstitial1_click_3);
- //mk.ad.showBanner(BannerAdType.banner_click_8);
- mk.ad.showNative();
- }
- onDisable() {
- //mk.ad.destoryBanner();
- mk.ad.destroyNativeAd();
- }
- clickWatchVideo() {
- mk.audio.playEffect("button");
- mk.ui.closePanel(this.node.name);
- switch (gData.adClearSickData.tab) {
- case ProductType.nzw:
- mk.ad.videoAdType = VideoAdType.video_init_7;
- break;
- case ProductType.dw:
- mk.ad.videoAdType = VideoAdType.video_init_8;
- break;
- default:
- mk.ad.videoAdType = VideoAdType.video_init_9;
- break;
- }
- mk.ad.watchAd((success: boolean) => {
- mk.console.log("watchAD:" + success);
- if (success) {
- // gData.adUnlockData.unlockFarm();
- gData.adClearSickData.clearSick();
- gData.adData.watchVideo(null);
- let des = '';
- switch (gData.adClearSickData.tab) {
- case ProductType.nzw:
- des = '已消灭害虫';
- break;
- case ProductType.dw:
- des = '已恢复健康';
- break;
- default:
- des = '已恢复供电';
- break;
- }
- mk.tip.pop(des);
- }
- });
- }
- onClickClose() {
- //关闭banner广告等
- mk.ui.closePanel(this.node.name);
- }
- }
|