WelfareThree.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * @Author: mojunshou 1637302775@qq.com
  3. * @Date: 2025-04-19 10:27:15
  4. * @LastEditors: mojunshou 1637302775@qq.com
  5. * @LastEditTime: 2025-04-28 16:31:22
  6. * @Description:官方承诺
  7. */
  8. import { _decorator, Component, Node, Animation } from 'cc';
  9. import { oops } from 'db://oops-framework/core/Oops';
  10. import { GameComponent } from 'db://oops-framework/module/common/GameComponent';
  11. import { UIID } from '../../common/config/GameUIConfig';
  12. import { ServerHandler } from '../../common/manager/ServerHandler';
  13. import { smc } from '../../common/SingletonModuleComp';
  14. import { GameEvent } from '../../common/config/GameEvent';
  15. const { ccclass, property } = _decorator;
  16. @ccclass('WelfareThree')
  17. export class WelfareThree extends GameComponent {
  18. @property(Node)
  19. private showNode1: Node = null!;
  20. @property(Node)
  21. private showNode2: Node = null!;
  22. start() {
  23. //3秒后打开官方承诺,关闭当前窗口
  24. oops.message.dispatchEvent(GameEvent.updateGameState, "paused");
  25. this.showNode1.active = true;
  26. this.showNode2.active = false;
  27. this.scheduleOnce(() => {
  28. this.showNode1.active = false;
  29. this.showNode2.active = true;
  30. //播放动画
  31. const animation = this.showNode2.getComponent(Animation);
  32. if (animation) {
  33. animation.play();
  34. }
  35. //3秒后打开官方承诺,关闭当前窗口
  36. this.scheduleOnce(() => {
  37. this.updateState();
  38. oops.gui.remove(UIID.WelfareThree);
  39. }, 5)
  40. }, 3)
  41. }
  42. updateState() {
  43. ServerHandler.inst.updatePopupState({
  44. level: smc.account.AccountModel.curLevel,
  45. type: smc.game.GameModel.popupType
  46. })
  47. }
  48. }