123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- "use strict";
- cc._RF.push(module, '462c2IJX19O+ZlqIp3Ccge5', 'MissionItem');
- // Script/view/missionPanel/MissionItem.ts
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
- 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;
- return c > 3 && r && Object.defineProperty(target, key, r), r;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var App_1 = require("../../Manager/App");
- var hallModel_1 = require("../../model/hallModel");
- var SuperListItem_1 = require("../SuperScrollview/SuperListItem");
- var TipPanel_1 = require("../tipPanel/TipPanel");
- var TipPanelMediator_1 = require("../tipPanel/TipPanelMediator");
- var SDK_1 = require("../../sdk/SDK");
- var ATRewardedVideoJSSDK_1 = require("../../AnyThinkAds/ATRewardedVideoJSSDK");
- var ATAndroidJS2_1 = require("../../ATAndroidJS2");
- var GlobalManager_1 = require("../../GlobalManager");
- var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
- var MissionItem = /** @class */ (function (_super) {
- __extends(MissionItem, _super);
- function MissionItem() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.textLabel = null;
- _this.processLabel = null;
- _this.coinnumLabel = null;
- _this.diamondLabel = null;
- _this.progress = null;
- _this.misOver = false;
- _this.m_index = 0;
- return _this;
- }
- MissionItem.prototype.onLoad = function () {
- console.log('zh:MissionItem.ts onload '); //这个地方会加载4次,暂时没有办法
- SDK_1.default.Instance.initAdForPage();
- };
- MissionItem.prototype.setData = function (tag) {
- var _this = this;
- this.m_index = tag;
- this.refresh();
- this.node.on(cc.Node.EventType.TOUCH_END, function () {
- console.log('zh:a m_index=' + _this.m_index);
- if (!_this.misOver) {
- App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "No rewards for incomplete tasks!", false);
- return;
- }
- console.log('zh:aa m_index=' + _this.m_index);
- var missionReceiveNum = App_1.App.DataManager.MissionReceive[_this.m_index];
- if (missionReceiveNum >= App_1.App.DataManager.MissionDataList[_this.m_index].missonNum.length) {
- App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "Already obtained the highest reward!", false); //Already obtained the highest reward 已经获得最高奖励
- return;
- }
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- if (ATRewardedVideoJSSDK_1.default.hasAdReady(ATAndroidJS2_1.default.getPlacementId())) {
- cc.sys.localStorage.setItem('yxAdMark', 'callBack_forGetJBei'); //看广告用于 xx 标记
- GlobalManager_1.default.instance.registerMethod('callBack_forGetJBei', _this.callBack_forGetJBei.bind(_this));
- ATRewardedVideoJSSDK_1.default.showAd(ATAndroidJS2_1.default.getPlacementId());
- }
- else {
- console.log('zh:AD 没有OK');
- _this.callBack_forGetJBei();
- SDK_1.default.Instance.initAdForPage();
- }
- }
- else {
- _this.callBack_forGetJBei();
- }
- // this.callBack_forGetJBei();
- }, this);
- // let passNum = Object.keys(App.DataManager.PassProgress).length - 1;
- // App.Facade.loadTexture('hallScene/texture/skin/' + data.getSkin).then((res: any) => {
- // self.texture.spriteFrame = res;
- // });
- };
- /**
- * 奖杯
- */
- MissionItem.prototype.callBack_forGetJBei = function () {
- console.log('zh:callBack_forGetJBei 被触发');
- var missionReceiveNum = App_1.App.DataManager.MissionReceive[this.m_index];
- App_1.App.DataManager.UserCoin += App_1.App.DataManager.MissionDataList[this.m_index].rewardCoin[missionReceiveNum];
- App_1.App.DataManager.UserDiamond += App_1.App.DataManager.MissionDataList[this.m_index].rewardDiamon[missionReceiveNum];
- App_1.App.Facade.getModel(hallModel_1.default).updateCoinNumber();
- App_1.App.Facade.getModel(hallModel_1.default).updateDiamond();
- App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "Receive successfully", false); // 领取成功
- App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_Coin, App_1.App.DataManager.UserCoin);
- App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_UserDiamond, App_1.App.DataManager.UserDiamond);
- App_1.App.DataManager.MissionReceive[this.m_index]++;
- App_1.App.LocalStorageUtil.setJsonObj(App_1.App.LocalStorageUtil.list_missionReceive, App_1.App.DataManager.MissionReceive);
- this.refresh();
- };
- MissionItem.prototype.refresh = function () {
- var missionReceiveNum = App_1.App.DataManager.MissionReceive[this.m_index];
- if (missionReceiveNum >= App_1.App.DataManager.MissionDataList[this.m_index].missonNum.length) {
- App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "Already obtained the highest reward", false); // 已经领取最高奖励
- return;
- }
- // 具体任务
- this.textLabel.string = App_1.App.DataManager.MissionName[this.m_index].replace("%d", App_1.App.DataManager.MissionDataList[this.m_index].missonNum[missionReceiveNum].toString());
- // 完成进度数字
- this.processLabel.string = App_1.App.DataManager.MissionComplete[this.m_index] + "/" + App_1.App.DataManager.MissionDataList[this.m_index].missonNum[missionReceiveNum];
- // 奖励金币
- this.coinnumLabel.string = App_1.App.DataManager.MissionDataList[this.m_index].rewardCoin[missionReceiveNum].toString();
- // 奖励钻石
- this.diamondLabel.string = App_1.App.DataManager.MissionDataList[this.m_index].rewardDiamon[missionReceiveNum].toString();
- // 是否完成了这个任务
- this.misOver = App_1.App.DataManager.MissionComplete[this.m_index] >= App_1.App.DataManager.MissionDataList[this.m_index].missonNum[missionReceiveNum];
- // 完成进度
- this.progress.progress = App_1.App.DataManager.MissionComplete[this.m_index] / App_1.App.DataManager.MissionDataList[this.m_index].missonNum[missionReceiveNum];
- };
- __decorate([
- property(cc.Label)
- ], MissionItem.prototype, "textLabel", void 0);
- __decorate([
- property(cc.Label)
- ], MissionItem.prototype, "processLabel", void 0);
- __decorate([
- property(cc.Label)
- ], MissionItem.prototype, "coinnumLabel", void 0);
- __decorate([
- property(cc.Label)
- ], MissionItem.prototype, "diamondLabel", void 0);
- __decorate([
- property(cc.ProgressBar)
- ], MissionItem.prototype, "progress", void 0);
- MissionItem = __decorate([
- ccclass
- ], MissionItem);
- return MissionItem;
- }(SuperListItem_1.default));
- exports.default = MissionItem;
- cc._RF.pop();
|