UnlockDoubleSpeed.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { _decorator, Component, Node } from 'cc';
  2. import { GameComponent } from 'db://oops-framework/module/common/GameComponent';
  3. import { GameEvent } from '../../common/config/GameEvent';
  4. import { oops } from 'db://oops-framework/core/Oops';
  5. import { UIID } from '../../common/config/GameUIConfig';
  6. import { ServerHandler } from '../../common/manager/ServerHandler';
  7. import { smc } from '../../common/SingletonModuleComp';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('UnlockDoubleSpeed')
  10. export class UnlockDoubleSpeed extends GameComponent {
  11. start() {
  12. oops.message.dispatchEvent(GameEvent.updateGameState, "paused");
  13. this.startDoubleSpeed();
  14. }
  15. startDoubleSpeed() {
  16. this.scheduleOnce(() => {
  17. smc.game.GameModel.doubleSpeedTime = 180;
  18. this.updateState();
  19. //还要自己更新状态
  20. oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
  21. oops.message.dispatchEvent(GameEvent.DoubleSpeedOpenSuccess);
  22. oops.gui.remove(UIID.UnlockDoubleSpeed);
  23. }, 3)
  24. }
  25. //更新状态
  26. updateState() {
  27. ServerHandler.inst.updatePopupState({
  28. level: smc.account.AccountModel.curLevel,
  29. type: smc.game.GameModel.popupType
  30. })
  31. }
  32. }