| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- /** 可生产产品列表 */
- import TableView from "../../../game/component/TableView";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class PlantPanel extends cc.Component {
- @property({ type: TableView, displayName: '滚动视图' })
- private tableView: TableView = null;
- private list_data = null;
- @property({ type: cc.Node, tooltip: '文字动画' }) node_ani: cc.Node = null;
- start() {
- gData.plantData.init_itemIndex = -1;
- gData.plantData.init_lock = -1;
- this.initScollView();
- mk.event.emit("moveUpAndDownFarmMapUI", true);
- mk.event.register("close-panel", this.closeUI.bind(this), this);
- }
- getItemDataByID(id) {
- let len = this.list_data.length;
- for (var i = 0; i < len; i++) {
- if (this.list_data[i].picture == id) {
- return i;
- }
- }
- return 0;
- }
- update(dt)
- {
- if(gData.plantData.init_ani)
- {
- gData.plantData.init_ani = false;
- if (gData.gameData.playerProp.userFarmTaskInfo) {
- let com = gData.gameData.playerProp.userFarmTaskInfo.completeCount;
- let count = gData.gameData.playerProp.userFarmTaskInfo.taskCount;
- let addAni = cc.instantiate(this.node_ani);
- addAni.parent = this.node_ani.parent;
- addAni.getComponent(cc.Label).string = `百元红包:${com}/${count}`;
- cc.tween(addAni).delay(0.7).call(()=>{
- addAni.opacity = 255;
- }).by(0.8, {y : 100}).to(0.4, {opacity : 0}).call(()=>{
- addAni.destroy();
- }).start();
- }
- }
- }
- /**
- * 初始化滚动视图
- */
- private initScollView() {
- this.list_data = gData.plantData.productArr;
- this.tableView.node.emit('srollview-init', this.list_data)
- if(gData.plantData.productIndex > 1)
- {
- cc.tween(this).delay(0.2).call(()=>{
- if(this.list_data.length > 4)
- {
- if(gData.plantData.productIndex <= this.list_data.length-4)
- {
- this.tableView.contentMoveByIndex(gData.plantData.productIndex-1, 0.2);
- }else{
- //this.tableView.moveButtom();
- this.tableView.contentMoveByIndex(this.list_data.length-4, 0.2, true);
- }
- }
-
- }).start();
- }
- }
- onDestroy() {
- // this.tableView.clearItem();
- mk.event.remove("close-panel", this);
- }
- public closeUI()
- {
- mk.event.emit("moveUpAndDownFarmMapUI", false);
- }
- }
|