咸鱼的反击
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.
 
 
 
xianyudefanji/assets/Scripts/SCommon/ShangDianRenWuDan.ts

103 lines
3.0 KiB

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 ShangDianRenWuDan 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 = '';
// @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 mainTaskInfo:any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
let taskConfig = TaskManager.getTaskConfigById(mainId)
if(taskConfig && taskConfig.taskCaiGouDan && (taskConfig.GMGameType == this.curGameName)){
this.node.active = true
for(let i = 0;i<taskConfig.taskCaiGouDan.length;i++){
let item = cc.instantiate(this.itemNode)
item.parent = this.descView
item.active = true
this.refeshNode(item,taskConfig.taskCaiGouDan[i])
}
// 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 name = goodConfig.goodName
let 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>'
}
}
}