|
|
@@ -160,12 +160,14 @@ export class ShopController extends Component {
|
|
|
console.log('[ShopController] 迁移旧的costFreeUsed数据到新字段');
|
|
|
}
|
|
|
|
|
|
- // 确保新字段存在
|
|
|
+ // 确保新字段存在,设置默认值
|
|
|
if (data.billCostFreeUsed === undefined) {
|
|
|
- data.billCostFreeUsed = false;
|
|
|
+ data.billCostFreeUsed = true; // 默认为true(可用)
|
|
|
+ console.log('[ShopController] 设置billCostFreeUsed默认值: true');
|
|
|
}
|
|
|
if (data.diamondCostFreeUsed === undefined) {
|
|
|
- data.diamondCostFreeUsed = false;
|
|
|
+ data.diamondCostFreeUsed = true; // 默认为true(可用)
|
|
|
+ console.log('[ShopController] 设置diamondCostFreeUsed默认值: true');
|
|
|
}
|
|
|
|
|
|
// 检查是否需要重置(新的一天)
|
|
|
@@ -192,8 +194,8 @@ export class ShopController extends Component {
|
|
|
diamondsFreeCount: 0,
|
|
|
diamondsAdCount: 0,
|
|
|
costAdCount: 0,
|
|
|
- billCostFreeUsed: false,
|
|
|
- diamondCostFreeUsed: false
|
|
|
+ billCostFreeUsed: true,
|
|
|
+ diamondCostFreeUsed: true
|
|
|
};
|
|
|
this.saveDailyRewardData();
|
|
|
}
|
|
|
@@ -397,22 +399,18 @@ export class ShopController extends Component {
|
|
|
console.log('[ShopController] 显示钞票奖励广告');
|
|
|
|
|
|
// 这里应该调用广告SDK显示广告
|
|
|
- // 模拟广告观看成功
|
|
|
- this.scheduleOnce(() => {
|
|
|
- console.log('[ShopController] 广告观看完成,发放钞票奖励');
|
|
|
- this.claimMoneyReward(true);
|
|
|
- }, 1.0); // 模拟1秒广告时间
|
|
|
+ // 立即发放奖励,无延迟
|
|
|
+ console.log('[ShopController] 广告观看完成,发放钞票奖励');
|
|
|
+ this.claimMoneyReward(true);
|
|
|
}
|
|
|
|
|
|
private showAdForDiamondReward() {
|
|
|
console.log('[ShopController] 显示钻石奖励广告');
|
|
|
|
|
|
// 这里应该调用广告SDK显示广告
|
|
|
- // 模拟广告观看成功
|
|
|
- this.scheduleOnce(() => {
|
|
|
- console.log('[ShopController] 广告观看完成,发放钻石奖励');
|
|
|
- this.claimDiamondReward(true);
|
|
|
- }, 1.0); // 模拟1秒广告时间
|
|
|
+ // 立即发放奖励,无延迟
|
|
|
+ console.log('[ShopController] 广告观看完成,发放钻石奖励');
|
|
|
+ this.claimDiamondReward(true);
|
|
|
}
|
|
|
|
|
|
private showRewardEffect(type: 'money' | 'diamonds', amount: number) {
|
|
|
@@ -433,7 +431,7 @@ export class ShopController extends Component {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const costFreeUsed = this.dailyRewardData.billCostFreeUsed || false;
|
|
|
+ const costFreeUsed = this.dailyRewardData.billCostFreeUsed !== undefined ? this.dailyRewardData.billCostFreeUsed : true;
|
|
|
console.log('[ShopController] 更新钞票Cost按钮UI状态,billCostFreeUsed:', costFreeUsed);
|
|
|
|
|
|
if (this.billCostButton) {
|
|
|
@@ -442,33 +440,34 @@ export class ShopController extends Component {
|
|
|
|
|
|
console.log('[ShopController] 按钮组件检查 - Label:', !!buttonLabel, 'Sprite:', !!buttonSprite);
|
|
|
|
|
|
- if (!costFreeUsed) {
|
|
|
- // 每天第一次,显示"免费"
|
|
|
- this.billCostButton.interactable = true;
|
|
|
- if (buttonLabel) {
|
|
|
- buttonLabel.string = "免费";
|
|
|
- }
|
|
|
- // 恢复原始图片
|
|
|
- if (buttonSprite && this.originalBillButtonSprite) {
|
|
|
- buttonSprite.spriteFrame = this.originalBillButtonSprite;
|
|
|
- console.log('[ShopController] 恢复按钮原始图片');
|
|
|
- }
|
|
|
+ if (costFreeUsed) {
|
|
|
+ // 每天第一次,显示"免费"
|
|
|
+ this.billCostButton.interactable = true;
|
|
|
+ if (buttonLabel) {
|
|
|
+ buttonLabel.string = "免费";
|
|
|
+ }
|
|
|
+ // 恢复原始图片
|
|
|
+ if (buttonSprite && this.originalBillButtonSprite) {
|
|
|
+ buttonSprite.spriteFrame = this.originalBillButtonSprite;
|
|
|
+ console.log('[ShopController] 恢复按钮原始图片');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 免费已使用,按钮置灰,并更新对应的数值显示
|
|
|
+ this.billCostButton.interactable = false;
|
|
|
+ if (buttonLabel) {
|
|
|
+ buttonLabel.string = "已使用";
|
|
|
+ }
|
|
|
+ // 设置置灰图片
|
|
|
+ console.log('[ShopController] 尝试设置置灰图片 - buttonSprite:', !!buttonSprite, 'disabledButtonSprite:', !!this.disabledButtonSprite);
|
|
|
+ if (buttonSprite && this.disabledButtonSprite) {
|
|
|
+ buttonSprite.spriteFrame = this.disabledButtonSprite;
|
|
|
+ console.log('[ShopController] 设置按钮为置灰图片成功');
|
|
|
} else {
|
|
|
- // 免费已使用,按钮置灰,并更新对应的数值显示
|
|
|
- this.billCostButton.interactable = false;
|
|
|
- if (buttonLabel) {
|
|
|
- buttonLabel.string = "已使用";
|
|
|
- }
|
|
|
- // 设置置灰图片
|
|
|
- if (buttonSprite && this.disabledButtonSprite) {
|
|
|
- buttonSprite.spriteFrame = this.disabledButtonSprite;
|
|
|
- console.log('[ShopController] 设置按钮为置灰图片');
|
|
|
- } else {
|
|
|
- console.log('[ShopController] 警告:无法获取按钮Sprite组件或置灰图片资源');
|
|
|
- }
|
|
|
- // 更新钞票数值显示
|
|
|
- this.updateMoneyAmountFromConfig();
|
|
|
+ console.log('[ShopController] 警告:无法设置置灰图片 - buttonSprite:', !!buttonSprite, 'disabledButtonSprite:', !!this.disabledButtonSprite);
|
|
|
}
|
|
|
+ // 更新钞票数值显示
|
|
|
+ this.updateMoneyAmountFromConfig();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -479,7 +478,7 @@ export class ShopController extends Component {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const costFreeUsed = this.dailyRewardData.diamondCostFreeUsed || false;
|
|
|
+ const costFreeUsed = this.dailyRewardData.diamondCostFreeUsed !== undefined ? this.dailyRewardData.diamondCostFreeUsed : true;
|
|
|
console.log('[ShopController] 更新钻石Cost按钮UI状态,diamondCostFreeUsed:', costFreeUsed);
|
|
|
|
|
|
if (this.diamondCostButton) {
|
|
|
@@ -545,7 +544,7 @@ export class ShopController extends Component {
|
|
|
|
|
|
if (costFreeUsed) {
|
|
|
// 第一次免费点击
|
|
|
- this.dailyRewardData.billCostFreeUsed = true;
|
|
|
+ this.dailyRewardData.billCostFreeUsed = false;
|
|
|
// 增加钞票计数
|
|
|
this.dailyRewardData.moneyFreeCount++;
|
|
|
this.saveDailyRewardData();
|
|
|
@@ -566,7 +565,7 @@ export class ShopController extends Component {
|
|
|
|
|
|
if (costFreeUsed) {
|
|
|
// 第一次免费点击
|
|
|
- this.dailyRewardData.diamondCostFreeUsed = true;
|
|
|
+ this.dailyRewardData.diamondCostFreeUsed = false;
|
|
|
// 增加钻石计数
|
|
|
this.dailyRewardData.diamondsFreeCount++;
|
|
|
this.saveDailyRewardData();
|