keepDoubleSpeedView.ts 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. smc.game.GameModel.doubleSpeedAdCount++;
  57. }
  58. private btn_no() {
  59. this.isAuto = false;
  60. oops.gui.remove(UIID.KeepSpeed);
  61. ADHandler.inst.showAd("107");
  62. }
  63. private btn_close() {
  64. this.isAuto = false;
  65. oops.gui.remove(UIID.KeepSpeed);
  66. //播放插屏广告
  67. ADHandler.inst.showAd("107");
  68. DCHandler.inst.reportData(3000305);
  69. }
  70. protected onDisable(): void {
  71. this.isAuto = false;
  72. if (this.autoFunction) {
  73. this.unschedule(this.autoFunction);
  74. }
  75. }
  76. }