attributes_count_down.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import { _decorator, Component, EditBox, Label, Node, Toggle } from 'cc';
  2. import { att_count_down, event_item } from '../../../data/data';
  3. import { tools } from '../../tools';
  4. import { question_btn_info } from './question_btn_info';
  5. import { config } from '../../config';
  6. import { Attributes } from '../Attributes';
  7. const { ccclass, property } = _decorator;
  8. @ccclass('attributes_count_down')
  9. export class attributes_count_down extends Component {
  10. @property(Node) ProgressBar_Bg:Node = null;
  11. @property(Node) ProgressBar_Bar:Node = null;
  12. @property(Node) img_text:Node = null;
  13. @property(Node) toggle_enbale_time:Node = null;
  14. @property(Node) edit_down_count_time:Node = null;
  15. //event
  16. @property(Node) btn_finish_event:Node = null;
  17. @property(Node) btn_fail_event:Node = null;
  18. @property(Node) btn_start_event:Node = null;
  19. @property(Node) lab_finish_event:Node = null;
  20. @property(Node) lab_fail_event:Node = null;
  21. @property(Node) lab_start_event:Node = null;
  22. @property(Node) clear_finish_event:Node = null;
  23. @property(Node) clear_fail_event:Node = null;
  24. @property(Node) clear_start_event:Node = null;
  25. private call_back = null;
  26. private m_data:att_count_down = null;
  27. public initView(call){
  28. this.call_back = call;
  29. this.edit_down_count_time.on('editing-did-ended',()=>{
  30. this.change()
  31. this.update_att(this.m_data)
  32. })
  33. this.toggle_enbale_time.on('toggle',()=>{
  34. this.change()
  35. this.update_att(this.m_data)
  36. })
  37. this.btn_finish_event.on(Node.EventType.TOUCH_END,()=>{
  38. let list = Attributes.Singleton.getEventList()
  39. tools.show_select_evele_list(list,(data:event_item)=>{
  40. this.m_data.finish_event_id = data.event_id;
  41. this.change()
  42. this.update_att(this.m_data)
  43. })
  44. })
  45. this.btn_fail_event.on(Node.EventType.TOUCH_END,()=>{
  46. let list = Attributes.Singleton.getEventList()
  47. tools.show_select_evele_list(list,(data:event_item)=>{
  48. this.m_data.fail_event_id = data.event_id;
  49. this.change()
  50. this.update_att(this.m_data)
  51. })
  52. })
  53. this.btn_start_event.on(Node.EventType.TOUCH_END,()=>{
  54. let list = Attributes.Singleton.getEventList()
  55. tools.show_select_evele_list(list,(data:event_item)=>{
  56. if(data.type!=config.event_type.collect_event){
  57. return tools.showToast("必须设置收集事件")
  58. }
  59. this.m_data.start_event_id = data.event_id;
  60. this.change()
  61. this.update_att(this.m_data)
  62. })
  63. })
  64. this.clear_finish_event.on(Node.EventType.TOUCH_END,()=>{
  65. this.m_data.finish_event_id = -1;
  66. this.change()
  67. this.update_att(this.m_data)
  68. })
  69. this.clear_fail_event.on(Node.EventType.TOUCH_END,()=>{
  70. this.m_data.fail_event_id = -1;
  71. this.change()
  72. this.update_att(this.m_data)
  73. })
  74. this.clear_start_event.on(Node.EventType.TOUCH_END,()=>{
  75. this.m_data.start_event_id = -1;
  76. this.change()
  77. this.update_att(this.m_data)
  78. })
  79. }
  80. public update_att(data:att_count_down){
  81. this.m_data = data;
  82. this.ProgressBar_Bg.getComponent(question_btn_info).initView(this.m_data.ProgressBar_Bg,1,null,config.attributes_list_type.count_down)
  83. this.ProgressBar_Bar.getComponent(question_btn_info).initView(this.m_data.ProgressBar_Bar,2,null,config.attributes_list_type.count_down)
  84. this.img_text.getComponent(question_btn_info).initView(this.m_data.img_text,3,null,config.attributes_list_type.count_down)
  85. this.toggle_enbale_time.getComponent(Toggle).isChecked = this.m_data.is_show_time;
  86. this.edit_down_count_time.getComponent(EditBox).string = this.m_data.time_count.toString()
  87. this.lab_finish_event.getComponent(Label).string = this.m_data.finish_event_id!=-1?`绑定的id${this.m_data.finish_event_id}`:"无"
  88. this.lab_fail_event.getComponent(Label).string = this.m_data.fail_event_id!=-1?`绑定的id${this.m_data.fail_event_id}`:"无"
  89. this.lab_start_event.getComponent(Label).string = this.m_data.start_event_id!=-1?`绑定的id${this.m_data.start_event_id}`:"无"
  90. }
  91. change(){
  92. this.m_data.is_show_time = this.toggle_enbale_time.getComponent(Toggle).isChecked ;
  93. let down_count_time = this.edit_down_count_time.getComponent(EditBox).string
  94. if(down_count_time.length>0) {
  95. this.m_data.time_count = parseInt(down_count_time);
  96. }
  97. if(this.call_back!=null){
  98. this.call_back(this.m_data)
  99. }
  100. }
  101. }