觉醒时刻
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.
juexingshike/assets/Scripts/SCommon/CurGameJinHuoDesc.ts

123 lines
3.7 KiB

1 week ago
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
import EventMgr from "../../FrameWork/Event/EventMgr";
import User from "../../FrameWork/User/User";
import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager";
import BagManager from "../Manager/BagManager";
import InterfaceManager from "../Manager/InterfaceManager";
import { GameType } from "../PrefabManager/PrefabManage";
const {ccclass, property} = cc._decorator;
@ccclass
export default class CurGameJinHuoDesc extends cc.Component {
@property(cc.Node)
jianTouXia: cc.Node = null;
@property(cc.Node)
descView: cc.Node = null;
@property(cc.Node)
itemNode: cc.Node = null;
@property(cc.Node)
jianTouShang: cc.Node = null;
@property([cc.String])
curGameName:string[] = []
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
this.refreshView()
EventMgr.onEvent_custom(ryw_Event.RefreshCurJinHuoDesc,()=>{
this.refreshView()
},this)
}
refreshView(){
this.descView.removeAllChildren()
let isHaveKaiye = true//InterfaceManager.getHaveKaiye(GameType.GDaoYeShouGou)
let daoyeGoodList = User.getDaoyeGoodList()
let mainTaskInfo:any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
// if(this.curGameName == '小卖部' && MainTaskIdEnum.MainTask_109 == mainId){
// //1434,1435,1430,1432
// daoyeGoodList = [
// {goodId:1434},
// {goodId:1432},
// {goodId:1435},
// {goodId:1430},
// ]
// }
let isHaveData = false
for(let i=0;i<daoyeGoodList.length;i++){
let goodId = daoyeGoodList[i].goodId
let gameName = InterfaceManager.getGoodInGame(goodId)
// if(gameName != this.curGameName){
// continue
// }
if(this.curGameName.indexOf(gameName) < 0){
continue
}
isHaveData = true
let item = cc.instantiate(this.itemNode)
item.parent = this.descView
item.active = true
this.refeshNode(item,goodId)
}
if(isHaveKaiye && isHaveData){
this.node.active = true
let jianTouShang = cc.instantiate(this.jianTouShang)
jianTouShang.active = true
jianTouShang.parent = this.descView
}else{
this.node.active = false
}
}
onOpenDescView(){
this.jianTouXia.active = false
this.descView.active = true
}
onCloseDescView(){
this.jianTouXia.active = true
this.descView.active = false
}
refeshNode(node_, goodId){
let goodConfig = BagManager.getGoodsProperty(goodId)
let userGoodData = BagManager.getBagGoodConfig(goodId)
let mainTaskInfo:any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
let name = goodConfig.goodName
let buyNum = goodConfig.buyNum
// if(this.curGameName == '小卖部' && MainTaskIdEnum.MainTask_109 == mainId){
// buyNum = 1
// }
let haveNum = 0
if(userGoodData){
haveNum = userGoodData.goodNum
}
let nameLab = node_.getChildByName('goodName').getComponent(cc.Label)
let numLab = node_.getChildByName('goodNum').getComponent(cc.RichText)
nameLab.string = name
if(haveNum>=buyNum){
numLab.string = '<color=#67C119>'+buyNum+'</c><color=#67C119>/'+buyNum+'</color>'
}else{
numLab.string = '<color=#D65C44>'+haveNum+'</c><color=#67C119>/'+buyNum+'</color>'
}
}
}