diff --git a/assets/Scene/HomeScene.fire b/assets/Scene/HomeScene.fire index 0fa8ea7..5973169 100644 --- a/assets/Scene/HomeScene.fire +++ b/assets/Scene/HomeScene.fire @@ -16731,12 +16731,10 @@ "setUi": { "__id__": 96 }, - "monthCardReward": { - "__id__": 322 - }, - "cardTime": { - "__id__": 341 - }, + "monthCardBtn": null, + "monthCardBtn2": null, + "monthCardTime": null, + "monthCard": null, "_id": "0dna+7W/NMp6RyIrSQLx5u" }, { diff --git a/assets/Script/JiaZai.ts b/assets/Script/JiaZai.ts index 0fc0701..4ebe705 100644 --- a/assets/Script/JiaZai.ts +++ b/assets/Script/JiaZai.ts @@ -64,20 +64,14 @@ export default class JiaZai extends cc.Component { setUi: cc.Node = null; scheduleCallback2: any; //月卡 - // @property(cc.Node) - // monthCardBtn: cc.Node = null; - // @property(cc.Node) - // monthCardBtn2: cc.Node = null; - // @property(cc.Node) - // monthCardTime: cc.Node = null; - // @property(cc.Node) - // monthCard: cc.Node = null; - @property(cc.Node) - monthCardReward: cc.Node = null; - //剩余天数 + monthCardBtn: cc.Node = null; @property(cc.Node) - cardTime: cc.Node = null; + monthCardBtn2: cc.Node = null; + @property(cc.Node) + monthCardTime: cc.Node = null; + @property(cc.Node) + monthCard: cc.Node = null; // LIFE-CYCLE CALLBACKS: onLoad() { @@ -137,7 +131,17 @@ export default class JiaZai extends cc.Component { this.setFirstInfo(); cc.fx.GameConfig.GM_INFO.first = false; } - cc.fx.GameConfig.LEVEL_INFO_init(true, 1000); + let power = cc.fx.GameTool.getUserPowerTime(); + if (cc.fx.GameConfig.GM_INFO.hp < 1 && power == false) { + MiniGameSdk.API.showToast("体力值不足,无法进入好友关卡"); + setTimeout(() => { + this.openHeath(); + }, 1000); + return; + } + else { + cc.fx.GameConfig.LEVEL_INFO_init(true, 1000); + } } else { if (cc.fx.GameConfig.GM_INFO.first) { @@ -193,9 +197,8 @@ export default class JiaZai extends cc.Component { // //打开heath弹窗 // this.openHeath(); this.uploadToCloud(cc.fx.GameConfig.GM_INFO.level + 1); - - this.getMonthlyCardValidityDays(); - this.rewarded(); + // this.rewarded(); + // this.getMonthlyCardValidityDays(); Utils.getMonthlyCard((data) => { if (data.code == 1) { cc.fx.GameConfig.GM_INFO.hp_Max = 7; @@ -760,53 +763,63 @@ export default class JiaZai extends cc.Component { openMonthCard() { this.openMonthlyCard(); this.monthlyCardNode.getComponent("monthlyCard").home = 1; - + // this.monthCard.active = true; + // Utils.getMonthlyCard((data) => { + // if (data.msg == "不在有效期") { + // this.monthCardBtn.active = true; + // this.monthCardBtn2.active = false; + // } else { + // this.monthCardBtn.active = false; + // this.monthCardBtn2.active = true; + // NumberToImage.numberToImageNodes(25, 35, 20, "month_", this.monthCardTime, true); + // } + // }) } //关闭界面 - // closeMonthCard() { - // Utils.getMonthlyCard((data) => { - // if (data.msg == "不在有效期") { - // this.monthCardBtn.active = true; - // this.monthCardBtn2.active = false; - // } else { - // this.monthCardBtn.active = false; - // this.monthCardBtn2.active = true; - // NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true); - // } - // }) - // this.monthCard.active = false; - // this.rewarded(); + closeMonthCard() { + Utils.getMonthlyCard((data) => { + if (data.msg == "不在有效期") { + this.monthCardBtn.active = true; + this.monthCardBtn2.active = false; + } else { + this.monthCardBtn.active = false; + this.monthCardBtn2.active = true; + NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true); + } + }) + this.monthCard.active = false; + this.rewarded(); - // } - // //购买月卡 - // buyMonthCard() { - // Utils.setMonthlyCard(0, (data) => { - // console.log("购买月卡'✅ ", data.code); - // if (data.code == 1) { - // let rewardData = [ - // { type: "coin", count: 6000 }, - // ] - // cc.fx.GameConfig.GM_INFO.hp_Max = 7; - // cc.fx.GameConfig.GM_INFO.hp = 7; - // cc.fx.GameTool.changeCoin(6000); - // setTimeout(() => { - // this.updateCoin(); - // this.setHealthInfo(false); - // this.startTimeCutDown(); - // this.openRewardWindow(rewardData, 1); - // }, 300); - // cc.fx.GameTool.setUserHealth(0, (data) => { - // cc.fx.GameTool.getHealth(null); - // }) - // this.monthCardBtn.active = false; - // this.monthCardBtn2.active = true; - // NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true); + } + //购买月卡 + buyMonthCard() { + Utils.setMonthlyCard(0, (data) => { + console.log("购买月卡'✅ ", data.code); + if (data.code == 1) { + let rewardData = [ + { type: "coin", count: 6000 }, + ] + cc.fx.GameConfig.GM_INFO.hp_Max = 7; + cc.fx.GameConfig.GM_INFO.hp = 7; + cc.fx.GameTool.changeCoin(6000); + setTimeout(() => { + this.updateCoin(); + this.setHealthInfo(false); + this.startTimeCutDown(); + this.openRewardWindow(rewardData, 1); + }, 300); + cc.fx.GameTool.setUserHealth(0, (data) => { + cc.fx.GameTool.getHealth(null); + }) + this.monthCardBtn.active = false; + this.monthCardBtn2.active = true; + NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true); - // } - // }) - // } + } + }) + } - rewarded() { + rewarded() { Utils.monthGetReward((data) => { if (data.data == null) { console.log("到期"); @@ -824,17 +837,33 @@ export default class JiaZai extends cc.Component { this.startTimeCutDown(); }, 300); + } if (data.data != null && data.code == 0) { console.log("未到期已领取"); } if (data.code == 1) { - this.monthCardReward.active = true; - NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 40, 20, "month_", this.cardTime, true); + cc.fx.GameTool.changeCoin(500); + this.updateCoin(); + + let rewardData = [ + { type: "coin", count: 500 }, + ] + setTimeout(() => { + this.openRewardWindow(rewardData); + }, 500); + const dataTemp = { + change_reason: "month", + id: "1001", + num: 500, + compensate: false + } + cc.fx.GameTool.shushu_Track("resource_get", dataTemp); + + } }) } - //缓存弹窗 monthH() { // return; @@ -884,8 +913,7 @@ export default class JiaZai extends cc.Component { const remainingDays = Math.max(0, days); cc.fx.GameConfig.GM_INFO.monthTime = remainingDays; - console.log('%c月卡剩余天数 (零点刷新): ' + remainingDays, - 'color: green; font-weight: bold;'); + console.log('月卡剩余天数 (零点刷新):', remainingDays); } else { } }); @@ -939,19 +967,5 @@ export default class JiaZai extends cc.Component { } } - onCardReward() { - cc.fx.GameTool.changeCoin(500); - this.updateCoin(); - const dataTemp = { - change_reason: "month", - id: "1001", - num: 500, - compensate: false - } - cc.fx.GameTool.shushu_Track("resource_get", dataTemp); - this.monthCardReward.active = false; - } - - // update (dt) {} } diff --git a/assets/shop/prefab/onMCReward.prefab b/assets/shop/prefab/onMCReward.prefab index 48ad471..6e68870 100644 --- a/assets/shop/prefab/onMCReward.prefab +++ b/assets/shop/prefab/onMCReward.prefab @@ -391,8 +391,8 @@ 0, 0, 1, - 2, - 2, + 1, + 1, 1 ] },