AdPanel.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { _decorator, Button, Component, director, Node } from 'cc';
  2. import { BasePanel } from './BasePanel';
  3. import { PlayerCtl } from '../Game/PlayerCtl';
  4. import { LoadRes } from '../Config/LoadRes';
  5. import { StateManager, FailState } from '../Game/StateManager';
  6. import { UIManager } from './UIManager';
  7. const { ccclass, property } = _decorator;
  8. @ccclass('AdPanel')
  9. export class AdPanel extends BasePanel {
  10. private Get_Btn:Button;
  11. private Cancel_Btn:Button;
  12. start() {
  13. this.Get_Btn = this.node.getChildByName("Get_Btn").getComponent(Button);
  14. this.Cancel_Btn = this.node.getChildByName("Cancel_Btn").getComponent(Button);
  15. this.Get_Btn.node.on(Button.EventType.CLICK, this.onGet, this);
  16. this.Cancel_Btn.node.on(Button.EventType.CLICK, this.onCancel, this);
  17. }
  18. //看广告
  19. onGet() {
  20. super.onClose(null);
  21. PlayerCtl.instance.onAdFinish();
  22. }
  23. //不看广告
  24. onCancel() {
  25. StateManager.getInstance().setState(new FailState());
  26. super.onClose(()=>{
  27. //游戏结束,调用结算界面
  28. UIManager.Instance.ShowUI('resultPanel', LoadRes.getInstance().resultPanel);
  29. });
  30. }
  31. update(deltaTime: number) {
  32. }
  33. onClose() {
  34. super.onClose(null);
  35. }
  36. }