ADClearSickPanel.ts 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /** 清除害虫 */
  2. import { BannerAdType, InterAdType, ProductType, VideoAdType } from "../../../game/data/GameData";
  3. const { ccclass, property } = cc._decorator;
  4. @ccclass
  5. export default class ADClearSickPanel extends cc.Component {
  6. @property({ type: cc.Label, tooltip: "标题" }) labTitle: cc.Label = null;
  7. @property({ type: cc.Label, tooltip: "描述" }) labDes: cc.Label = null;
  8. @property({ type: cc.Sprite, tooltip: "故障图标" }) sp: cc.Sprite = null;
  9. @property({ type: cc.Label, tooltip: "按钮文字" }) labBtn: cc.Label = null;
  10. async onLoad() {
  11. switch (gData.adClearSickData.tab) {
  12. case ProductType.nzw:
  13. this.labTitle.string = '农作物生虫了,无法收获';
  14. this.labDes.string = '看视频消灭害虫';
  15. this.labBtn.string = '消灭害虫';
  16. this.sp.spriteFrame = await mk.loader.load('game/coregame/texture/warning/warning_1', cc.SpriteFrame);
  17. break;
  18. case ProductType.dw:
  19. this.labTitle.string = '动物生病了,无法收获';
  20. this.labDes.string = '看视频恢复健康';
  21. this.labBtn.string = '恢复健康';
  22. this.sp.spriteFrame = await mk.loader.load('game/coregame/texture/warning/warning_2', cc.SpriteFrame);
  23. break;
  24. default:
  25. this.labTitle.string = '商铺停电了,无法收获';
  26. this.labDes.string = '看视频恢复供电';
  27. this.labBtn.string = '恢复供电';
  28. this.sp.spriteFrame = await mk.loader.load('game/coregame/texture/warning/warning_3', cc.SpriteFrame);
  29. break;
  30. }
  31. }
  32. onEnable() {
  33. gData.adData.checkPopInter(InterAdType.interstitial1_click_3);
  34. //mk.ad.showBanner(BannerAdType.banner_click_8);
  35. mk.ad.showNative();
  36. }
  37. onDisable() {
  38. //mk.ad.destoryBanner();
  39. mk.ad.destroyNativeAd();
  40. }
  41. clickWatchVideo() {
  42. mk.audio.playEffect("button");
  43. mk.ui.closePanel(this.node.name);
  44. switch (gData.adClearSickData.tab) {
  45. case ProductType.nzw:
  46. mk.ad.videoAdType = VideoAdType.video_init_7;
  47. break;
  48. case ProductType.dw:
  49. mk.ad.videoAdType = VideoAdType.video_init_8;
  50. break;
  51. default:
  52. mk.ad.videoAdType = VideoAdType.video_init_9;
  53. break;
  54. }
  55. mk.ad.watchAd((success: boolean) => {
  56. mk.console.log("watchAD:" + success);
  57. if (success) {
  58. // gData.adUnlockData.unlockFarm();
  59. gData.adClearSickData.clearSick();
  60. gData.adData.watchVideo(null);
  61. let des = '';
  62. switch (gData.adClearSickData.tab) {
  63. case ProductType.nzw:
  64. des = '已消灭害虫';
  65. break;
  66. case ProductType.dw:
  67. des = '已恢复健康';
  68. break;
  69. default:
  70. des = '已恢复供电';
  71. break;
  72. }
  73. mk.tip.pop(des);
  74. }
  75. });
  76. }
  77. onClickClose() {
  78. //关闭banner广告等
  79. mk.ui.closePanel(this.node.name);
  80. }
  81. }