123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- const ListViewAdapter = require('../utils/TapTapScrollViewAdapter');
- cc.Class({
- extends: cc.Component,
- properties: {
- content: cc.Node,
- item: cc.Prefab,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {},
- start () {
- },
- init(starData) {
- let buyGold = starData.buyGold;
- let starTypeCount = starData.starTypeCount;
- this._userStars = starData.userStars;
- this.listAdapter = new ListViewAdapter(this);
- this.listAdapter.buyGold = buyGold;
- this.listAdapter.start = starTypeCount;
- this.listAdapter.updateItems(this._userStars, this.item, 'StarItem');
- // for(let i = 0; i < userStars.length; ++i) {
- // let starItem = cc.instantiate(this.item);
- // starItem.getComponent('StarItem').init(userStars[i], buyGold, starTypeCount);
- // this.content.addChild(starItem);
- // }
- this.listAdapter.isBuying = false;
- GameEvent.on("Star_Buy_success", this, (areaType, buyGold, starTypeCount) => {
- this.listAdapter.buyGold = buyGold;
- this.listAdapter.starTypeCount = starTypeCount;
- // ///说明满足明星和房间的条件 已经解锁 那么只需要判断金币进行预约了
- // if (this._isStarLocked == false && this._isRoomLocked == false) {
- // /// 如果金币满足
- // this.setUpUseBtnBg(TapTapTool.compare(GameModule.userInfo.gold, this._buyGold));
- // this.starUseTitleRichText.string = `<color=#ffffff>签约</c><br/><img src='coin_small'/><color=#ffffff>${TapTapTool.parseToString(this._buyGold)}</c>`;
- // }
- /// 如果是明星所需种类
- for (let i = 0; i < this._userStars.length; ++ i) {
- let starData = this._userStars[i];
- if (starData.itemId == 102) {
- this.listAdapter.starTypeCount = starTypeCount;
- /// 如果是明星需要个数
- } else if (starData.itemId == 101) {
- /// 地区需要明星多少个
- } else {
- /// 如果该地区与需要的这个地区匹配
- if (starData.itemId == areaType) {
- starData.areaStarCount += 1;
- }
- }
- }
- GameEvent.fire('StarItem_updateUI');
- });
- },
- onScroll() {
- if (this.listAdapter != undefined) {
- this.listAdapter.update();
- }
- },
- // update (dt) {
- // if (this.listAdapter != undefined) {
- // this.listAdapter.update(dt);
- // }
- // },
- });
|