UIADPanel.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { utils } from "../../common-plugin/Scripts/Utils";
  2. import { cocosz } from "../Framework/CocosZ";
  3. import Msg from "../Framework/Msg";
  4. // @ts-ignore
  5. const i18n = require('LanguageData');
  6. const { ccclass, property } = cc._decorator;
  7. @ccclass
  8. export default class NewClass extends cc.Component {
  9. @property(cc.Node)
  10. btnAD: cc.Node = null;
  11. @property(cc.Node)
  12. btnSkip: cc.Node = null;
  13. start() {
  14. if (cocosz.isADON) {
  15. this.node.scale = 0;
  16. cc.tween(this.node).to(0.3, { scale: 1 }, { easing: "backOut" }).start();
  17. utils.SendEvent("页面-" + (this.isDiamond ? "钻石" : "金币"));
  18. } else {
  19. this.node.destroy();
  20. }
  21. }
  22. isDiamond: boolean = false;
  23. setDiamond() {
  24. this.isDiamond = true;
  25. this.node.getChildByName("bg").active = false;
  26. this.node.getChildByName("bg1").active = true;
  27. }
  28. watchAD() {
  29. utils.SendEvent(`视频-${this.isDiamond ? "钻石购买" : "金币购买"}-播放`)
  30. cocosz.watchAD(() => {
  31. utils.SendEvent(`视频-${this.isDiamond ? "钻石购买" : "金币购买"}-成功`)
  32. if (this.isDiamond) {
  33. let num = cocosz.isDeBug ? 10000 : 200;
  34. cocosz.dataMgr.DiamondCount += num;
  35. Msg.Show(i18n.t("msg.gxhdzs") + num);//恭喜获得钻石
  36. }
  37. else {
  38. let num = cocosz.isDeBug ? 10000 : 500;
  39. cocosz.dataMgr.CoinCount += num;
  40. Msg.Show(i18n.t("msg.gxhdjb") + num);//恭喜获得金币
  41. }
  42. this.node.destroy();
  43. }, () => {
  44. utils.SendEvent(`视频-${this.isDiamond ? "钻石购买" : "金币购买"}-失败`)
  45. })
  46. }
  47. exit() {
  48. cocosz.audioMgr.playBtnEffect();
  49. this.node.destroy();
  50. }
  51. }