import ViewObject from "../../main/ViewObject"; import CardItem from "../home/card/item/CardItem"; import GoodItem from "./GoodItem"; /** * 通用的奖励显示弹出界面 */ const { ccclass, property } = cc._decorator; @ccclass export default class RewardView extends ViewObject { @property(cc.Prefab) mGoodItem: cc.Prefab = null; @property(cc.Node) mContent: cc.Node = null; @property(cc.Node) mComm: cc.Node = null;//普通道具,装备,金币钻石 @property(cc.Node) mGodCard: cc.Node = null;//神卡显示 @property(CardItem) mCardItem: CardItem = null; @property(cc.Label) mTitle: cc.Label = null;//标题 @property(cc.Label) mAbout: cc.Label = null;//说明 /** * 额外的奖励显示 */ private addList: Array = [] /** * * @param prev 父界面 */ public show(prev?: ViewObject) { if (prev) { this.prev = prev; this.prev.__close(); } this.main.viewManage.popView1(this.node); if (this.main && this.main.gameHttp) { this.main.gameHttp.pushEvent(this); } } //let list = ff.main.sManage.getRewards(reve); /** { type:3, ---0:金币,1:钻石,2:道具,3:装备,4:神卡 icon:'icon/equip/'+equip.icon, count:element.count, id:element.id, pz:equip.pz, PI:element.PI, star:element.star _data:__Equip } * @param list */ public init(list: Array) { let count = 0 for (let i = 0; i < list.length; i++) { const element = list[i]; if (element.type <= 3) { let node = cc.instantiate(this.mGoodItem) node.parent = this.mContent let goodItem = node.getComponent(GoodItem) goodItem.initReward(this.main, element) if(element.name){ goodItem.mContrast.node.active = true goodItem.mContrast.string = element.name } count++ } else { this.addList.push(element) } } if (count <= 0) { this.exitDistroy() }else{ this.mComm.active = true this.mGodCard.active = false } } /** * 退出销毁界面 */ public exitDistroy() { if (this.addList.length <= 0) { super.exitDistroy() } else { this.mComm.active = false this.mGodCard.active = true let rewardData = this.addList.shift() this.mCardItem.init(this.main,rewardData.data) } } public setCloseCallback(closeCallback:()=>void){ this.closeCallback = closeCallback } }