keepDoubleSpeedView.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * @Author: mojunshou 1637302775@qq.com
  3. * @Date: 2025-04-15 20:16:16
  4. * @LastEditors: mojunshou 1637302775@qq.com
  5. * @LastEditTime: 2025-04-23 16:32:13
  6. * @Description: 继续二倍速
  7. */
  8. import { _decorator, Component, Node } from 'cc';
  9. import { oops } from 'db://oops-framework/core/Oops';
  10. import { GameComponent } from 'db://oops-framework/module/common/GameComponent';
  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 { Label } from 'cc';
  16. import { DCHandler } from '../common/manager/DCHandler';
  17. const { ccclass, property } = _decorator;
  18. @ccclass('keepDoubleSpeedView')
  19. export class keepDoubleSpeedView extends GameComponent {
  20. private isAuto: boolean = false;
  21. @property(Label)
  22. private lab_time: Label = null!;
  23. private time: number = 3;
  24. private autoFunction: Function | null = null;
  25. start() {
  26. this.setButton();
  27. //设置3秒自启动
  28. this.isAuto = true;
  29. this.time = 3;
  30. this.lab_time.string = `${this.time}秒后自启动`;
  31. this.autoFunction = () => {
  32. this.time--
  33. this.lab_time.string = `${this.time}秒后自启动`;
  34. if (this.isAuto && this.time <= 0) {
  35. if (this.autoFunction) {
  36. this.unschedule(this.autoFunction);
  37. this.isAuto = false;
  38. this.openAd();
  39. oops.gui.remove(UIID.KeepSpeed);
  40. DCHandler.inst.reportData(3000304);
  41. }
  42. }
  43. }
  44. this.schedule(this.autoFunction, 1);
  45. }
  46. private btn_open() {
  47. this.isAuto = false;
  48. this.openAd();
  49. oops.gui.remove(UIID.KeepSpeed);
  50. DCHandler.inst.reportData(3000303);
  51. }
  52. //打开广告
  53. private openAd() {
  54. smc.game.GameModel.viewType = "speed_reward";
  55. ADHandler.inst.showAd(AD_TYPE.Double_Speed_Receive);
  56. }
  57. private btn_no() {
  58. this.isAuto = false;
  59. oops.gui.remove(UIID.KeepSpeed);
  60. ADHandler.inst.showAd("107");
  61. }
  62. private btn_close() {
  63. this.isAuto = false;
  64. oops.gui.remove(UIID.KeepSpeed);
  65. //播放插屏广告
  66. ADHandler.inst.showAd("107");
  67. DCHandler.inst.reportData(3000305);
  68. }
  69. protected onDisable(): void {
  70. this.isAuto = false;
  71. if (this.autoFunction) {
  72. this.unschedule(this.autoFunction);
  73. }
  74. }
  75. }