FExit.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import FqLogin from "../../../login/FqLogin";
  2. import { AudioMgr } from "../../../main/ViewManage";
  3. import FExitBox from "../box/FExitBox";
  4. import FF from "../FF";
  5. import BaseEvent from "./base/BaseEvent";
  6. /**
  7. * 退出副本事件
  8. */
  9. const { ccclass, property } = cc._decorator;
  10. @ccclass
  11. export default class FExit extends BaseEvent {
  12. @property({
  13. displayName: '提示图标',
  14. type: cc.SpriteFrame
  15. })
  16. mTipsIcon: cc.SpriteFrame = null;
  17. private isEnd = false;
  18. onLoad(){
  19. super.onLoad();
  20. this.node.zIndex = -9999;
  21. }
  22. onBegin(tag: number) {
  23. if (this.isEnd) {
  24. return
  25. }
  26. if (tag == 1) {
  27. this.showOpt(this.mTipsIcon, () => {
  28. this.exitFF(this.ff);
  29. })
  30. }
  31. }
  32. onEnd(tag: number) {
  33. if (tag == 1) {
  34. this.closeOpt()
  35. }
  36. }
  37. private exitFF(ff: FF) {
  38. this.ff = ff;
  39. ff.stopRuning();
  40. ff.pauseSprite(true);
  41. let node = cc.instantiate(this.ff.mExitBox);
  42. let exitBox = node.getComponent(FExitBox);
  43. exitBox.main = this.ff.main;
  44. exitBox.init(this.ff.mFFheader.stageData);
  45. exitBox.show();
  46. exitBox.setCloseCallback(() => {
  47. ff.pauseSprite(false);
  48. })
  49. exitBox.setOKCallback(() => {
  50. this.isEnd = true;
  51. this.ff.exitCallback();
  52. this.ff.main.topNode.active = true;
  53. this.ff.main.playMusicByPath(AudioMgr.homeMusic);
  54. });
  55. FqLogin.commitEvent(this.node.name, '', '');
  56. }
  57. }