UI_Revive.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { _decorator, Component, Node } from 'cc';
  2. import { aa, UIController, UIElement } from 'db://assets/scripts/aa';
  3. import { UI_Dialog } from '../UI_Dialog';
  4. import { rootMgr } from '../../../scene/RootMgr';
  5. const { ccclass, property } = _decorator;
  6. @UIController({ bundleName: 'dialog', path: 'revive/revive' })
  7. //复活面板
  8. @ccclass('UI_Revive')
  9. export class UI_Revive extends UI_Dialog {
  10. @UIElement(Node)
  11. reviveBtn: Node;
  12. @UIElement(Node)
  13. closebtn: Node;
  14. @UIElement(Node)
  15. closeBtn001: Node;
  16. start() {
  17. this.reviveBtn.on(Node.EventType.TOUCH_END, this.handleRevive, this)
  18. this.closebtn.on(Node.EventType.TOUCH_END, this.closeFile, this)
  19. this.closeBtn001.on(Node.EventType.TOUCH_END, this.closeFile, this)
  20. }
  21. //复活按钮
  22. private handleRevive() {
  23. // 播放复活广告
  24. aa.sdk.playRewardAd("复活-解锁新桌子").then((ok) => {
  25. if (ok) {
  26. rootMgr.game.evt.emit('revive_request')// 广告成功,执行复活
  27. this.close(); // 关闭面板
  28. } else {
  29. rootMgr.game.evt.emit('revive_fail'); // 广告失败,游戏结束
  30. this.close(); // 关闭面板
  31. }
  32. });
  33. }
  34. closeFile() {
  35. rootMgr.game.evt.emit('revive_fail'); // 广告失败,游戏结束
  36. this.close(); // 关闭面板
  37. }
  38. }