import { _decorator, Component, Node, SimplexCollider, Size } from 'cc';
import { interact_puzzle_data, not_have_interact_data } from '../../../data/data';
import { view_ui_att_item } from './view_ui_att_item';
import { config } from '../../config';
const { ccclass, property } = _decorator;

@ccclass('view_interact_puzzle')
export class view_interact_puzzle extends Component {

    @property(Node) bg:Node = null;
    @property(Node) puzzle1:Node = null;
    @property(Node) puzzle2:Node = null;
    @property(Node) puzzle3:Node = null;
    @property(Node) puzzle4:Node = null;
    @property(Node) puzzle5:Node = null;
    @property(Node) puzzle6:Node = null;
    @property(Node) content:Node = null;

    private m_data:interact_puzzle_data = null;
    public updateView(data:interact_puzzle_data){
        if(data===null){
            data = new interact_puzzle_data;
        }
        this.m_data = data;
        this.bg.getComponent(view_ui_att_item).updateAtt(data.bg)
        data.bg = this.bg.getComponent(view_ui_att_item).getData()

        this.content.getComponent(view_ui_att_item).updateAtt(data.content,config.update_type.update_info)
        data.content = this.content.getComponent(view_ui_att_item).getData()

        let contentSize = new Size(data.content.width,data.content.height)
        this.puzzle1.getComponent(view_ui_att_item).updateAtt(data.puzzle1,config.update_type.update_all)
        data.puzzle1 = this.puzzle1.getComponent(view_ui_att_item).getData(contentSize)
        this.puzzle1.getComponent(view_ui_att_item).updateAtt(data.puzzle1,config.update_type.update_all)

        this.puzzle2.getComponent(view_ui_att_item).updateAtt(data.puzzle2,config.update_type.update_all)
        data.puzzle2 = this.puzzle2.getComponent(view_ui_att_item).getData(contentSize)
        this.puzzle2.getComponent(view_ui_att_item).updateAtt(data.puzzle2,config.update_type.update_all)


        this.puzzle3.getComponent(view_ui_att_item).updateAtt(data.puzzle3,config.update_type.update_all)
        data.puzzle3 = this.puzzle3.getComponent(view_ui_att_item).getData(contentSize)
        this.puzzle3.getComponent(view_ui_att_item).updateAtt(data.puzzle3,config.update_type.update_all)

        this.puzzle4.getComponent(view_ui_att_item).updateAtt(data.puzzle4,config.update_type.update_all)
        data.puzzle4 = this.puzzle4.getComponent(view_ui_att_item).getData(contentSize)
        this.puzzle4.getComponent(view_ui_att_item).updateAtt(data.puzzle4,config.update_type.update_all)

        this.puzzle5.getComponent(view_ui_att_item).updateAtt(data.puzzle5,config.update_type.update_all)
        data.puzzle5 = this.puzzle5.getComponent(view_ui_att_item).getData(contentSize)
        this.puzzle5.getComponent(view_ui_att_item).updateAtt(data.puzzle5,config.update_type.update_all)

        this.puzzle6.getComponent(view_ui_att_item).updateAtt(data.puzzle6,config.update_type.update_all)
        data.puzzle6 = this.puzzle6.getComponent(view_ui_att_item).getData(contentSize)
        this.puzzle6.getComponent(view_ui_att_item).updateAtt(data.puzzle6,config.update_type.update_all)

    }

    public getData(){
        return this.m_data;
    }
}


