79 lines
2.1 KiB
TypeScript
79 lines
2.1 KiB
TypeScript
|
|
/**
|
|
* 无限体力
|
|
*/
|
|
|
|
import GameResMgr, { uiPreName } from "../../Tools/GameResMgr";
|
|
import AdsApiMgr from "../../Tools/Sdk/ads/AdsApiMgr";
|
|
import gameStorage from "../../Tools/gameStorage";
|
|
import TipsManager from "../TipsManager";
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class wuxianEnerySc extends cc.Component {
|
|
|
|
@property(cc.ProgressBar)
|
|
jindubar:cc.ProgressBar = null
|
|
|
|
onLoad () {
|
|
let data = gameStorage.Instance.getMaxEngryVideoShu()
|
|
this.jindubar.progress = data[1]/3
|
|
|
|
}
|
|
|
|
start () {
|
|
|
|
}
|
|
|
|
protected onEnable(): void {
|
|
AdsApiMgr.Instance.chaPingAds_Show()
|
|
}
|
|
|
|
/**
|
|
* 按钮点击
|
|
* @param t
|
|
* @param e
|
|
*/
|
|
btnClickCallBack(t, e){
|
|
if(e == 'add'){
|
|
var self = this
|
|
let data = gameStorage.Instance.getMaxEngryVideoShu()
|
|
AdsApiMgr.Instance.motivational_Other_Video_Show(()=>{
|
|
data[1]++
|
|
if(Number(data[1]) >= 3){
|
|
data[0] = Number(new Date())
|
|
gameStorage.Instance.setMaxEngryVideoShu(data)
|
|
gameStorage.Instance.setEnergy(999)
|
|
cc.director.emit('updateengry')
|
|
self.closepanel(0)
|
|
}else{
|
|
gameStorage.Instance.setMaxEngryVideoShu(data)
|
|
gameStorage.Instance.setEnergy(gameStorage.Instance.getEnergy()+5)
|
|
cc.director.emit('updateengry')
|
|
TipsManager.Instance.createTips('体力+5')
|
|
}
|
|
self.jindubar.progress = data[1]/3
|
|
},()=>{}, [0,data[1]])
|
|
}else if(e == 'no'){
|
|
if(gameStorage.Instance.getEnergy() <= 0){
|
|
let newnode = cc.instantiate(GameResMgr.Instance.uiPre[uiPreName.addEnery])
|
|
newnode.parent = cc.director.getScene()
|
|
}
|
|
this.node.destroy()
|
|
}
|
|
}
|
|
|
|
closepanel(_type){
|
|
if(_type == 0){
|
|
this.scheduleOnce(()=>{
|
|
this.node.destroy()
|
|
}, 0.5)
|
|
}else{
|
|
this.node.destroy()
|
|
}
|
|
}
|
|
|
|
// update (dt) {}
|
|
}
|