82 lines
2.0 KiB
TypeScript
82 lines
2.0 KiB
TypeScript
/**
|
|
* 侧边栏奖励
|
|
*/
|
|
|
|
import PlayData from "../../Tools/PlayData";
|
|
import TipsManager from "../TipsManager";
|
|
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class cebianPanelSc extends cc.Component {
|
|
|
|
@property(cc.Node)
|
|
lingbtn:cc.Node = null
|
|
|
|
@property(cc.Node)
|
|
jinbtn:cc.Node = null
|
|
|
|
@property(cc.Node)
|
|
yiling:cc.Node = null
|
|
|
|
onLoad () {
|
|
|
|
}
|
|
|
|
initUi(){
|
|
// console.log('打印侧边状态', PlayData.Instance.cebianlingquState)
|
|
this.jinbtn.active = PlayData.Instance.cebianlingquState == 0
|
|
this.lingbtn.active = PlayData.Instance.cebianlingquState == 1
|
|
this.yiling.active = PlayData.Instance.cebianlingquState == 2
|
|
}
|
|
|
|
start () {
|
|
|
|
}
|
|
|
|
protected onEnable(): void {
|
|
this.initUi()
|
|
}
|
|
|
|
/**
|
|
* 领取侧边奖励
|
|
*/
|
|
lingquCeBianJiangLi(t, e){
|
|
if(e == 'jin'){
|
|
var self = this
|
|
//@ts-ignore
|
|
tt.navigateToScene({
|
|
scene: "sidebar",
|
|
success: (res) => {
|
|
console.log("navigate to scene success");
|
|
// 跳转成功回调逻辑
|
|
//gameConfig.cebianlingquState = 0
|
|
self.node.destroy()
|
|
},
|
|
fail: (res) => {
|
|
console.log("navigate to scene fail: ", res);
|
|
// 跳转失败回调逻辑
|
|
},
|
|
});
|
|
}else if(e == 'ling'){
|
|
//领取奖励
|
|
// Storage.setCaiSeBall(Storage.getCaiSeBall() + 2)
|
|
// Storage.setChangeBall(Storage.getChangeBall() + 2)
|
|
// Storage.setBoomBall(Storage.getBoomBall() + 2)
|
|
PlayData.Instance.cebianlingquState = 2
|
|
TipsManager.Instance.createTips('领取成功')
|
|
|
|
this.initUi()
|
|
this.scheduleOnce(()=>{
|
|
this.node.destroy()
|
|
},1)
|
|
|
|
}else if(e == 'close'){
|
|
this.node.destroy()
|
|
}
|
|
}
|
|
|
|
// update (dt) {}
|
|
}
|