StarScrollView.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. const ListViewAdapter = require('../utils/TapTapScrollViewAdapter');
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. content: cc.Node,
  6. item: cc.Prefab,
  7. },
  8. // LIFE-CYCLE CALLBACKS:
  9. onLoad () {},
  10. start () {
  11. },
  12. init(starData) {
  13. let buyGold = starData.buyGold;
  14. let starTypeCount = starData.starTypeCount;
  15. this._userStars = starData.userStars;
  16. this.listAdapter = new ListViewAdapter(this);
  17. this.listAdapter.buyGold = buyGold;
  18. this.listAdapter.start = starTypeCount;
  19. this.listAdapter.updateItems(this._userStars, this.item, 'StarItem');
  20. // for(let i = 0; i < userStars.length; ++i) {
  21. // let starItem = cc.instantiate(this.item);
  22. // starItem.getComponent('StarItem').init(userStars[i], buyGold, starTypeCount);
  23. // this.content.addChild(starItem);
  24. // }
  25. this.listAdapter.isBuying = false;
  26. GameEvent.on("Star_Buy_success", this, (areaType, buyGold, starTypeCount) => {
  27. this.listAdapter.buyGold = buyGold;
  28. this.listAdapter.starTypeCount = starTypeCount;
  29. // ///说明满足明星和房间的条件 已经解锁 那么只需要判断金币进行预约了
  30. // if (this._isStarLocked == false && this._isRoomLocked == false) {
  31. // /// 如果金币满足
  32. // this.setUpUseBtnBg(TapTapTool.compare(GameModule.userInfo.gold, this._buyGold));
  33. // this.starUseTitleRichText.string = `<color=#ffffff>签约</c><br/><img src='coin_small'/><color=#ffffff>${TapTapTool.parseToString(this._buyGold)}</c>`;
  34. // }
  35. /// 如果是明星所需种类
  36. for (let i = 0; i < this._userStars.length; ++ i) {
  37. let starData = this._userStars[i];
  38. if (starData.itemId == 102) {
  39. this.listAdapter.starTypeCount = starTypeCount;
  40. /// 如果是明星需要个数
  41. } else if (starData.itemId == 101) {
  42. /// 地区需要明星多少个
  43. } else {
  44. /// 如果该地区与需要的这个地区匹配
  45. if (starData.itemId == areaType) {
  46. starData.areaStarCount += 1;
  47. }
  48. }
  49. }
  50. GameEvent.fire('StarItem_updateUI');
  51. });
  52. },
  53. onScroll() {
  54. if (this.listAdapter != undefined) {
  55. this.listAdapter.update();
  56. }
  57. },
  58. // update (dt) {
  59. // if (this.listAdapter != undefined) {
  60. // this.listAdapter.update(dt);
  61. // }
  62. // },
  63. });