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.
189 lines
5.9 KiB
189 lines
5.9 KiB
import { _decorator, Component, find, instantiate, Label, Node, Sprite, tween } from 'cc';
|
|
import { ITaskData } from '../../game/ConfigTableData';
|
|
|
|
import { GEvent } from 'db://assets/mx/module/event/GEvent';
|
|
import MTools from 'db://assets/mx/tools/MTools';
|
|
import { UIID } from '../../game/ConfigRes';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('taskItemNode')
|
|
export class taskItemNode extends Component {
|
|
taskData:ITaskData = null
|
|
taskId = 0
|
|
rewardGet = 0
|
|
rewardPro = 0
|
|
endPosiNode:Node = null
|
|
endPosiNode2:Node = null
|
|
ui_center: Node = null;
|
|
start() {
|
|
|
|
}
|
|
|
|
setTaskData(taskId:number, rewardGet:number,rewardPro:number, taskData:ITaskData, endPosiNode:Node,endPosiNode2:Node, ui_center:Node){
|
|
|
|
this.taskData = taskData
|
|
this.taskId = taskId
|
|
this.rewardGet = rewardGet
|
|
this.rewardPro = rewardPro
|
|
this.endPosiNode = endPosiNode
|
|
this.endPosiNode2 = endPosiNode2
|
|
this.ui_center = ui_center
|
|
|
|
this.setTaskInfo()
|
|
|
|
}
|
|
|
|
//0,1,2
|
|
//0,未完成
|
|
//1,已完成
|
|
//2,已领取
|
|
//设置任务信息
|
|
setTaskInfo(){
|
|
if(this.taskData == null){
|
|
return
|
|
}
|
|
let descLable = this.node.getChildByName('descLable').getComponent(Label)
|
|
descLable.string = gg.lang.get(this.taskData.desc)//this.taskData.desc
|
|
//显示UI
|
|
let huoyueLab = find('活跃值/huoyueLab',this.node).getComponent(Label)
|
|
huoyueLab.string ='+'+ this.taskData.reward
|
|
if(this.rewardGet == 0){
|
|
//goToFinishTaskBtn
|
|
let goToFinishTaskBtn = find('goToFinishTaskBtn',this.node)
|
|
goToFinishTaskBtn.active = true
|
|
//getRewardBtn
|
|
let getRewardBtn = find('getRewardBtn',this.node)
|
|
getRewardBtn.active = false
|
|
//已领取
|
|
let receivedLab = find('已领取',this.node)
|
|
receivedLab.active = false
|
|
}else if(this.rewardGet == 1){
|
|
//goToFinishTaskBtn
|
|
let goToFinishTaskBtn = find('goToFinishTaskBtn',this.node)
|
|
goToFinishTaskBtn.active = false
|
|
//getRewardBtn
|
|
let getRewardBtn = find('getRewardBtn',this.node)
|
|
getRewardBtn.active = true
|
|
//已领取
|
|
let receivedLab = find('已领取',this.node)
|
|
receivedLab.active = false
|
|
}else if(this.rewardGet == 2){
|
|
//goToFinishTaskBtn
|
|
let goToFinishTaskBtn = find('goToFinishTaskBtn',this.node)
|
|
goToFinishTaskBtn.active = false
|
|
//getRewardBtn
|
|
let getRewardBtn = find('getRewardBtn',this.node)
|
|
getRewardBtn.active = false
|
|
//已领取
|
|
let receivedLab = find('已领取',this.node)
|
|
receivedLab.active = true
|
|
}
|
|
|
|
let proLab = find('proLab',this.node).getComponent(Label)
|
|
if(this.rewardPro >= this.taskData.freq){
|
|
this.rewardPro = this.taskData.freq
|
|
}
|
|
proLab.string = this.rewardPro+'/'+this.taskData.freq
|
|
let proBar = this.node.getChildByName('Bar').getComponent(Sprite)
|
|
proBar.fillRange = this.rewardPro/this.taskData.freq
|
|
|
|
}
|
|
|
|
|
|
refreshTaskInfo(){
|
|
if(this.taskData == null){
|
|
return
|
|
}
|
|
//刷新UI
|
|
|
|
}
|
|
|
|
|
|
//领取点击
|
|
click_getRewardBtn(event){
|
|
//加分
|
|
gg.data.addDayTaskScore(this.taskData.reward)
|
|
gg.data.addWeekTaskScore(this.taskData.reward)
|
|
//状态设置
|
|
gg.data.setDayTaskProgressData(this.taskId,2)
|
|
//刷新界面
|
|
let goToFinishTaskBtn = find('goToFinishTaskBtn',this.node)
|
|
goToFinishTaskBtn.active = false
|
|
//getRewardBtn
|
|
let getRewardBtn = find('getRewardBtn',this.node)
|
|
getRewardBtn.active = false
|
|
//已领取
|
|
let receivedLab = find('已领取',this.node)
|
|
receivedLab.active = true
|
|
//通知刷新界面
|
|
let huoyue = this.node.getChildByName('活跃值')
|
|
let copy1 = instantiate(huoyue)
|
|
copy1.parent = this.ui_center
|
|
MTools.setNodeToTargetPos(copy1,event.target)
|
|
tween(copy1)
|
|
.to(0.5,{worldPosition:this.endPosiNode.worldPosition})
|
|
.call(()=>{
|
|
copy1.destroy()
|
|
})
|
|
.start()
|
|
|
|
|
|
let copy2 = instantiate(huoyue)
|
|
copy2.parent = this.ui_center
|
|
MTools.setNodeToTargetPos(copy2,event.target)
|
|
tween(copy2)
|
|
.to(0.5,{worldPosition:this.endPosiNode2.worldPosition})
|
|
.call(()=>{
|
|
copy2.destroy()
|
|
})
|
|
.start()
|
|
|
|
|
|
GEvent.Ins.emit(GEvent.RefreshTaskView)
|
|
}
|
|
|
|
//前往点击
|
|
click_goToFinishTaskBtn(){
|
|
//跳转
|
|
//location
|
|
let location = this.taskData.location+''
|
|
let array = location.split(',')
|
|
|
|
if(array.length == 2){
|
|
let scene = array[0]
|
|
let posi = array[1]
|
|
if(scene == '1'){
|
|
//打开商店
|
|
//需要跳转位置
|
|
//1、钻石/碎片,2、宝箱开启,3、金币)
|
|
//console.log('this.changePosi 1111==',posi)
|
|
GEvent.Ins.emit(GEvent.TiaoZhuanShop,0,posi);
|
|
}
|
|
}else{
|
|
let scene = array[0]
|
|
//
|
|
if(scene == '1'){
|
|
//打开商店
|
|
GEvent.Ins.emit(GEvent.TiaoZhuanShop,0);
|
|
}else if(scene == '2'){
|
|
//打开角色
|
|
if(gg.data.doc.chapter < 3){
|
|
gg.ui.showToast('等待章节剧情解锁')
|
|
|
|
return
|
|
}
|
|
GEvent.Ins.emit(GEvent.TiaoZhuanShop,1);
|
|
}else if(scene == '3'){
|
|
GEvent.Ins.emit(GEvent.TiaoZhuanShop,2);
|
|
//战斗界面
|
|
}else if(scene == '4'){
|
|
GEvent.Ins.emit(GEvent.TiaoZhuanShop,3);
|
|
//打开武器
|
|
}
|
|
}
|
|
|
|
gg.ui.closePanel(UIID.taskView)
|
|
}
|
|
}
|
|
|
|
|
|
|