RankEquipView = RankEquipView or BaseClass(BaseItem)
|
|
function RankEquipView:__init(parent_wnd, prefab_asset, layer_name)
|
|
self.base_file = "rank"
|
|
self.layout_file = "RankEquipView"
|
|
self.is_delay_callback = true
|
|
|
|
self.equip_suit_id = 1
|
|
|
|
self.model = RankModel:getInstance()
|
|
self.mainVo = RoleManager.Instance.mainRoleInfo
|
|
|
|
self.equip_item_list = {}
|
|
self.suit_tab_list = {}
|
|
self.data = false
|
|
self.show_role_id = false
|
|
|
|
self:Load()
|
|
end
|
|
|
|
function RankEquipView:Load_callback()
|
|
self:SetAnchoredPosition(0,0)
|
|
self.nodes = {
|
|
"contain/tab_bg:img",
|
|
"contain/equip_conta",
|
|
"contain/tabScroll/Viewport/tab_con",
|
|
"contain/tabScroll:scroll",
|
|
"contain/evilCon",
|
|
"contain/star_tip_btn/star_tip_num:tmp", "contain/suit_btn/suit_num:tmp",
|
|
"contain/suit_btn/suit_text:tmp", "contain/star_tip_btn/star_tip_text:tmp",
|
|
}
|
|
self:GetChildren(self.nodes)
|
|
|
|
self.suit_text_tmp.text = "宝石等级"
|
|
self.star_tip_text_tmp.text = "装备星级"
|
|
|
|
if self.need_refreshData then
|
|
self:SetData(self.data)
|
|
end
|
|
|
|
self:InitEvent()
|
|
|
|
end
|
|
|
|
function RankEquipView:InitEvent()
|
|
|
|
local function OnUpdateEquipInfo(role_id)
|
|
if role_id == self.data.role_id then
|
|
self:UpdateSuitTab()
|
|
end
|
|
end
|
|
self:BindEvent(RankModel:getInstance(), RankModel.UPDATE_EQUIP_INFO, OnUpdateEquipInfo)
|
|
end
|
|
|
|
--根据等级获取展示的最大套数,配置,当前真实代数
|
|
function RankEquipView:GetRoleReinMaxTurn(level)
|
|
local turn = 1--展示最高代(以前的做法,只创建最大套数个tab,现在全部创建出来,所以后面返回最大套数)
|
|
local really_turn = 0--当前真实代数
|
|
local list = {}
|
|
for k,v in ipairs(Config.Equipmentseriesopen) do
|
|
list[k] = v
|
|
-- if v.visible_lv <= level then
|
|
-- turn = v.series > turn and v.series or turn
|
|
-- list[k] = v
|
|
-- end
|
|
if v.open_lv <= level then
|
|
really_turn = really_turn + 1
|
|
end
|
|
end
|
|
return #Config.Equipmentseriesopen,list,really_turn
|
|
end
|
|
|
|
|
|
--更新装备套件标签
|
|
function RankEquipView:UpdateSuitTab( )
|
|
for k,v in pairs(self.suit_tab_list) do
|
|
v:SetVisible(false)
|
|
end
|
|
local len,list,max_suit_id = self:GetRoleReinMaxTurn(self.data.level)
|
|
local equip_list = self.model:GetEquipList(self.show_role_id, self.equip_suit_id)
|
|
|
|
local all_equip_list = self.model:GetAllEquipList(self.show_role_id)
|
|
local all_star_num = 0
|
|
|
|
for k,v in pairs(all_equip_list) do
|
|
for m,n in pairs(v) do
|
|
for p,q in pairs(n.other_data) do
|
|
if q.type == 5 then
|
|
local attr_list = stringtotable(q.info)
|
|
for y,z in pairs(attr_list) do
|
|
local attr_cfg = EquipModel:getInstance():GetEquipmentGreatAttrCfg(z)
|
|
if attr_cfg and attr_cfg.type == 1 then
|
|
all_star_num = all_star_num + 1
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
self.star_tip_num_tmp.text = all_star_num
|
|
|
|
|
|
local active_list = EquipModel:getInstance():GetCurSuitInfo(equip_list)
|
|
if len == 0 then return end
|
|
local function call_back( equip_suit_id )
|
|
self:UpdateSuitState(equip_suit_id)
|
|
self.init_choose_index = false--初始化结束
|
|
end
|
|
local offer_x = 0
|
|
local offer_y = 0
|
|
local x = 0
|
|
local y = 0
|
|
for i=1,max_suit_id do
|
|
local item = self.suit_tab_list[i]
|
|
if item == nil then
|
|
item = RankSuitTab.New(self.tab_con,nil,self.layer_name)
|
|
self.suit_tab_list[i] = item
|
|
item:SetPosition((RankSuitTab.Width - 5) * (i - 1), 0)
|
|
item:SetCallBack(call_back)
|
|
end
|
|
item:SetData(active_list[i],i,list[i],len,nil, self.data.level)
|
|
item:SetVisible(true)
|
|
end
|
|
|
|
SetSizeDeltaX(self.tab_con, (RankSuitTab.Width-5)*max_suit_id+5)
|
|
self.tabScroll_scroll.enabled = max_suit_id > 4
|
|
|
|
local go_suit_id = self.model.now_equip_suit_id
|
|
if self.model.now_equip_suit_id > max_suit_id then
|
|
go_suit_id = max_suit_id
|
|
end
|
|
|
|
self:UpdateSuitState(go_suit_id)
|
|
if go_suit_id <= 3 then
|
|
SetAnchoredPositionX(self.tab_con, 0)
|
|
elseif go_suit_id == 4 then
|
|
SetAnchoredPositionX(self.tab_con, -4)
|
|
elseif go_suit_id == 5 then
|
|
SetAnchoredPositionX(self.tab_con, -89)
|
|
elseif go_suit_id == 6 then
|
|
SetAnchoredPositionX(self.tab_con, -172)
|
|
else
|
|
SetAnchoredPositionX(self.tab_con, 0)
|
|
end
|
|
end
|
|
|
|
function RankEquipView:UpdateSuitState(equip_suit_id)
|
|
self.equip_suit_id = equip_suit_id or self.equip_suit_id
|
|
for k,v in pairs(self.suit_tab_list) do
|
|
v:SetChoose(self.equip_suit_id)
|
|
end
|
|
self:SetEquipData()
|
|
end
|
|
|
|
function RankEquipView:SetData(data)
|
|
self.data = data
|
|
if self.is_loaded then
|
|
self.need_refreshData = false
|
|
if self.show_role_id ~= self.data.role_id then
|
|
self.show_role_id = self.data.role_id
|
|
RankModel:getInstance():Fire(RankModel.REQUEST_EQUIP_CCMD_EVENT,self.show_role_id)
|
|
end
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
|
|
end
|
|
|
|
function RankEquipView:__delete()
|
|
for i,v in ipairs(self.equip_item_list) do
|
|
v:DeleteMe()
|
|
end
|
|
self.equip_item_list = {}
|
|
|
|
for i,v in ipairs(self.suit_tab_list) do
|
|
v:DeleteMe()
|
|
end
|
|
self.suit_tab_list = {}
|
|
|
|
if self.evil_item then
|
|
self.evil_item:DeleteMe()
|
|
end
|
|
end
|
|
|
|
function RankEquipView:GetRowCol(num, col_num)
|
|
local row = 0
|
|
local col = 0
|
|
if col_num and col_num > 0 and num and num > 0 then
|
|
row = math.floor((num - 1) / col_num ) + 1
|
|
col = (num - 1) % col_num +1
|
|
end
|
|
return row, col
|
|
end
|
|
|
|
--设置装备数据
|
|
function RankEquipView:SetEquipData()
|
|
local list = self.model:GetEquipList(self.show_role_id, self.equip_suit_id)
|
|
|
|
local all_gem_lv = 0
|
|
local cur_suit_id_num,suit_equip_pos_list = 0,{}
|
|
local necklace_cur_suit_id_num,necklace_suit_equip_pos_list = 0,{}
|
|
|
|
for m,n in pairs(list) do
|
|
local equip_cfg = EquipModel:getInstance():GetEquipmentCfg(n.type_id)
|
|
if equip_cfg and equip_cfg.color and equip_cfg.color >= 4 and equip_cfg.equip_type ~= EquipModel.EquipType.Guard then--橙色品质才有套装
|
|
if equip_cfg.equip_type >= EquipModel.EquipType.Necklace then
|
|
necklace_cur_suit_id_num = necklace_cur_suit_id_num + 1
|
|
necklace_suit_equip_pos_list[equip_cfg.equip_type] = true
|
|
elseif equip_cfg.equip_type < EquipModel.EquipType.Necklace then
|
|
cur_suit_id_num = cur_suit_id_num + 1
|
|
suit_equip_pos_list[equip_cfg.equip_type] = true
|
|
end
|
|
end
|
|
for p,q in pairs(n.other_data) do
|
|
if q.type == 18 then
|
|
local gem_list = stringtotable(q.info)
|
|
for y,z in pairs(gem_list) do
|
|
local gem_cfg = Config.Equipmentgems[z[2]]
|
|
if gem_cfg then
|
|
all_gem_lv = all_gem_lv + gem_cfg.lv
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
for m,n in pairs(list) do
|
|
n.cur_suit_id_num = cur_suit_id_num
|
|
n.suit_equip_pos_list = suit_equip_pos_list
|
|
n.necklace_cur_suit_id_num = necklace_cur_suit_id_num
|
|
n.necklace_suit_equip_pos_list = necklace_suit_equip_pos_list
|
|
end
|
|
|
|
self.suit_num_tmp.text = all_gem_lv
|
|
|
|
local show_index =
|
|
{
|
|
[1] = {cell = 1,index = 3},
|
|
[2] = {cell = 2,index = 1},
|
|
[3] = {cell = 3,index = 4},
|
|
[4] = {cell = 4,index = 9},
|
|
[5] = {cell = 5,index = 6},
|
|
[6] = {cell = 6,index = 7},
|
|
[7] = {cell = 7,index = 10},
|
|
[8] = {cell = 8,index = 5},
|
|
[9] = {cell = 9,index = 8},
|
|
[10] = {cell = 10,index = 11},
|
|
[11] = {cell = 11,index = 2},
|
|
[12] = {cell = 12,index = 12},
|
|
}
|
|
local index_key_list = {}
|
|
local empty_key_list = {}
|
|
for k,v in pairs(show_index) do
|
|
empty_key_list[v.index] = {}
|
|
empty_key_list[v.index].equip_suit_type = v.cell
|
|
end
|
|
for _,vo in pairs(list) do
|
|
local index = show_index[vo.equip_suit_type] and show_index[vo.equip_suit_type].index or 0
|
|
index_key_list[index] = vo
|
|
end
|
|
local start_x = -147
|
|
local start_y = 207
|
|
local space_x = 105
|
|
local space_y = 102
|
|
for frame_count= 1, 11 do
|
|
local item = self.equip_item_list[frame_count]
|
|
if not item then
|
|
item = RankEquipItem.New(self.equip_conta, nil, self.layer_name)
|
|
self.equip_item_list[frame_count] = item
|
|
item:SetEquipStyle(frame_count)
|
|
local row , col = self:GetRowCol(frame_count + 1, 3)
|
|
if frame_count == 12 then
|
|
item:SetPosition( start_x + (col - 1) * space_x, start_y - (row - 5) * space_y)
|
|
else
|
|
item:SetPosition( start_x + (col - 1) * space_x, start_y - (row - 1) * space_y)
|
|
end
|
|
end
|
|
local vo = index_key_list[frame_count]
|
|
if vo then
|
|
item:SetData(vo,nil,self.show_role_id)
|
|
item:SetPosType(vo.equip_suit_type, false)
|
|
else
|
|
item:ClearData()
|
|
item:SetPosType(empty_key_list[frame_count].equip_suit_type, true)
|
|
end
|
|
-- item:SetBgAlpha((vo and frame_count == 2) and 0 or 1)
|
|
item:SetBgAlpha(1)
|
|
--更新守护模型
|
|
-- if frame_count == 2 then
|
|
-- self:UpdateEvilMomodel(index_key_list[frame_count])
|
|
if frame_count == 12 then
|
|
local mate_info = self.model:GetMateShipData( self.data.role_id )
|
|
if mate_info then
|
|
item:SetRingShow(mate_info.mate_stage,mate_info.mate_star)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function RankEquipView:UpdateEvilMomodel(vo)
|
|
if not self.evil_item then
|
|
self.evil_item = RankBagEvilItem.New(self.evilCon,nil,self.layer_name)
|
|
end
|
|
self.evil_item:SetData(vo and vo.type_id or false)
|
|
end
|