|
|
@@ -33,11 +33,11 @@ export default class NewOpenRedBag extends cc.Component {
|
|
|
data = null
|
|
|
|
|
|
private showNativeAd = false;
|
|
|
- onLoad(){
|
|
|
+ onLoad() {
|
|
|
this.showNativeAd = gData.gameData.init_hideRedBag;
|
|
|
}
|
|
|
start() {
|
|
|
-
|
|
|
+
|
|
|
if (gData.moreGame.init_newOpenRedBag) {
|
|
|
gData.moreGame.init_newOpenRedBag = false;
|
|
|
this.showElectUI();
|
|
|
@@ -45,18 +45,17 @@ export default class NewOpenRedBag extends cc.Component {
|
|
|
this.showChangePart();
|
|
|
|
|
|
this.initCashOutStyle(gData.gameData.playerProp.redMoney);
|
|
|
-
|
|
|
- mk.ui.registerRefreshEvent(this, this.initCashOutStyle.bind(this), "refreshCoin");
|
|
|
+
|
|
|
+ mk.event.register("refreshCoin", this.initCashOutStyle.bind(this), this);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
showElectUI() {
|
|
|
this.sendRecommendList();
|
|
|
}
|
|
|
|
|
|
async sendRecommendList() {
|
|
|
- if( this.sp_icon)
|
|
|
- {
|
|
|
+ if (this.sp_icon) {
|
|
|
this.sp_icon.node.active = true;
|
|
|
this.data = gData.moreGame.getRandomNormal();
|
|
|
if (this.data && cc.sys.os != cc.sys.OS_WINDOWS) {
|
|
|
@@ -70,7 +69,7 @@ export default class NewOpenRedBag extends cc.Component {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
this.node_openBtn.active = false;
|
|
|
this.node_getBtn.active = true;
|
|
|
}
|
|
|
@@ -78,24 +77,22 @@ export default class NewOpenRedBag extends cc.Component {
|
|
|
onEnable() {
|
|
|
gData.adData.checkPopInter(InterAdType.interstitial1_click_1);
|
|
|
|
|
|
- if(this.showNativeAd)
|
|
|
- {
|
|
|
+ if (this.showNativeAd) {
|
|
|
mk.ad.showNative();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
mk.ad.showBanner(BannerAdType.banner_click_3);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
onDisable() {
|
|
|
- mk.ui.removeRefreshEvent(this);
|
|
|
- if(this.showNativeAd)
|
|
|
- {
|
|
|
+ mk.event.remove('refreshCoin', this);
|
|
|
+ if (this.showNativeAd) {
|
|
|
mk.ad.destroyNativeAd();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
mk.ad.destoryBanner();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -103,26 +100,24 @@ export default class NewOpenRedBag extends cc.Component {
|
|
|
*/
|
|
|
private initCashOutStyle(redMoney: number = 0) {
|
|
|
|
|
|
- if(gData.gameData.init_hideRedBag)
|
|
|
- {
|
|
|
+ if (gData.gameData.init_hideRedBag) {
|
|
|
this.node_cashOut.active = false;
|
|
|
gData.gameData.init_hideRedBag = false;
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
- if(redMoney == 0)
|
|
|
- {
|
|
|
+ if (redMoney == 0) {
|
|
|
redMoney = gData.gameData.playerProp.redMoney;
|
|
|
}
|
|
|
- redMoney = redMoney/100;
|
|
|
+ redMoney = redMoney / 100;
|
|
|
const cash_bar = gData.redBagCash.cash_bar;
|
|
|
let cash_data = gData.redBagCash.getItemDataByIndex(cash_bar);
|
|
|
if (!cash_data) return;
|
|
|
const newRedMoney = redMoney > cash_data.redMoney ? cash_data.redMoney : redMoney;
|
|
|
this.lbl_reward_value.string = cash_data.money / 100 + '元';
|
|
|
- this.lbl_progress.string = newRedMoney + '/' + cash_data.redMoney/100;
|
|
|
- const fillRange = newRedMoney / cash_data.redMoney >= 1 ? 1 : newRedMoney / (cash_data.redMoney/100);
|
|
|
+ this.lbl_progress.string = newRedMoney + '/' + cash_data.redMoney / 100;
|
|
|
+ const fillRange = newRedMoney / cash_data.redMoney >= 1 ? 1 : newRedMoney / (cash_data.redMoney / 100);
|
|
|
// this.spr_cash_out.fillRange = fillRange;
|
|
|
cc.tween(this.spr_cash_out).to(fillRange, { fillRange: fillRange }).start();
|
|
|
if (redMoney >= cash_data.redMoney) {
|