You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
3.1 KiB
109 lines
3.1 KiB
|
|
//*********************
|
|
// create by 流云
|
|
// time: Fri Nov 28 2025
|
|
// desc:
|
|
//*********************
|
|
import { _decorator, Component, Node , find} from 'cc';
|
|
import { Auto_buyPower } from './Auto_buyPower';
|
|
import { ItemNumType, StatisticsType } from '../../game/GameData';
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('UIbuyPower')
|
|
export class UIbuyPower extends Auto_buyPower {
|
|
|
|
//88钻石购买15点
|
|
spendZS= 88
|
|
buyTili = 15
|
|
freeBuyMax = 10
|
|
buyZSMax = 5
|
|
|
|
onLoad(): void {
|
|
super.onLoad();
|
|
}
|
|
|
|
onEnable(): void {
|
|
super.onEnable();
|
|
}
|
|
|
|
onDisable(): void {
|
|
super.onDisable();
|
|
}
|
|
|
|
onInit(): void {
|
|
this.showOpenCenterEff();
|
|
this.showOpenMaskEff(2);
|
|
this.setView()
|
|
}
|
|
|
|
setView(){
|
|
let count1 = gg.data.getStatistics(StatisticsType.buyPowerAdCount)
|
|
let count2 = gg.data.getStatistics(StatisticsType.buyPowerMoneyCount)
|
|
|
|
this.tiliNumLab1.string = 'x'+this.buyTili
|
|
this.tiliNumLab2.string = 'x'+this.buyTili
|
|
|
|
let add = Math.max(this.freeBuyMax-count1, 0)
|
|
this.freeLab.string = gg.lang.get('今日剩余次数:{1}',[add])//'今日剩余次数:'+(add).toString()
|
|
if(add>0){
|
|
this.freeBtnRed.active = true
|
|
}else{
|
|
this.freeBtnRed.active = false
|
|
}
|
|
|
|
this.buyNumLab.string = this.spendZS.toString()
|
|
let add2 = Math.max(this.buyZSMax-count2, 0)
|
|
this.freeLabZS.string = gg.lang.get('今日剩余次数:{1}',[add2])//'今日剩余次数:'+(add2).toString()
|
|
|
|
}
|
|
|
|
|
|
click_bgMask() {
|
|
this.close(2);
|
|
}
|
|
click_btnClose() {
|
|
this.close(2);
|
|
}
|
|
click_freeBtn() {
|
|
let count1 = gg.data.getStatistics(StatisticsType.buyPowerAdCount)
|
|
if(count1>=this.freeBuyMax){
|
|
gg.ui.showToast("今日剩余次数不足!");
|
|
return
|
|
}
|
|
|
|
gg.sdk.showVideoAd((res) => {
|
|
if (res) {
|
|
|
|
gg.sdk.reportDY("inLevel", `体力-AD-购买体力`);
|
|
gg.data.setStatistics(StatisticsType.buyPowerAdCount, count1+1)
|
|
gg.data.addItemNum(ItemNumType.vigour, this.buyTili)
|
|
gg.ui.showToast(gg.lang.get('体力增加{1}', [this.buyTili]),false);
|
|
this.setView()
|
|
} else {
|
|
gg.ui.showToast("观看视频失败");
|
|
}
|
|
})
|
|
}
|
|
click_buyBtn() {
|
|
let count2 = gg.data.getStatistics(StatisticsType.buyPowerMoneyCount)
|
|
if(count2>=this.buyZSMax){
|
|
gg.ui.showToast("今日剩余次数不足!");
|
|
return
|
|
}
|
|
let myZs = gg.data.getItemNum(ItemNumType.diamond)
|
|
if(myZs<this.spendZS){
|
|
gg.ui.showToast("钻石不足");
|
|
return
|
|
}
|
|
|
|
gg.data.setStatistics(StatisticsType.buyPowerMoneyCount, count2+1)
|
|
gg.data.addItemNum(ItemNumType.vigour, this.buyTili)
|
|
gg.data.subItemNum(ItemNumType.diamond, this.spendZS)
|
|
gg.ui.showToast(gg.lang.get('体力增加{1}', [this.buyTili]),false);
|
|
this.setView()
|
|
|
|
gg.sdk.reportDY("inLevel", `体力-钻石购买体力`);
|
|
}
|
|
}
|
|
|