源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

146 行
4.8 KiB

  1. CSMainExploitRankTopItem = CSMainExploitRankTopItem or BaseClass(BaseItem)
  2. local CSMainExploitRankTopItem = CSMainExploitRankTopItem
  3. function CSMainExploitRankTopItem:__init()
  4. self.base_file = "csMain"
  5. self.layout_file = "CSMainExploitRankTopItem"
  6. self.model = CSMainModel:getInstance()
  7. self:Load()
  8. end
  9. function CSMainExploitRankTopItem:Load_callback()
  10. self.nodes = {
  11. "bg:img", "headCon:obj", "rankIcon:img", "none:obj",
  12. "name:tmp", "vipCon", "worshipBtn:obj:img", "worshipBtn/worshipRed:obj",
  13. }
  14. self:GetChildren(self.nodes)
  15. self.vipItem = RoleVipItem.New(self.vipCon)
  16. self.roleItem = HeadRoleItem.New(self.headCon)
  17. self.roleItem:SetItemSize(75,75)
  18. self:AddEvents()
  19. if self.need_refreshData then
  20. self:UpdateView()
  21. end
  22. end
  23. function CSMainExploitRankTopItem:AddEvents( )
  24. local on_click = function ( click_obj )
  25. if self.worshipBtn_obj == click_obj then
  26. if self.data then
  27. local click_worship_role = self.model:GetCSMainClickWorshipRole()
  28. -- local can_worship = self.model:CanPlayerWorship(self.data.role_id)
  29. self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60309,self.data.role_id)
  30. else
  31. Message.show("不可膜拜")
  32. end
  33. end
  34. end
  35. AddClickEvent(self.worshipBtn_obj, on_click)
  36. --60309 膜拜后刷新状态
  37. local function on_update_worship(vo)
  38. if self.is_loaded then
  39. self:UpdateView()
  40. end
  41. end
  42. self:BindEvent(self.model, CSMainConst.UPDATE_WORSHIP_STATE, on_update_worship)
  43. end
  44. function CSMainExploitRankTopItem:UpdateView( )
  45. lua_resM:setOutsideImageSprite(self, self.bg_img, GameResPath.GetCSMainImage("cs_main_top_bg_"..self.index), true)
  46. lua_resM:setImageSprite(self, self.rankIcon_img, "csMain_asset","cs_main_rank_"..self.index, true)
  47. self.worshipBtn_obj:SetActive(self.is_my_contray)
  48. if self.data then
  49. self.none_obj:SetActive(false)
  50. self.headCon_obj:SetActive(true)
  51. self.vipItem:SetData(self.data.vip_flag, self.data.sup_vip_type)
  52. if self.data.vip_flag > 0 then
  53. SetAnchoredPositionX(self.name, 15)
  54. SetAnchoredPositionX(self.vipCon, 15-self.name_tmp.preferredWidth)
  55. else
  56. SetAnchoredPositionX(self.name, 0)
  57. end
  58. if self.index == 1 then
  59. self.name_tmp.text = string.format("<#fdffc2>%s</color>",GetCSLongName(self.data.name,self.data.ser_num))
  60. else
  61. self.name_tmp.text = string.format("<#ffffff>%s</color>",GetCSLongName(self.data.name,self.data.ser_num))
  62. end
  63. SetAnchoredPositionX(self.vipCon, 15-self.name_tmp.preferredWidth/2-15-8)
  64. local head_data = {
  65. vo = {
  66. id=self.data.rid,
  67. career=self.data.career,
  68. level=self.data.level,
  69. sex=self.data.sex,
  70. turn=self.data.turn,
  71. dress_board_id = self.data.dress_board or self.data.dress_id,
  72. picture_ver = self.data.picture_ver,
  73. picture = self.data.picture,
  74. profile_photo_id = self.data.profile_photo_id,
  75. },
  76. }
  77. self.roleItem:SetData(head_data)
  78. local can_worship = self.model:CanPlayerWorship(self.data.role_id)
  79. if can_worship then --可以膜拜
  80. SetImageGray(self.worshipBtn_img, false)
  81. self.worshipRed_obj:SetActive(true)
  82. else
  83. SetImageGray(self.worshipBtn_img, true)
  84. self.worshipRed_obj:SetActive(false)
  85. end
  86. else
  87. self.vipItem:SetData(0, 0)
  88. self.none_obj:SetActive(true)
  89. self.headCon_obj:SetActive(false)
  90. SetAnchoredPositionX(self.name, 0)
  91. self.name_tmp.text = self.index == 1 and "<#fdffc2>虚位以待</color>" or "<#ffffff>虚位以待</color>"
  92. SetImageGray(self.worshipBtn_img, true)
  93. self.worshipRed_obj:SetActive(false)
  94. end
  95. SetAnchoredPosition(self.bg,CSMainConst.ExploitTopItemPos[self.index].bg_x,CSMainConst.ExploitTopItemPos[self.index].bg_y)
  96. local rank_scale = CSMainConst.ExploitTopItemPos[self.index].rank_scale
  97. SetLocalScale(self.rankIcon,rank_scale,rank_scale,rank_scale)
  98. SetAnchoredPosition(self.rankIcon,CSMainConst.ExploitTopItemPos[self.index].rank_x,CSMainConst.ExploitTopItemPos[self.index].rank_y)
  99. local head_scale = CSMainConst.ExploitTopItemPos[self.index].head_scale
  100. SetLocalScale(self.headCon,head_scale,head_scale,head_scale)
  101. SetLocalScale(self.none,head_scale,head_scale,head_scale)
  102. SetAnchoredPosition(self.headCon,CSMainConst.ExploitTopItemPos[self.index].head_x,CSMainConst.ExploitTopItemPos[self.index].head_y)
  103. SetAnchoredPosition(self.none,CSMainConst.ExploitTopItemPos[self.index].head_x,CSMainConst.ExploitTopItemPos[self.index].head_y)
  104. SetAnchoredPositionY(self.name,CSMainConst.ExploitTopItemPos[self.index].name_y)
  105. SetAnchoredPositionY(self.vipCon,CSMainConst.ExploitTopItemPos[self.index].name_y)
  106. end
  107. function CSMainExploitRankTopItem:SetData( data,index,is_my_contray )
  108. self.data = data
  109. self.index = index
  110. self.is_my_contray = is_my_contray
  111. if self.is_loaded then
  112. self.need_refreshData = false
  113. self:UpdateView()
  114. else
  115. self.need_refreshData = true
  116. end
  117. end
  118. function CSMainExploitRankTopItem:__delete( )
  119. if self.vipItem then
  120. self.vipItem:DeleteMe()
  121. self.vipItem = nil
  122. end
  123. if self.roleItem then
  124. self.roleItem:DeleteMe()
  125. self.roleItem = nil
  126. end
  127. end