源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

146 lines
4.8 KiB

CSMainExploitRankTopItem = CSMainExploitRankTopItem or BaseClass(BaseItem)
local CSMainExploitRankTopItem = CSMainExploitRankTopItem
function CSMainExploitRankTopItem:__init()
self.base_file = "csMain"
self.layout_file = "CSMainExploitRankTopItem"
self.model = CSMainModel:getInstance()
self:Load()
end
function CSMainExploitRankTopItem:Load_callback()
self.nodes = {
"bg:img", "headCon:obj", "rankIcon:img", "none:obj",
"name:tmp", "vipCon", "worshipBtn:obj:img", "worshipBtn/worshipRed:obj",
}
self:GetChildren(self.nodes)
self.vipItem = RoleVipItem.New(self.vipCon)
self.roleItem = HeadRoleItem.New(self.headCon)
self.roleItem:SetItemSize(75,75)
self:AddEvents()
if self.need_refreshData then
self:UpdateView()
end
end
function CSMainExploitRankTopItem:AddEvents( )
local on_click = function ( click_obj )
if self.worshipBtn_obj == click_obj then
if self.data then
local click_worship_role = self.model:GetCSMainClickWorshipRole()
-- local can_worship = self.model:CanPlayerWorship(self.data.role_id)
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60309,self.data.role_id)
else
Message.show("不可膜拜")
end
end
end
AddClickEvent(self.worshipBtn_obj, on_click)
--60309 膜拜后刷新状态
local function on_update_worship(vo)
if self.is_loaded then
self:UpdateView()
end
end
self:BindEvent(self.model, CSMainConst.UPDATE_WORSHIP_STATE, on_update_worship)
end
function CSMainExploitRankTopItem:UpdateView( )
lua_resM:setOutsideImageSprite(self, self.bg_img, GameResPath.GetCSMainImage("cs_main_top_bg_"..self.index), true)
lua_resM:setImageSprite(self, self.rankIcon_img, "csMain_asset","cs_main_rank_"..self.index, true)
self.worshipBtn_obj:SetActive(self.is_my_contray)
if self.data then
self.none_obj:SetActive(false)
self.headCon_obj:SetActive(true)
self.vipItem:SetData(self.data.vip_flag, self.data.sup_vip_type)
if self.data.vip_flag > 0 then
SetAnchoredPositionX(self.name, 15)
SetAnchoredPositionX(self.vipCon, 15-self.name_tmp.preferredWidth)
else
SetAnchoredPositionX(self.name, 0)
end
if self.index == 1 then
self.name_tmp.text = string.format("<#fdffc2>%s</color>",GetCSLongName(self.data.name,self.data.ser_num))
else
self.name_tmp.text = string.format("<#ffffff>%s</color>",GetCSLongName(self.data.name,self.data.ser_num))
end
SetAnchoredPositionX(self.vipCon, 15-self.name_tmp.preferredWidth/2-15-8)
local head_data = {
vo = {
id=self.data.rid,
career=self.data.career,
level=self.data.level,
sex=self.data.sex,
turn=self.data.turn,
dress_board_id = self.data.dress_board or self.data.dress_id,
picture_ver = self.data.picture_ver,
picture = self.data.picture,
profile_photo_id = self.data.profile_photo_id,
},
}
self.roleItem:SetData(head_data)
local can_worship = self.model:CanPlayerWorship(self.data.role_id)
if can_worship then --可以膜拜
SetImageGray(self.worshipBtn_img, false)
self.worshipRed_obj:SetActive(true)
else
SetImageGray(self.worshipBtn_img, true)
self.worshipRed_obj:SetActive(false)
end
else
self.vipItem:SetData(0, 0)
self.none_obj:SetActive(true)
self.headCon_obj:SetActive(false)
SetAnchoredPositionX(self.name, 0)
self.name_tmp.text = self.index == 1 and "<#fdffc2>虚位以待</color>" or "<#ffffff>虚位以待</color>"
SetImageGray(self.worshipBtn_img, true)
self.worshipRed_obj:SetActive(false)
end
SetAnchoredPosition(self.bg,CSMainConst.ExploitTopItemPos[self.index].bg_x,CSMainConst.ExploitTopItemPos[self.index].bg_y)
local rank_scale = CSMainConst.ExploitTopItemPos[self.index].rank_scale
SetLocalScale(self.rankIcon,rank_scale,rank_scale,rank_scale)
SetAnchoredPosition(self.rankIcon,CSMainConst.ExploitTopItemPos[self.index].rank_x,CSMainConst.ExploitTopItemPos[self.index].rank_y)
local head_scale = CSMainConst.ExploitTopItemPos[self.index].head_scale
SetLocalScale(self.headCon,head_scale,head_scale,head_scale)
SetLocalScale(self.none,head_scale,head_scale,head_scale)
SetAnchoredPosition(self.headCon,CSMainConst.ExploitTopItemPos[self.index].head_x,CSMainConst.ExploitTopItemPos[self.index].head_y)
SetAnchoredPosition(self.none,CSMainConst.ExploitTopItemPos[self.index].head_x,CSMainConst.ExploitTopItemPos[self.index].head_y)
SetAnchoredPositionY(self.name,CSMainConst.ExploitTopItemPos[self.index].name_y)
SetAnchoredPositionY(self.vipCon,CSMainConst.ExploitTopItemPos[self.index].name_y)
end
function CSMainExploitRankTopItem:SetData( data,index,is_my_contray )
self.data = data
self.index = index
self.is_my_contray = is_my_contray
if self.is_loaded then
self.need_refreshData = false
self:UpdateView()
else
self.need_refreshData = true
end
end
function CSMainExploitRankTopItem:__delete( )
if self.vipItem then
self.vipItem:DeleteMe()
self.vipItem = nil
end
if self.roleItem then
self.roleItem:DeleteMe()
self.roleItem = nil
end
end