PlantPanel.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /** 可生产产品列表 */
  2. import TableView from "../../../game/component/TableView";
  3. const { ccclass, property } = cc._decorator;
  4. @ccclass
  5. export default class PlantPanel extends cc.Component {
  6. @property({ type: TableView, displayName: '滚动视图' })
  7. private tableView: TableView = null;
  8. private list_data = null;
  9. @property({ type: cc.Node, tooltip: '文字动画' }) node_ani: cc.Node = null;
  10. start() {
  11. gData.plantData.init_itemIndex = -1;
  12. gData.plantData.init_lock = -1;
  13. this.initScollView();
  14. }
  15. getItemDataByID(id) {
  16. let len = this.list_data.length;
  17. for (var i = 0; i < len; i++) {
  18. if (this.list_data[i].picture == id) {
  19. return i;
  20. }
  21. }
  22. return 0;
  23. }
  24. update(dt)
  25. {
  26. if(gData.plantData.init_ani)
  27. {
  28. gData.plantData.init_ani = false;
  29. if (gData.gameData.playerProp.userFarmTaskInfo) {
  30. let com = gData.gameData.playerProp.userFarmTaskInfo.completeCount;
  31. let count = gData.gameData.playerProp.userFarmTaskInfo.taskCount;
  32. let addAni = cc.instantiate(this.node_ani);
  33. addAni.parent = this.node_ani.parent;
  34. addAni.getComponent(cc.Label).string = `百元红包:${com}/${count}`;
  35. cc.tween(addAni).delay(0.7).call(()=>{
  36. addAni.opacity = 255;
  37. }).by(0.8, {y : 100}).to(0.4, {opacity : 0}).call(()=>{
  38. addAni.destroy();
  39. }).start();
  40. }
  41. }
  42. }
  43. /**
  44. * 初始化滚动视图
  45. */
  46. private initScollView() {
  47. this.list_data = gData.plantData.productArr;
  48. this.tableView.node.emit('srollview-init', this.list_data)
  49. }
  50. onDestroy() {
  51. // this.tableView.clearItem();
  52. }
  53. }