GamePassView.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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-11 11:27:19
  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. import { smc } from '../common/SingletonModuleComp';
  17. import { ADHandler } from '../common/manager/ADHandler';
  18. const { ccclass, property } = _decorator;
  19. /** 显示对象控制 */
  20. @ccclass('GamePassView')
  21. export class GamePassView extends GameComponent {
  22. //提示Node
  23. @property(Label)
  24. private lab_tips: Label = null!;
  25. @property(Node)
  26. private receiveNode: Node = null!; //十倍领取
  27. @property([Label])
  28. private lab_list: Label[] = [];
  29. private time: number = 3; //倒数时间
  30. private isAuto: boolean = true; //服务器传是否展示按钮
  31. callback: Function = null!;
  32. protected start() {
  33. this.setButton();
  34. this.isAuto = true;
  35. this.setData();
  36. }
  37. private setData() {
  38. this.isAuto = smc.game.GameModel.passViewInfo.doubleReward;
  39. this.receiveNode.active = this.isAuto;
  40. if (this.isAuto) {
  41. this.setAutoReceive();
  42. }
  43. const list = smc.game.GameModel.passViewInfo.showReward;
  44. list.forEach((item, index) => {
  45. console.log("tiem.propId", item.propId)
  46. if (this.lab_list[index]) {
  47. this.lab_list[index].string = item.propNum + "";
  48. }
  49. })
  50. }
  51. //开心收下正常领取
  52. private btn_none() {
  53. //是否展示广告
  54. oops.gui.remove(UIID.GamePass);
  55. ADHandler.inst.showAd(AD_TYPE.Pass_Receive);
  56. }
  57. //十倍领取
  58. private btn_more() {
  59. this.isAuto = false;
  60. if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
  61. ADHandler.inst.showAd(AD_TYPE.Pass_Receive);
  62. } else {
  63. oops.gui.remove(UIID.GamePass);
  64. }
  65. }
  66. //设置自动领取
  67. setAutoReceive() {
  68. let time = this.time;
  69. this.callback = function () {
  70. if (time <= 0 && this.isAuto) {
  71. this.unschedule(this.callback)
  72. //
  73. ADHandler.inst.showAd(AD_TYPE.Pass_Receive);
  74. }
  75. this.lab_tips.string = `${time}秒后自动领取`;
  76. time--;
  77. }
  78. this.schedule(this.callback, 1, this.time);
  79. }
  80. }