import { _decorator, Component, Node } from 'cc';
import { att_top_data } from '../../../data/data';
import { config } from '../../config';
import { widget_not_have_interact } from './widget_not_have_interact';
import { widget_interact_input } from './widget_interact_input';
import { widget_interact_puzzle } from './widget_interact_puzzle';
import { widget_interact_page } from './widget_interact_page';
import { widget_pointer_ding_wei } from './widget_pointer_ding_wei';
import { widget_wei_chi_pointer } from './widget_wei_chi_pointer';
import { widget_boss_info } from './widget_boss_info';
const { ccclass, property } = _decorator;

@ccclass('att_widget_set_view')
export class att_widget_set_view extends Component {
    @property(Node) not_have_interact:Node = null;
    @property(Node) interact_input:Node = null;
    @property(Node) interact_page:Node = null;
    @property(Node) interact_puzzle:Node = null;
    @property(Node) interact_scene:Node = null;
    @property(Node) pointer_ding_wei:Node = null;
    @property(Node) wei_chi_pointer:Node = null;
    @property(Node) boss_info:Node = null;
    private m_data:att_top_data = null;
    private map_node:Map<number,Node> = new Map;
    init(): void {
        this.map_node.set(config.top_view_type.not_have_interact,this.not_have_interact)
        this.map_node.set(config.top_view_type.interact_input,this.interact_input)
        this.map_node.set(config.top_view_type.interact_page,this.interact_page)
        this.map_node.set(config.top_view_type.interact_puzzle,this.interact_puzzle)
        this.map_node.set(config.top_view_type.interact_scene,this.interact_scene)
        this.map_node.set(config.top_view_type.pointer_ding_wei,this.pointer_ding_wei)
        this.map_node.set(config.top_view_type.wei_chi_pointer,this.wei_chi_pointer)
        this.map_node.set(config.top_view_type.boss_info,this.boss_info)
    }

    hideAllNode(){
        this.map_node.forEach((v,k)=>{
            v.active = false;
        })
    }
    public updateStatus(data:att_top_data){
        this.m_data = data;
        this.hideAllNode()
        if(this.map_node.size<=0){
            this.init()
        }
        this.map_node.get(this.m_data.top_ui_type).active = true;
        switch (this.m_data.top_ui_type) {
            case config.top_view_type.not_have_interact:
                this.map_node.get(this.m_data.top_ui_type).getComponent(widget_not_have_interact).initView(this.m_data._not_have_interact_data)
                break;
            case config.top_view_type.interact_input:
                this.map_node.get(this.m_data.top_ui_type).getComponent(widget_interact_input).initView(this.m_data._interact_input_data)
                break;
            case config.top_view_type.interact_puzzle:
                this.map_node.get(this.m_data.top_ui_type).getComponent(widget_interact_puzzle).initView(this.m_data._interact_puzzle_data)
                break;
            case config.top_view_type.interact_page:
                this.map_node.get(this.m_data.top_ui_type).getComponent(widget_interact_page).initView(this.m_data._interact_page_data)
                break;
            case config.top_view_type.pointer_ding_wei:
                this.map_node.get(this.m_data.top_ui_type).getComponent(widget_pointer_ding_wei).initView(this.m_data._pointer_ding_wei_data)
                break;
            case config.top_view_type.wei_chi_pointer:
                this.map_node.get(this.m_data.top_ui_type).getComponent(widget_wei_chi_pointer).initView(this.m_data._wei_chi_pointer_data)
                break;
            case config.top_view_type.boss_info:
                this.map_node.get(this.m_data.top_ui_type).getComponent(widget_boss_info).initView(this.m_data._boss_info_data)
                break;
        }
    }
}


