源战役客户端
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.9 KiB

  1. CSGWarSupportItem = CSGWarSupportItem or BaseClass(BaseItem)
  2. local CSGWarSupportItem = CSGWarSupportItem
  3. function CSGWarSupportItem:__init()
  4. self.base_file = "CSGWar"
  5. self.layout_file = "CSGWarSupportItem"
  6. self.model = CSGWarModel:GetInstance()
  7. self:Load()
  8. end
  9. function CSGWarSupportItem:Load_callback()
  10. self.nodes = {
  11. "power_text:txt", "num_text:tmp", "my_image:obj", "guild_text:tmp", "name_text:tmp", "country_text:tmp", "progress_image:img",
  12. "support_text:tmp","select_image:obj", "click_con:obj", "bg:img", "boss_power_text:txt", "contry_image:img",
  13. }
  14. self:GetChildren(self.nodes)
  15. self:AddEvents()
  16. if self.need_refreshData then
  17. self:UpdateView()
  18. end
  19. if self.need_reselect then
  20. self:SetSelect(self.select)
  21. end
  22. end
  23. function CSGWarSupportItem:AddEvents( )
  24. local function on_click( ... )
  25. if self.call_back then
  26. self.call_back(self.data, self.index)
  27. end
  28. end
  29. AddClickEvent(self.click_con_obj, on_click)
  30. end
  31. function CSGWarSupportItem:UpdateView( )
  32. local data = self.data
  33. self.country_text_tmp.text = KfWorldModel:GetInstance():GetContrayNameById(self.index)
  34. lua_resM:setOutsideImageSprite(self, self.bg_img, GameResPath.GetCSGWarImage("csgwar_support_bg"..self.index))
  35. if data and TableSize(data) > 0 then
  36. lua_resM:setImageSprite(self, self.contry_image_img, "CSGWar_asset", "CSGWar_color"..self.index)
  37. self.power_text_txt.text = data.guild_power
  38. -- self.progress_image_img.fillAmount = data.help_num/self.all_support_num
  39. self.progress_image_img.fillAmount = data.help_num/100--改成100作为分母了
  40. self.name_text_tmp.text = "团长: "..data.chief_name
  41. self.num_text_tmp.text = data.help_num
  42. self.guild_text_tmp.text = GetCSLongName(data.guild_name, data.server_num, false, ColorUtil.GREEN_DARK)
  43. self.my_image_obj:SetActive(data.my_help_num > 0)
  44. self.support_text_tmp.text = string.format("我的应援:%s", data.my_help_num)
  45. self.boss_power_text_txt.text = data.chief_power
  46. else
  47. self.power_text_txt.text = 0
  48. self.progress_image_img.fillAmount = 0
  49. self.name_text_tmp.text = "暂无"
  50. self.num_text_tmp.text = 0
  51. self.guild_text_tmp.text = "暂无社团"
  52. self.my_image_obj:SetActive(false)
  53. self.support_text_tmp.text = "我的应援:0"
  54. self.boss_power_text_txt.text = 0
  55. end
  56. end
  57. function CSGWarSupportItem:SetCallBackFunc( func )
  58. self.call_back = func
  59. end
  60. function CSGWarSupportItem:GetData( )
  61. return self.data
  62. end
  63. function CSGWarSupportItem:SetData( data,index,all_support_num )
  64. self.data = data
  65. self.index = index
  66. self.all_support_num = all_support_num or 1
  67. if self.is_loaded then
  68. self.need_refreshData = false
  69. self:UpdateView()
  70. else
  71. self.need_refreshData = true
  72. end
  73. end
  74. function CSGWarSupportItem:SetSelect( bool )
  75. self.select = bool
  76. if self.is_loaded then
  77. self.need_reselect = false
  78. self.select_image_obj:SetActive(bool)
  79. else
  80. self.need_reselect = true
  81. end
  82. end
  83. function CSGWarSupportItem:__delete( )
  84. end