UIInvitation.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import DataMgr from "../data/DataMgr";
  2. import { GameMode, RESTART_GAME } from "../data/Define";
  3. import UIBase from "../fgui/core/UIBase";
  4. import ui_UIInvitation from "../fgui/res/game/ui_UIInvitation";
  5. import { xGame } from "../xGame";
  6. /**
  7. * 摆球达人界面,选择关卡界面
  8. */
  9. export default class UIInvitation extends UIBase {
  10. public ui: ui_UIInvitation;
  11. public constructor() {
  12. super();
  13. }
  14. public onConstructor(): void {
  15. this.ui = ui_UIInvitation.createInstance();
  16. this.contentPane = this.ui;
  17. this.isEject = false;
  18. //
  19. this.addUIClick(this.ui.myNode.enterBtn, this.enterGame);
  20. }
  21. public show(): void {
  22. super.show();
  23. }
  24. public enterGame() {
  25. xGame.common.gameMode = GameMode.classic;
  26. DataMgr.setChallengeTimes(1);
  27. xGame.common.passAwardCoin = 2000;
  28. let need = xGame.common.classicNiceNeddCoin;
  29. if (DataMgr.coinEnough(need)) {
  30. DataMgr.setCoin(-need);
  31. //开始游戏
  32. xGame.eventMgr.event(RESTART_GAME, true);
  33. Moyu.sendDataEvent("enterChallenge", { mode: xGame.common.gameMode });
  34. //
  35. }
  36. else {
  37. //金币不够时也强制进入
  38. xGame.eventMgr.event(RESTART_GAME, true);
  39. }
  40. this.hide();
  41. }
  42. public hide() {
  43. super.hide();
  44. }
  45. }
  46. UIInvitation.uiName = "UIInvitation";