ChildHandbookSuitItem = ChildHandbookSuitItem or BaseClass(BaseItem)
|
|
function ChildHandbookSuitItem:__init()
|
|
self.base_file = "child"
|
|
self.layout_file = "ChildHandbookSuitItem"
|
|
self.is_delay_callback = true
|
|
-- self.use_local_view = true
|
|
self.model = ChildModel:GetInstance()
|
|
self:Load()
|
|
end
|
|
|
|
function ChildHandbookSuitItem:Load_callback()
|
|
self.nodes = {
|
|
"chosen:obj","bg:img:obj","red_dot:obj",
|
|
-- "loading_bg/fight_num:txt",
|
|
"load_num:tmp",
|
|
"frontBg:img",
|
|
"title:tmp",
|
|
}
|
|
self:GetChildren(self.nodes)
|
|
lua_resM:setOutsideImageSprite(self, self.bg_img, GameResPath.GetChildIcon("child_hbsuit_item_bg"), false)
|
|
self:InitEvent()
|
|
if self.need_refreshData then
|
|
self:SetData(self.data,self.callback)
|
|
self:SetChosen(self.isChosen)
|
|
self:SetRedDot(self.isRedDot)
|
|
end
|
|
end
|
|
|
|
function ChildHandbookSuitItem:InitEvent()
|
|
local function updata_child_suit_reward_info_fun()
|
|
--if self.data and self.data.suit_type == suit_type then
|
|
-- print("============>>> YiRan:ChildHandbookSuitItem [start:31] suit_type:",suit_type)
|
|
self:SetData()
|
|
--end
|
|
end
|
|
self.updata_child_suit_reward_info = self.model:Bind(ChildConst.UPDATA_CHILD_HB_SUIT_REWARD_INFO, updata_child_suit_reward_info_fun) --
|
|
|
|
local function onBtnClickHandler(target, x, y)
|
|
if target == self.bg_obj then
|
|
--Message.show("Ñ¡ÖÐaaa:",self.stage)
|
|
self.callback(self)
|
|
end
|
|
end
|
|
AddClickEvent(self.bg_obj, onBtnClickHandler)
|
|
end
|
|
|
|
function ChildHandbookSuitItem:SetData(data,callback)
|
|
self.data = data or self.data
|
|
self.callback = callback or self.callback
|
|
if self.is_loaded then
|
|
if not self.data then return end
|
|
--logWarn('=======Msh:ChildHandbookSuitItem.lua[49]=======')
|
|
-- 设置原画
|
|
local res_id = "toy_img_" .. self.data.suit_type
|
|
-- lua_resM:setOutsideImageSprite(self, self.frontBg_img, GameResPath.GetChildToyImgIcon(res_id), false)
|
|
|
|
|
|
self.title_tmp.text = Trim(self.data.suit_name)
|
|
|
|
local suitRewardList = self.model:GetChildSuitRewardList()
|
|
local collectMaxNum = suitRewardList[self.data.suit_type].collectMaxNum
|
|
local progress = suitRewardList[self.data.suit_type].progress
|
|
--self.load_num_tmp.text = (progress*100 / collectMaxNum).."%"
|
|
self.load_num_tmp.text = string.format('收集(%s/%s)', HtmlColorTxt( progress, progress == 0 and ColorUtil.RED_DARK or ColorUtil.GREEN_DARK) , collectMaxNum)
|
|
-- self.loading_img.fillAmount = (progress / collectMaxNum)
|
|
|
|
------战力
|
|
-- local handbook_list = self.model:GetSuitToyList(self.data.suit_type)
|
|
-- local sum_attr_list = {}
|
|
|
|
-- for k,v in pairs(handbook_list) do
|
|
-- if v.isActive then
|
|
-- local attr_list = stringtotable(v.attr_list)
|
|
-- for k,v_attr in pairs(attr_list) do
|
|
-- local isHad = false
|
|
-- for k,v_sum in pairs(sum_attr_list) do
|
|
-- if v_sum[1] == v_attr[1] then
|
|
-- isHad = true
|
|
-- v_sum[2] = v_sum[2] + v_attr[2]
|
|
-- end
|
|
-- end
|
|
-- if isHad == false then
|
|
-- table.insert(sum_attr_list,v_attr)
|
|
-- end
|
|
-- end
|
|
-- end
|
|
-- end
|
|
-- self.fight_num_txt.text = "f"..GetFighting(sum_attr_list)
|
|
-- self.lock_con_obj:SetActive(progress == 0)
|
|
-- self.bg_img.gray = (progress == 0)
|
|
|
|
--else
|
|
-- self.title_txt.text = "未激活"
|
|
--end
|
|
--
|
|
--self.lock_img_obj:SetActive(false)
|
|
--self.icon_img.color = ColorUtilValue.WHITE
|
|
--if stage == 0 then
|
|
--- self.icon_img.color = Color(148/255,148/255,148/255)
|
|
--- self.lock_img_obj:SetActive(true)
|
|
--else
|
|
--self.stage_txt_num_txt.text = stage
|
|
--end
|
|
|
|
self:SetRedDot(self.isRedDot)
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
end
|
|
|
|
function ChildHandbookSuitItem:SetChosen(bool)
|
|
self.isChosen = bool
|
|
if self.is_loaded then
|
|
if bool then
|
|
self.chosen_obj:SetActive(true)
|
|
else
|
|
self.chosen_obj:SetActive(false)
|
|
end
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
end
|
|
|
|
function ChildHandbookSuitItem:SetRedDot(bool)
|
|
self.isRedDot = bool
|
|
|
|
if self.is_loaded then
|
|
--print("============>>> YiRan:ChildHandbookSuitItem [start:83] vehicle_id :",vehicle_id,"self.isRedDot:",self.isRedDot)
|
|
self.red_dot_obj:SetActive(self.isRedDot)
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
end
|
|
|
|
function ChildHandbookSuitItem:__delete( )
|
|
if self.updata_child_suit_reward_info then
|
|
self.model:UnBind(self.updata_child_suit_reward_info)
|
|
self.updata_child_suit_reward_info = nil
|
|
end
|
|
|
|
end
|