ADClearSickPanel.ts 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. }
  36. onDisable() {
  37. mk.ad.destoryBanner();
  38. }
  39. clickWatchVideo() {
  40. mk.audio.playEffect("button");
  41. mk.ui.closePanel(this.node.name);
  42. switch (gData.adClearSickData.tab) {
  43. case ProductType.nzw:
  44. mk.ad.videoAdType = VideoAdType.video_init_7;
  45. break;
  46. case ProductType.dw:
  47. mk.ad.videoAdType = VideoAdType.video_init_8;
  48. break;
  49. default:
  50. mk.ad.videoAdType = VideoAdType.video_init_9;
  51. break;
  52. }
  53. mk.ad.watchAd((success: boolean) => {
  54. mk.console.log("watchAD:" + success);
  55. if (success) {
  56. // gData.adUnlockData.unlockFarm();
  57. gData.adClearSickData.clearSick();
  58. gData.adData.watchVideo(null);
  59. let des = '';
  60. switch (gData.adClearSickData.tab) {
  61. case ProductType.nzw:
  62. des = '已消灭害虫';
  63. break;
  64. case ProductType.dw:
  65. des = '已恢复健康';
  66. break;
  67. default:
  68. des = '已恢复供电';
  69. break;
  70. }
  71. mk.tip.pop(des);
  72. }
  73. });
  74. }
  75. onClickClose() {
  76. //关闭banner广告等
  77. mk.ui.closePanel(this.node.name);
  78. }
  79. }