import { _decorator, Component, EditBox, Node } from 'cc';
import { boss_info_data } from '../../../data/data';
import { receive_widget_item } from './receive_widget_item';
const { ccclass, property } = _decorator;

@ccclass('widget_boss_info')
export class widget_boss_info extends Component {
    @property(Node) bg:Node = null;
    @property(Node) bg_bar:Node = null;
    @property(Node) bar:Node = null;
    @property(Node) head:Node = null;
    @property(Node) edit_hp:Node = null;
    private m_data:boss_info_data = null;
    public initView(data:boss_info_data){
        this.m_data = data;
        this.bg.getComponent(receive_widget_item).updateView(this.m_data.bg)
        this.bg_bar.getComponent(receive_widget_item).updateView(this.m_data.bg_bar)
        this.bar.getComponent(receive_widget_item).updateView(this.m_data.bar)
        this.head.getComponent(receive_widget_item).updateView(this.m_data.head)
        this.edit_hp.off(EditBox.EventType.EDITING_DID_ENDED)
        this.edit_hp.on(EditBox.EventType.EDITING_DID_ENDED,()=>{
            this.m_data.hp = parseInt(this.edit_hp.getComponent(EditBox).string)
        })
        this.edit_hp.getComponent(EditBox).string = this.m_data.hp.toString()
    }
}


