源战役客户端
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.
 
 
 
 
 

290 lines
9.4 KiB

ChildHandbookUpgradeView = ChildHandbookUpgradeView or BaseClass(BaseView)
local ChildHandbookUpgradeView = ChildHandbookUpgradeView
-- ChildHandbookUpgradeView.TabData = {
-- [1] = {name = "人物", level = 1},
-- [2] = {name = "人", level = 1},
-- [3] = {name = "物", level = 1},
-- }
function ChildHandbookUpgradeView:__init()
self.base_file = "child"
self.layout_file = "ChildHandbookUpgradeView"
self.layer_name = "Activity"
self.destroy_imm = true
self.use_background = true --全屏界面默认使用这个参数
self.hide_maincancas = true
self.change_scene_close = true
self.append_to_ctl_queue = false --是否要添加进界面堆栈
self.need_show_money = false --是否要显示顶部的金钱栏
self.is_set_zdepth = true
self.model = ChildModel:GetInstance()
self.blur_activity_bg = true
self.attr_item_list = {}
self.attr_item_sum_list = {}
self.suit_tab_item_list = {}
self.load_callback = function ()
self:LoadSuccess()
self:AddEvent()
end
self.open_callback = function ( )
self:OpenSuccess()
end
self.switch_callback = function(index)
self:SwitchTab(index)
end
self.destroy_callback = function ( )
self:DestroySuccess()
end
end
function ChildHandbookUpgradeView:Open( )
--self.data = data
BaseView.Open(self)
end
function ChildHandbookUpgradeView:LoadSuccess()
local nodes = {
"con_money",
"container/bg:raw",
"container/btn_level_up:obj",
"container/btn_level_up/red_dot_up:obj",
-- "container/collectCon/fight_num:txt",
"container/collectCon/collect_num:tmp","container/collectCon/percent_num:tmp",
"container/collectCon:obj", "container/levelCon:obj",
"container/collectCon/ScrollView_attr/Viewport/Content_attr_collect",
"container/levelCon/ScrollView_attr/Viewport/Content_attr_level",
"container/levelCon/level_num:txt", "container/levelCon/level_num_after:txt",
-- "container/levelCon/fight_num_level:txt",
"container/levelCon/money_con/money_num:tmp",
"container/ScrollView_item/Viewport/Content_item",
"container/levelCon/effectCon",
"container/levelCon/maxTxt:obj:tmp",
}
self:GetChildren(nodes)
local closeWin_callback = function()
self:Close()
end
self.tabWindowComponent = UITabWindow.New(self.transform,{},select_callback,closeWin_callback,
self.background_wnd,self.container, UITabWindow.SizeSmallNoTab, false,nil,true)
self.tabWindowComponent:SetBackgroundRes("child_handbook_upgrade_bg_945_533")
self.tabWindowComponent:SetTitleText("玩具加成")
self.tabWindowComponent:ChangeShowFlag("Child")
--lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetChildIcon("child_hb_upgrade_bg"),false)
local child_coin_good_id = self.model:GetChildCoinId()
self.model:Fire(ChildConst.UPDATA_CHILD_COIN_NUM,GoodsModel:getInstance():GetTypeGoodsNum(child_coin_good_id))
end
function ChildHandbookUpgradeView:AddEvent()
local function onBreakSuccess()
if self:HasOpen() then
self:UpdateView()
end
end
self.onBreakSuccess_id = GlobalEventSystem:Bind(EventName.GOODS_DECOMPOSE_RESULT, onBreakSuccess)
local function updata_child_dif_suit_info_fun()
self:SetBoxDesCon()
end
self.updata_child_dif_suit_info = self.model:Bind(ChildConst.UPDATA_CHILD_HB_SUIT_INFO, updata_child_dif_suit_info_fun) --
local function updata_Child_RED_DOT_VIEW_fun(id)
if id ~= ChildConst.TabId.ChildHandbook then return end
self:UpdateRedDot()
end
self.updata_Child_RED_DOT_VIEW_id = self.model:Bind(ChildConst.Child_RED_DOT_VIEW, updata_Child_RED_DOT_VIEW_fun) --红点更新
local function onBtnClickHandler(target, x, y)
if target == self.btn_level_up_obj then
self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16537) -- 升级
end
end
AddClickEvent(self.btn_level_up_obj, onBtnClickHandler)
end
function ChildHandbookUpgradeView:OpenSuccess()
self:UpdateView()
end
function ChildHandbookUpgradeView:UpdateView()
self:SetBoxDesCon()
self:UpdateRedDot()
local toy_suit_list = self.model:GetToySuitInfo()
local function callback( item )
end
for k,v in pairs(toy_suit_list) do
local item = self.suit_tab_item_list[k]
if item == nil then
item = ChildHandbookSuitItem.New(self.Content_item)
self.suit_tab_item_list[k] = item
end
--local data = self.model:GetConfigChildSkillInfo(v.skill_id,v.skill_lv)
self.suit_tab_item_list[k]:SetData(v,callback)
end
end
function ChildHandbookUpgradeView:SetBoxDesCon( ) --改为整个玩具箱的而不是单独的
local handbook_list = self.model:GetSuitToyList()
local level = self.model:GetSuitToyBoxLv()
self.level_num_after_txt.text = level + 1
local last_level = tonumber(self.level_num_txt.text)
self.level_num_txt.text = level
local up_grade_list = self.model:GetChildHandbookToyUpgradeList(level)
-- self.fight_num_level_txt.text = "f"..GetFighting(stringtotable(up_grade_list.add_attr))
self.money_num_tmp.text = stringtotable(up_grade_list.next_cost)[1][3]
local up_grade_list_next = self.model:GetChildHandbookToyUpgradeList(level+1)
if TableSize(up_grade_list_next) <= 0 then--满级
self.level_num_after_txt.text = ""
self.maxTxt_tmp.text = "已满级"
else
self.maxTxt_tmp.text = ""
end
if self.has_init then
if (not self.show_fight_effect) and last_level < level then
self.show_fight_effect = true
local function call_back( )
self.show_fight_effect = false
end
self:ClearUIEffect(self.effectCon)
self:AddUIEffect("ui_jinjieshuxing", self.effectCon,
self.layer_name, Vector3(-220, 20, 0), 1.2, false, 0.75, nil, call_back)
end
end
if not self.has_init then -- 第一次初始化标志
self.has_init = true
end
----升级属性
--local attr_list = self.model:GetChildVehicleShowAttrList(vehicle_id,stage)
local attr_list = self.model:GetChildHandbookItemAttrList(level) -- stringtotable(item.data.attr_list)
for i=1,#self.attr_item_list do
self.attr_item_list[i]:SetVisible(false)
end
for k,v in pairs(attr_list) do
local item = self.attr_item_list[k]
if item == nil then
item = ChildHandbookAttrItem.New(self.Content_attr_level)
self.attr_item_list[k] = item
end
self.attr_item_list[k]:SetData(v.attr_id,v.num_before,v.num_after)
item:SetVisible(true)
end
--------总属性,总进度
local suitRewardList = self.model:GetChildSuitRewardList()
local progress = 0
local collectMaxNum = 0
for k,v in pairs(suitRewardList) do
progress = progress + v.progress
collectMaxNum = collectMaxNum + v.collectMaxNum
end
self.collect_num_tmp.text = ""..progress.."/"..collectMaxNum..""
self.percent_num_tmp.text = (progress*100 / collectMaxNum).."%"
--------总战力计算,总属性显示handbook_list
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
for i=1,#self.attr_item_sum_list do
self.attr_item_sum_list[i]:SetVisible(false)
end
for k,v in pairs(sum_attr_list) do
local item = self.attr_item_sum_list[k]
if item == nil then
item = ChildHandbookAttrItem.New(self.Content_attr_collect)
self.attr_item_sum_list[k] = item
end
self.attr_item_sum_list[k]:SetData(v[1],v[2],"collect")
item:SetVisible(true)
end
-- self.fight_num_txt.text = "f"..GetFighting(sum_attr_list)
end
function ChildHandbookUpgradeView:SwitchTab( index )
end
function ChildHandbookUpgradeView:UpdateRedDot( )
local red_dot_list = self.model:GetRedDotChildHandbook()
self.red_dot_up_obj:SetActive(red_dot_list.is_level_up)
end
function ChildHandbookUpgradeView:DestroySuccess( )
if self.onBreakSuccess_id then
self.model:UnBind(self.onBreakSuccess_id)
self.onBreakSuccess_id = nil
end
if self.updata_child_dif_suit_info then
self.model:UnBind(self.updata_child_dif_suit_info)
self.updata_child_dif_suit_info = nil
end
if self.updata_Child_RED_DOT_VIEW_id then
self.model:UnBind(self.updata_Child_RED_DOT_VIEW_id)
self.updata_Child_RED_DOT_VIEW_id = nil
end
if self.tabWindowComponent then
self.tabWindowComponent:DeleteMe()
self.tabWindowComponent = nil
end
for i, v in ipairs(self.attr_item_sum_list) do
v:DeleteMe()
v = nil
end
self.attr_item_sum_list = {}
for i, v in ipairs(self.suit_tab_item_list) do
v:DeleteMe()
v = nil
end
self.suit_tab_item_list = {}
for i, v in ipairs(self.attr_item_list) do
v:DeleteMe()
v = nil
end
self.attr_item_list = {}
end