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; @property(Node) edit_hp_delay_time: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,()=>{ if(this.edit_hp.getComponent(EditBox).string.length==0) { this.edit_hp.getComponent(EditBox).string = '0' } this.m_data.hp = parseInt(this.edit_hp.getComponent(EditBox).string) }) this.edit_hp.getComponent(EditBox).string = this.m_data.hp.toString() this.edit_hp_delay_time.off(EditBox.EventType.EDITING_DID_ENDED) this.edit_hp_delay_time.on(EditBox.EventType.EDITING_DID_ENDED, ()=>{ if(this.edit_hp_delay_time.getComponent(EditBox).string.length==0) { this.edit_hp_delay_time.getComponent(EditBox).string = '0' } this.m_data.hp_delay_time = parseFloat(this.edit_hp_delay_time.getComponent(EditBox).string) }) if(this.m_data.hp_delay_time==undefined) { this.m_data.hp_delay_time = 0 } this.edit_hp_delay_time.getComponent(EditBox).string = this.m_data.hp_delay_time.toString() } }