462c2209-5f5f-4ef9-996a-229dc27207b9.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. "use strict";
  2. cc._RF.push(module, '462c2IJX19O+ZlqIp3Ccge5', 'MissionItem');
  3. // Script/view/missionPanel/MissionItem.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. };
  24. Object.defineProperty(exports, "__esModule", { value: true });
  25. var App_1 = require("../../Manager/App");
  26. var hallModel_1 = require("../../model/hallModel");
  27. var SuperListItem_1 = require("../SuperScrollview/SuperListItem");
  28. var TipPanel_1 = require("../tipPanel/TipPanel");
  29. var TipPanelMediator_1 = require("../tipPanel/TipPanelMediator");
  30. var SDK_1 = require("../../sdk/SDK");
  31. var ATRewardedVideoJSSDK_1 = require("../../AnyThinkAds/ATRewardedVideoJSSDK");
  32. var ATAndroidJS2_1 = require("../../ATAndroidJS2");
  33. var GlobalManager_1 = require("../../GlobalManager");
  34. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  35. var MissionItem = /** @class */ (function (_super) {
  36. __extends(MissionItem, _super);
  37. function MissionItem() {
  38. var _this = _super !== null && _super.apply(this, arguments) || this;
  39. _this.textLabel = null;
  40. _this.processLabel = null;
  41. _this.coinnumLabel = null;
  42. _this.diamondLabel = null;
  43. _this.progress = null;
  44. _this.misOver = false;
  45. _this.m_index = 0;
  46. return _this;
  47. }
  48. MissionItem.prototype.onLoad = function () {
  49. console.log('zh:MissionItem.ts onload '); //这个地方会加载4次,暂时没有办法
  50. SDK_1.default.Instance.initAdForPage();
  51. };
  52. MissionItem.prototype.setData = function (tag) {
  53. var _this = this;
  54. this.m_index = tag;
  55. this.refresh();
  56. this.node.on(cc.Node.EventType.TOUCH_END, function () {
  57. console.log('zh:a m_index=' + _this.m_index);
  58. if (!_this.misOver) {
  59. App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "No rewards for incomplete tasks!", false);
  60. return;
  61. }
  62. console.log('zh:aa m_index=' + _this.m_index);
  63. var missionReceiveNum = App_1.App.DataManager.MissionReceive[_this.m_index];
  64. if (missionReceiveNum >= App_1.App.DataManager.MissionDataList[_this.m_index].missonNum.length) {
  65. App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "Already obtained the highest reward!", false); //Already obtained the highest reward 已经获得最高奖励
  66. return;
  67. }
  68. if (cc.sys.os == cc.sys.OS_ANDROID) {
  69. if (ATRewardedVideoJSSDK_1.default.hasAdReady(ATAndroidJS2_1.default.getPlacementId())) {
  70. cc.sys.localStorage.setItem('yxAdMark', 'callBack_forGetJBei'); //看广告用于 xx 标记
  71. GlobalManager_1.default.instance.registerMethod('callBack_forGetJBei', _this.callBack_forGetJBei.bind(_this));
  72. ATRewardedVideoJSSDK_1.default.showAd(ATAndroidJS2_1.default.getPlacementId());
  73. }
  74. else {
  75. console.log('zh:AD 没有OK');
  76. _this.callBack_forGetJBei();
  77. SDK_1.default.Instance.initAdForPage();
  78. }
  79. }
  80. else {
  81. _this.callBack_forGetJBei();
  82. }
  83. // this.callBack_forGetJBei();
  84. }, this);
  85. // let passNum = Object.keys(App.DataManager.PassProgress).length - 1;
  86. // App.Facade.loadTexture('hallScene/texture/skin/' + data.getSkin).then((res: any) => {
  87. // self.texture.spriteFrame = res;
  88. // });
  89. };
  90. /**
  91. * 奖杯
  92. */
  93. MissionItem.prototype.callBack_forGetJBei = function () {
  94. console.log('zh:callBack_forGetJBei 被触发');
  95. var missionReceiveNum = App_1.App.DataManager.MissionReceive[this.m_index];
  96. App_1.App.DataManager.UserCoin += App_1.App.DataManager.MissionDataList[this.m_index].rewardCoin[missionReceiveNum];
  97. App_1.App.DataManager.UserDiamond += App_1.App.DataManager.MissionDataList[this.m_index].rewardDiamon[missionReceiveNum];
  98. App_1.App.Facade.getModel(hallModel_1.default).updateCoinNumber();
  99. App_1.App.Facade.getModel(hallModel_1.default).updateDiamond();
  100. App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "Receive successfully", false); // 领取成功
  101. App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_Coin, App_1.App.DataManager.UserCoin);
  102. App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_UserDiamond, App_1.App.DataManager.UserDiamond);
  103. App_1.App.DataManager.MissionReceive[this.m_index]++;
  104. App_1.App.LocalStorageUtil.setJsonObj(App_1.App.LocalStorageUtil.list_missionReceive, App_1.App.DataManager.MissionReceive);
  105. this.refresh();
  106. };
  107. MissionItem.prototype.refresh = function () {
  108. var missionReceiveNum = App_1.App.DataManager.MissionReceive[this.m_index];
  109. if (missionReceiveNum >= App_1.App.DataManager.MissionDataList[this.m_index].missonNum.length) {
  110. App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "Already obtained the highest reward", false); // 已经领取最高奖励
  111. return;
  112. }
  113. // 具体任务
  114. this.textLabel.string = App_1.App.DataManager.MissionName[this.m_index].replace("%d", App_1.App.DataManager.MissionDataList[this.m_index].missonNum[missionReceiveNum].toString());
  115. // 完成进度数字
  116. this.processLabel.string = App_1.App.DataManager.MissionComplete[this.m_index] + "/" + App_1.App.DataManager.MissionDataList[this.m_index].missonNum[missionReceiveNum];
  117. // 奖励金币
  118. this.coinnumLabel.string = App_1.App.DataManager.MissionDataList[this.m_index].rewardCoin[missionReceiveNum].toString();
  119. // 奖励钻石
  120. this.diamondLabel.string = App_1.App.DataManager.MissionDataList[this.m_index].rewardDiamon[missionReceiveNum].toString();
  121. // 是否完成了这个任务
  122. this.misOver = App_1.App.DataManager.MissionComplete[this.m_index] >= App_1.App.DataManager.MissionDataList[this.m_index].missonNum[missionReceiveNum];
  123. // 完成进度
  124. this.progress.progress = App_1.App.DataManager.MissionComplete[this.m_index] / App_1.App.DataManager.MissionDataList[this.m_index].missonNum[missionReceiveNum];
  125. };
  126. __decorate([
  127. property(cc.Label)
  128. ], MissionItem.prototype, "textLabel", void 0);
  129. __decorate([
  130. property(cc.Label)
  131. ], MissionItem.prototype, "processLabel", void 0);
  132. __decorate([
  133. property(cc.Label)
  134. ], MissionItem.prototype, "coinnumLabel", void 0);
  135. __decorate([
  136. property(cc.Label)
  137. ], MissionItem.prototype, "diamondLabel", void 0);
  138. __decorate([
  139. property(cc.ProgressBar)
  140. ], MissionItem.prototype, "progress", void 0);
  141. MissionItem = __decorate([
  142. ccclass
  143. ], MissionItem);
  144. return MissionItem;
  145. }(SuperListItem_1.default));
  146. exports.default = MissionItem;
  147. cc._RF.pop();