12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import { _decorator, Component, Label, Node, sp } from 'cc';
- import { BattleManager } from '../../../manager/BattleManager';
- import { BattleData } from '../../../data/BattleData';
- import { Framework } from '../../../../framework/Framework';
- import { GameEvent } from '../../../data/GameEvent';
- const { ccclass, property } = _decorator;
- @ccclass('RewardChapter')
- export class RewardChapter extends Component {
- @property({type:Label,tooltip:'当前章节'})
- curChapterLabel:Label = null;
- @property({type:Label,tooltip:'当前章节是否可领取'})
- tipsChapterLabel:Label = null;
-
- curChapter:number = 0;
- protected onLoad(): void {
- Framework.event.addEvent(GameEvent.BattleDuplicateReward, ()=>{
- this.updateChapter()
- },this);
- }
- show() {
- this.curChapter = BattleData.duplicate.chapter
- this.node.active = true
- this.updateChapter()
- }
-
- private onTouchButton(event: Event) {
- //Framework.audio.playEffect(AudioID.Click);
- let target: any = event.target;
- switch (target.name) {
- case "get_btn":
- // this.node.active = false
- if(this.curChapter > BattleManager.getRewardChapter()){
- return
- }
- if(!BattleData.checkDuplicate(this.curChapter)){
- BattleManager.sendBattleDuplicateRewardMsg(this.curChapter)
- }
- break;
- case "left_btn":
- this.curChapter = this.curChapter > 1 ? this.curChapter - 1 : 1
- this.updateChapter()
- break;
- case "right_btn":
- this.curChapter = this.curChapter < BattleData.duplicate.chapter ? this.curChapter + 1 : BattleData.duplicate.chapter
- this.updateChapter()
- break;
- case "close_btn":
- this.node.active = false
- break;
- default:
- console.log("功能尚未开放")
- break;
- }
- }
- updateChapter()
- {
- this.curChapterLabel.string = `第 ${this.curChapter} 章`
-
- if(this.curChapter > BattleManager.getRewardChapter()){
- this.tipsChapterLabel.string = ""
- return
- }
- if(BattleData.checkDuplicate(this.curChapter)){
- this.tipsChapterLabel.string = "已领取"
- }
- else{
- this.tipsChapterLabel.string = "点击领取章节奖励"
- }
- }
- }
|