1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
- import { event_item } from '../../../data/data';
- import { select_collect_event_item } from './select_collect_event_item';
- const { ccclass, property } = _decorator;
- @ccclass('select_collect_event')
- export class select_collect_event extends Component {
- @property(Node) content:Node = null;
- @property(Node) btn_close:Node = null;
- @property(Prefab) item_prefab:Prefab = null;
- @property(Node) btn_sure:Node = null;
- private call_back = null;
- public show(list:event_item[],call,cur_event_id:number,event_list_id:number[]){
- this.call_back = call;
- for (let index = 0; index < list.length; index++) {
- const element = list[index];
- let isHave = false;
- for (let i = 0; i < event_list_id.length; i++) {
- const id = event_list_id[i];
- if(id==element.event_id){
- isHave = true;
- break;
- }
- }
- if(element.event_id!=cur_event_id){
- let item = instantiate(this.item_prefab)
- item.parent = this.content;
- item.getComponent(select_collect_event_item).initView(element,isHave)
- }
- }
- this.btn_close.on(Node.EventType.TOUCH_END,()=>{
- this.close()
- })
- this.btn_sure.on(Node.EventType.TOUCH_END,()=>{
- if(this.call_back!=null){
- this.call_back(this.getSelectList())
- }
- this.close();
- })
- }
- public getSelectList():number[]{
- let temp = []
- for (let index = 0; index < this.content.children.length; index++) {
- const element = this.content.children[index];
- if( element.getComponent(select_collect_event_item).getIsSelect()){
- temp.push(element.getComponent(select_collect_event_item).getData().event_id)
- }
- }
- return temp;
- }
- close(){
- this.node.destroy()
- }
- }
|