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 } 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(!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(BattleData.checkDuplicate(this.curChapter)){ this.tipsChapterLabel.string = "已领取" } else{ this.tipsChapterLabel.string = "点击领取章节奖励" } } }