GamePassView.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * @Author: mojunshou 1637302775@qq.com
  3. * @Date: 2025-03-21 14:43:24
  4. * @LastEditors: mojunshou 1637302775@qq.com
  5. * @LastEditTime: 2025-04-10 14:37:08
  6. * @Description: 游戏通关弹窗
  7. */
  8. import { Label, Node } from 'cc';
  9. import { _decorator } from 'cc';
  10. import { oops } from 'db://oops-framework/core/Oops';
  11. import { DeviceUtil } from 'db://oops-framework/core/utils/DeviceUtil';
  12. import { GameComponent } from "db://oops-framework/module/common/GameComponent";
  13. import { AD_TYPE } from '../common/config/GameDefine';
  14. import { UIID } from '../common/config/GameUIConfig';
  15. import { CocosHandler } from '../common/manager/CocosHandler';
  16. const { ccclass, property } = _decorator;
  17. /** 显示对象控制 */
  18. @ccclass('GamePassView')
  19. export class GamePassView extends GameComponent {
  20. //提示Node
  21. @property(Label)
  22. private lab_tips: Label = null!;
  23. @property(Node)
  24. private receiveNode: Node = null!; //十倍领取
  25. //引导小手
  26. @property(Node)
  27. private guildNode: Node = null!;
  28. @property([Label])
  29. private lab_list: Label[] = [];
  30. private time: number = 3; //倒数时间
  31. private isAuto: boolean = true; //服务器传是否展示按钮
  32. callback: Function = null!;
  33. protected start() {
  34. this.isAuto = true;
  35. }
  36. private setData() {
  37. this.receiveNode.active = this.isAuto;
  38. if (this.isAuto) {
  39. this.setAutoReceive();
  40. }
  41. }
  42. //开心收下正常领取
  43. private btn_none() {
  44. //是否展示广告
  45. }
  46. //十倍领取
  47. private btn_more() {
  48. this.isAuto = false;
  49. if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
  50. CocosHandler.inst.show_ad(AD_TYPE.Pass_Receive);
  51. } else {
  52. oops.gui.remove(UIID.GamePass);
  53. }
  54. }
  55. //设置自动领取
  56. setAutoReceive() {
  57. let time = this.time;
  58. this.callback = function () {
  59. if (time <= 0 && this.isAuto) {
  60. this.unschedule(this.callback)
  61. //
  62. CocosHandler.inst.show_ad(AD_TYPE.Pass_Receive);
  63. }
  64. this.lab_tips.string = `${time}秒后自动领取`;
  65. time--;
  66. }
  67. this.schedule(this.callback, 1, this.time);
  68. }
  69. }