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.
114 lines
4.1 KiB
114 lines
4.1 KiB
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
|
|
import EventMgr from "../../FrameWork/Event/EventMgr";
|
|
import User from "../../FrameWork/User/User";
|
|
import Common5 from "../../Platform/th/Common5";
|
|
import BagScript from "../Beibao/BagScript";
|
|
import BagManager from "../Manager/BagManager";
|
|
import UserManager from "../Manager/UserManager";
|
|
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
|
|
import JuQingManager from "./JuQingManager";
|
|
import TaskManager, { MainTaskDataInfo, MainTaskIdEnum, MainTaskWZEnum } from "./TaskManager";
|
|
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class NeedGoodQiPao extends cc.Component {
|
|
|
|
@property(cc.Node)
|
|
iconSpFrame: cc.Node = null
|
|
|
|
@property(cc.Label)
|
|
qiPaoStr: cc.Label = null
|
|
|
|
@property([cc.Integer])
|
|
goodIdTab: number[] = []
|
|
|
|
// onLoad () {}
|
|
|
|
start() {
|
|
this.setCurWuPinQiPaoVisible()
|
|
EventMgr.onEvent_custom(ryw_Event.RefreshJuQingDuiHua, () => {
|
|
this.setCurWuPinQiPaoVisible()
|
|
}, this)
|
|
|
|
}
|
|
|
|
onClickOpenBag() {
|
|
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
|
|
let mainId = mainTaskInfo.Id
|
|
let tiJiaoCallFunc = () => {
|
|
|
|
if (mainId != MainTaskIdEnum.MainTask_None && mainId) {
|
|
let taskConfig = TaskManager.getTaskConfigById(mainId)
|
|
|
|
if (taskConfig.needGoodId && this.goodIdTab.indexOf(taskConfig.needGoodId) > -1) {
|
|
BagManager.subBagList(taskConfig.needGoodId)
|
|
|
|
|
|
// //解锁下一个任务
|
|
// if(mainId == MainTaskIdEnum.MainTask_506){
|
|
// User.setRoomGoodStatus(10)
|
|
// }
|
|
|
|
// EventMgr.emitEvent_custom(ryw_Event.RefreshMyRoom);
|
|
// if(mainId == MainTaskIdEnum.MainTask_529_2){
|
|
// User.setRoomGoodStatus(21)
|
|
// }
|
|
|
|
// TaskManager.finishCurMainTask(mainId)
|
|
// if(mainId == MainTaskIdEnum.MainTask_517){
|
|
|
|
// JuQingManager.unLockNewJuQing('DH_101')
|
|
// User.setRoomGoodStatus(18)
|
|
// EventMgr.emitEvent_custom(ryw_Event.RefreshMyRoom);
|
|
// }
|
|
|
|
// PrefabManage.showTextTips('完成当前任务')
|
|
EventMgr.emitEvent_custom(ryw_Event.NeedGoodFinish);
|
|
this.node.active = false
|
|
} else if (taskConfig.needGoodId == -1) {
|
|
//给钱
|
|
EventMgr.emitEvent_custom(ryw_Event.NeedGoodFinish);
|
|
}
|
|
}
|
|
}
|
|
if (mainId != MainTaskIdEnum.MainTask_None && mainId) {
|
|
let taskConfig = TaskManager.getTaskConfigById(mainId)
|
|
if (taskConfig.needGoodId == -1) {
|
|
//给钱
|
|
tiJiaoCallFunc()
|
|
} else {
|
|
let goodNum = BagManager.getBagGoodNums(taskConfig.needGoodId)
|
|
if (goodNum > 0) {
|
|
tiJiaoCallFunc()
|
|
|
|
} else {
|
|
PrefabManage.showTextTips('当前背包没有该物品')
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
//物品气泡是否显示
|
|
setCurWuPinQiPaoVisible() {
|
|
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
|
|
let mainId = mainTaskInfo.Id
|
|
if (mainId != MainTaskIdEnum.MainTask_None && mainId) {
|
|
let taskConfig = TaskManager.getTaskConfigById(mainId)
|
|
if (taskConfig.needGoodId && this.goodIdTab.indexOf(taskConfig.needGoodId) > -1) {
|
|
//Common5.getSpriteFrameFromBundle("CommonRes","GoodIcon/texture/icon/"+taskConfig.needGoodId,this.iconSpFrame.getComponent(cc.Sprite));
|
|
Common5.addUrlSprite_custom("GoodIcon/texture/icon/" + taskConfig.needGoodId, this.iconSpFrame.getComponent(cc.Sprite))
|
|
|
|
this.node.active = true
|
|
this.qiPaoStr.string = taskConfig.TaskDesc
|
|
return
|
|
}
|
|
}
|
|
this.node.active = false
|
|
}
|
|
// update (dt) {}
|
|
}
|
|
|