DoubleSpeedViewComp.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * @Author: mojunshou 1637302775@qq.com
  3. * @Date: 2025-03-21 11:17:22
  4. * @LastEditors: mojunshou 1637302775@qq.com
  5. * @LastEditTime: 2025-04-23 10:49:01
  6. * @Description: 二倍速弹窗
  7. */
  8. import { _decorator } from "cc";
  9. import { oops } from "db://oops-framework/core/Oops";
  10. import VMParent from "db://oops-framework/libs/model-view/VMParent";
  11. import { AD_TYPE } from "../common/config/GameDefine";
  12. import { UIID } from "../common/config/GameUIConfig";
  13. import { ADHandler } from "../common/manager/ADHandler";
  14. import { smc } from "../common/SingletonModuleComp";
  15. import { GameEvent } from "../common/config/GameEvent";
  16. const { ccclass, property } = _decorator;
  17. /** 视图层对象 */
  18. @ccclass('DoubleSpeedViewComp')
  19. export class DoubleSpeedViewComp extends VMParent {
  20. /** 视图层逻辑代码分离演示 */
  21. data: any = {
  22. time: 0,
  23. }
  24. start() {
  25. // const entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
  26. this.setButton();
  27. this.data.time = smc.game.GameModel.doubleSpeedTime / 60;
  28. }
  29. private btn_open() {
  30. this.openAd();
  31. oops.gui.remove(UIID.DoubleSpeed);
  32. }
  33. //打开广告
  34. private openAd() {
  35. smc.game.GameModel.viewType = "speed_reward";
  36. ADHandler.inst.showAd(AD_TYPE.Double_Speed_Receive);
  37. oops.message.dispatchEvent(GameEvent.updateGameState, "paused");
  38. }
  39. private btn_no() {
  40. oops.gui.remove(UIID.DoubleSpeed);
  41. ADHandler.inst.showAd("107");
  42. oops.message.dispatchEvent(GameEvent.updateGameState, "paused");
  43. }
  44. private btn_close() {
  45. oops.gui.remove(UIID.DoubleSpeed);
  46. //播放插屏广告
  47. ADHandler.inst.showAd("107");
  48. oops.message.dispatchEvent(GameEvent.updateGameState, "paused");
  49. }
  50. }