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

96 lines
3.2 KiB

-- <*
-- @Author: Saber
-- @Description: 本国团战右侧信息采集物信息item
-- *>
GuildCSGRSceneCollectionItem = GuildCSGRSceneCollectionItem or BaseClass(BaseItem)
local GuildCSGRSceneCollectionItem = GuildCSGRSceneCollectionItem
function GuildCSGRSceneCollectionItem:__init(parent_wnd,prefab_asset,layer_name)
self.base_file = "guildCSGR"
self.layout_file = "GuildCSGRSceneCollectionItem"
self.parent_wnd = parent_wnd
self.layer_name = layer_name
self.model = GuildModel:getInstance()
self:Load()
end
function GuildCSGRSceneCollectionItem:Load_callback()
local nodes = {
"buff_icon:img",
"effect_lb:tmp",
-- "cur_num:tmp",
-- "left_num:tmp",
}
self:GetChildren(nodes)
self:AddEvents()
if self.need_refreshData then
self:UpdateBasicData()
self:UpdateView()
end
end
function GuildCSGRSceneCollectionItem:AddEvents( )
local function click_event(target)
if not self.can_click then return end
if target == self.gameObject then
if self.attr_icon then
self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 41008, self.attr_icon)
end
end
end
AddClickEvent(self.gameObject, click_event)
-- 更新采集数据
local function update_collect_buff()
self:UpdateView()
end
self:BindEvent(self.model, GuildModel.UPDATE_CSGR_BF_RES, update_collect_buff)
end
function GuildCSGRSceneCollectionItem:SetData( data, can_click )
self.data = data
self.can_click = can_click
self.attr_icon = data[1]
self.attr_id = data[2]
self.attr_cfg_val = data[3]
if self.is_loaded then
self.need_refreshData = false
self:UpdateBasicData()
self:UpdateView()
else
self.need_refreshData = true
end
end
function GuildCSGRSceneCollectionItem:UpdateBasicData( )
if self.data then
lua_resM:setImageSprite(self, self.buff_icon_img, "guildCSGR_asset", "csgr_attr_"..self.attr_icon, true)
end
end
function GuildCSGRSceneCollectionItem:UpdateView( )
if self.data then
-- 场景资源数据
local res_data = self.model:GetCSGRBattlefieldRes(self.attr_icon)
-- local left_num = res_data and res_data.num or 0
-- 社团buff资源数据
local buff_data = self.model:GetCSGRCollectBuffs(self.attr_icon)
-- local attr_name = WordManager:GetProperties(self.attr_id)
local attr_name = GuildModel.CSGRAttrName[self.attr_id]
local attr_val = WordManager:GetPropertyValue(self.attr_id, self.attr_cfg_val * (buff_data and buff_data.num or 0))
self.effect_lb_tmp.text = string.format("%s加成:<color=%s>%s</color>",
attr_name, ColorUtil.GREEN_DARK, attr_val)
-- self.effect_lb_tmp.text = string.format("%s <color=%s>+%s</color>", attr_name, ColorUtil.GREEN_DARK, attr_val)
-- self.cur_num_tmp.text = string.format("社团总采集数:<color=%s>%s</color>", ColorUtil.GREEN_DARK, buff_data and buff_data.num or 0)
-- self.left_num_tmp.text = string.format("剩余:<color=%s>%s</color>",
-- left_num > 0 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK, left_num)
end
end
function GuildCSGRSceneCollectionItem:__delete( )
end