|
RankView = RankView or BaseClass(BaseView)
|
|
local RankView = RankView
|
|
|
|
|
|
--Alert:排行榜页签顺序必须遵循123456递进排序,如果要后面新增排行榜,直接加就行,如果要插入排行榜,务必保证id顺序无误
|
|
--Alert:添加或插入排行榜后,需要同步修改索引的地方如下:
|
|
--RankModel | RankModel.TabId | 索引值,改好后从上到下调好顺序
|
|
--RankView | RankView.TabData | 从上到下调好顺序
|
|
--ConfigRank | Config.ConfigRank.RankTab | 修改id,并从上到下调好顺序
|
|
|
|
RankView.TabData = {
|
|
--前三个页签为开服冲榜专用,不要进行注释屏蔽操作,如果要屏蔽去RankModel:GetFinalRankTabData操作
|
|
{id = RankModel.TabId.KfRush_1, name = "---", abName = "rank_asset", open_lv = GetModuleOpenLevel(221,5) , open_task = 0},
|
|
{id = RankModel.TabId.KfRush_2, name = "---", abName = "rank_asset", open_lv = GetModuleOpenLevel(221,5) , open_task = 0},
|
|
{id = RankModel.TabId.KfRush_3, name = "---", abName = "rank_asset", open_lv = GetModuleOpenLevel(221,5) , open_task = 0},
|
|
|
|
{id = RankModel.TabId.Power, name = "战力", abName = "rank_asset", open_lv = GetModuleOpenLevel(221,1) , open_task = 0},
|
|
{id = RankModel.TabId.Level, name = "等级", abName = "rank_asset", open_lv = GetModuleOpenLevel(221,2) , open_task = 0},
|
|
{id = RankModel.TabId.Equip, name = "装备", abName = "rank_asset", open_lv = GetModuleOpenLevel(221,3) , open_task = 0},
|
|
{id = RankModel.TabId.WarSoul, name = "战魂", abName = "rank_asset", open_lv = GetModuleOpenLevel(221,0) , open_task = 0},
|
|
{id = RankModel.TabId.Advance, name = "进阶", abName = "rank_asset", open_lv = GetModuleOpenLevel(221,5) , open_task = 0},
|
|
{id = RankModel.TabId.AIGirl, name = "AI娘", abName = "rank_asset", open_lv = GetModuleOpenLevel(221,6) , open_task = 0},
|
|
{id = RankModel.TabId.Fashion, name = "收集", abName = "rank_asset", open_lv = GetModuleOpenLevel(221,4) , open_task = 0},
|
|
{id = RankModel.TabId.Charm, name = "魅力", abName = "rank_asset", open_lv = GetModuleOpenLevel(221,7) , open_task = 0},
|
|
}
|
|
|
|
RankView.CSTabData = {
|
|
{id = RankModel.CSTabId.Power, name = "战力", abName = "rank_asset", open_lv = GetModuleOpenLevel(221,1) , open_task = 0},
|
|
{id = RankModel.CSTabId.Level, name = "等级", abName = "rank_asset", open_lv = GetModuleOpenLevel(221,2) , open_task = 0},
|
|
}
|
|
|
|
function RankView:__init()
|
|
self.base_file = "rank"
|
|
self.layout_file = "RankView"
|
|
self.layer_name = "UI"
|
|
self.destroy_imm = true
|
|
self.use_background = true
|
|
self.change_scene_close = true
|
|
|
|
self.model_activity_bg = true
|
|
self.model_activity_bg_pos = Vector2(-294,100)
|
|
|
|
self.full_screen = true
|
|
self.ani_left = -200
|
|
self.ani_right = 200
|
|
|
|
self.hide_maincancas = true --是否隐藏主界面
|
|
self.append_to_ctl_queue = true --是否要添加进界面堆栈
|
|
self.need_show_money = false --是否要显示顶部的金钱栏
|
|
|
|
self.model = RankModel:getInstance()
|
|
|
|
self.need_tab_id = self.model:GetRankSubTypeData(false) --打开界面前获取一次排行榜子类型列表(Config.ConfigRank)
|
|
self.cur_need_tab_data = false
|
|
self.cur_tab_index = 1
|
|
|
|
self.item_list = {} -- 左侧子类型按钮列表
|
|
self.top_item_list = {}
|
|
self.now_select_rank_data = nil -- 当前选中的玩家的排行榜信息
|
|
|
|
self.kf_rush_rank_tab_item_list = {}
|
|
|
|
self.hide_clear_role_model = false
|
|
self.fire_change_visible_event = true
|
|
|
|
self.rank_equip_view = false
|
|
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
end
|
|
self.open_callback = function ( )
|
|
self.tabWindowComponent:SetTabBarIndex(self.current_index or 1,self.current_sub_id or 1)
|
|
self:ShowTabRedPointState()
|
|
end
|
|
self.switch_callback = function(index,sub_id)
|
|
self:SwitchTab(index or 1,sub_id or 1)
|
|
end
|
|
self.close_win_callback = function ( )
|
|
self:Close()
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
|
|
function RankView:Open(index,sub_id)
|
|
self.current_index = index or 1
|
|
self.current_sub_id = sub_id or 1
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function RankView:LoadSuccess()
|
|
local nodes = {
|
|
"winCon",
|
|
"mid/figureCon/figure_bg:raw:obj",
|
|
------ 左边子类型选择栏
|
|
"left/subTypeScrollView/Viewport/subTypeCon:obj",
|
|
"left/kfRankIcon:obj:img",
|
|
"left/kfRankIcon/kfEffect",
|
|
"left/fosterIcon:obj:img",
|
|
------ 中间形象展示栏
|
|
"mid/figureCon:obj",
|
|
"mid/figureCon/equip_con:obj", --装备栏
|
|
"mid/figureCon/warSoul_con:obj", --战魂栏
|
|
"mid/figureCon/role_Con:obj",--模型展示容器
|
|
"mid/figureCon/like_red:obj:imgex",--点赞按钮
|
|
"mid/figureCon/rank_power:txt",--排行分数,不一定就是战力
|
|
"mid/figureCon/like_num:tmp",--点赞数
|
|
|
|
"mid/figureCon/designation_con:obj",--称号栏
|
|
"mid/figureCon/designation_con/designation_image:img:obj",
|
|
"mid/figureCon/designation_con/name_text:tmp",
|
|
"mid/figureCon/designation_con/effect",
|
|
"mid/figureCon/designation_con/designation_small_image:img:obj",
|
|
"mid/figureCon/power_type_label:tmp",
|
|
------ 右侧排行榜栏
|
|
"right/rankCon/my_rank_num:tmp",--排名txt
|
|
"right/rankCon/ScrollView/Viewport/Content","right/rankCon/ScrollView",--排行榜容器
|
|
"right/rankCon/my_rank_power:tmp",--我的当前排行榜类型分数
|
|
"right/emptyCon:obj",
|
|
|
|
"right/rankCon/my_vip_icon", "right/rankCon/my_sex_icon:img", "right/rankCon/my_name:tmp",
|
|
"right/rankCon/topCon",
|
|
"right/rankCon/title_top_bg:img",
|
|
|
|
"left/mainTypeCon:obj",
|
|
"left/mainTypeCon/rankTypeBtn:obj:img", "left/mainTypeCon/csTypeBtn:obj:img",
|
|
"left/mainTypeCon/rankTypeBtn/rankTypeBtnText:tmp", "left/mainTypeCon/csTypeBtn/csBtnText:tmp",
|
|
|
|
"right/tipCon",
|
|
"right/tipCon/refreshTip:tmp",
|
|
|
|
"right/kfRushCon:obj",
|
|
|
|
|
|
}
|
|
self:GetChildren(nodes)
|
|
|
|
self.myVipItem = RoleVipItem.New(self.my_vip_icon)
|
|
|
|
|
|
lua_resM:setOutsideRawImage(self, self.figure_bg_raw, GameResPath.GetRankBg("rank_role_di"))
|
|
lua_resM:setOutsideImageSprite(self, self.title_top_bg_img, GameResPath.GetRankBg("rank_di"))
|
|
|
|
lua_resM:setImageSprite(self, self.kfRankIcon_img, "activityIcon_asset","icon_99_99001")
|
|
lua_resM:setImageSprite(self, self.fosterIcon_img, "activityIcon_asset","icon_146_0_1")
|
|
|
|
|
|
local final_rank_tab_data = self.model:GetFinalRankTabData()
|
|
local now_rank_tab_data = self.model.is_cs_rank and RankView.CSTabData or final_rank_tab_data
|
|
self.need_tab_id = self.model:GetRankSubTypeData(self.model.is_cs_rank)
|
|
self.tabWindowComponent = UITabWindow.New(self.transform,now_rank_tab_data,self.switch_callback,
|
|
self.close_win_callback,self.background_wnd,self.winCon, UITabWindow.SizeLarge, false,6,true)
|
|
self.tabWindowComponent:SetTitleText("排行")
|
|
self.tabWindowComponent:SetUIBack({target = self, bg1 = GameResPath.GetViewBigBg("default_bg_2")})
|
|
-- self:MoveUIToBack(self.figure_bg)
|
|
|
|
self:UpdateMainTypeTabCon()
|
|
|
|
end
|
|
|
|
|
|
|
|
function RankView:UpdateKfRushCon( )
|
|
local rush_tab_list = self.model:GetTodayKfRushTabList()
|
|
if #rush_tab_list == 0 or self.model.is_cs_rank then
|
|
self.kfRushCon_obj:SetActive(false)
|
|
else
|
|
self.kfRushCon_obj:SetActive(true)
|
|
|
|
local function click_call_back(index,sub_id)
|
|
self:SwitchTab(index,sub_id)
|
|
end
|
|
|
|
for k,v in pairs(self.kf_rush_rank_tab_item_list) do
|
|
v:SetVisible(false)
|
|
end
|
|
for i,v in ipairs(rush_tab_list) do
|
|
local item = self.kf_rush_rank_tab_item_list[i]
|
|
if not item then
|
|
item = RankKfRushTabItem.New(self.kfRushCon)
|
|
self.kf_rush_rank_tab_item_list[i] = item
|
|
end
|
|
item:SetVisible(true)
|
|
item:SetData(v,click_call_back)
|
|
if i == 1 then
|
|
item:SetAnchoredPosition(0, 0)
|
|
elseif i == 2 then
|
|
item:SetAnchoredPosition(0, -52)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function RankView:UpdateMainTypeTabCon( )
|
|
if self.model.is_cs_rank then
|
|
lua_resM:setImageSprite(self, self.rankTypeBtn_img, "uiComponent_asset","com_empty")
|
|
lua_resM:setImageSprite(self, self.csTypeBtn_img, "rank_asset","rank_cs_tab_select")
|
|
self.refreshTip_tmp.text = "榜单每<#f3fcff>十分钟</color>刷新一次"
|
|
else
|
|
lua_resM:setImageSprite(self, self.rankTypeBtn_img, "rank_asset","rank_cs_tab_select")
|
|
lua_resM:setImageSprite(self, self.csTypeBtn_img, "uiComponent_asset","com_empty")
|
|
self.refreshTip_tmp.text = "榜单每<#f3fcff>五分钟</color>刷新一次"
|
|
end
|
|
local csTypeBtnMat = self.model.is_cs_rank and ShaderTools.TMPSharedMaterialType.HKYTW7OutlineBlueTab or ShaderTools.TMPSharedMaterialType.HKYTW7FFDefault
|
|
local rankTypeBtnMat = self.model.is_cs_rank and ShaderTools.TMPSharedMaterialType.HKYTW7FFDefault or ShaderTools.TMPSharedMaterialType.HKYTW7OutlineBlueTab
|
|
SetTMPSharedMaterial(self.csBtnText_tmp, csTypeBtnMat)
|
|
SetTMPSharedMaterial(self.rankTypeBtnText_tmp, rankTypeBtnMat)
|
|
|
|
local csBtnColor = self.model.is_cs_rank and "#ffffff" or "#9eb3cf"
|
|
local rankBtnColor = self.model.is_cs_rank and "#9eb3cf" or "#ffffff"
|
|
self.csBtnText_tmp.color = ColorUtil:ConvertHexToRGBColor(csBtnColor)
|
|
self.rankTypeBtnText_tmp.color = ColorUtil:ConvertHexToRGBColor(rankBtnColor)
|
|
|
|
-- self:UpdateKfRushCon()
|
|
end
|
|
|
|
function RankView:AddEvent()
|
|
local on_click = function ( click_obj )
|
|
if self.like_red_obj == click_obj then
|
|
--点赞
|
|
if self.now_select_rank_data then
|
|
if self.model.selectId == 407 then--社团点赞
|
|
self.model:Fire(RankModel.REQUEST_CCMD_EVENT,22104,self.now_select_rank_data.guild_id,self.model.selectId)
|
|
else
|
|
self.model:Fire(RankModel.REQUEST_CCMD_EVENT,22104,self.now_select_rank_data.role_id,self.model.selectId)
|
|
end
|
|
end
|
|
elseif self.rankTypeBtn_obj == click_obj then
|
|
if self.model.is_cs_rank then
|
|
self.model:Fire(RankModel.CHANGE_RANK_MIAN_TYPE)
|
|
end
|
|
elseif self.csTypeBtn_obj == click_obj then
|
|
local is_kf_state = true
|
|
local info = KfWorldModel:GetInstance():GetKfWorldInfo()
|
|
if IsTableEmpty(info) then
|
|
is_kf_state = false
|
|
end
|
|
if info and info.stage and info.stage == 0 then
|
|
is_kf_state = false
|
|
end
|
|
if not is_kf_state then
|
|
Message.show("跨服暂未开启")
|
|
return
|
|
end
|
|
|
|
if not self.model.is_cs_rank then
|
|
self.model:Fire(RankModel.CHANGE_RANK_MIAN_TYPE)
|
|
end
|
|
elseif self.kfRankIcon_obj == click_obj then
|
|
self:Close()
|
|
OpenFun.Open(331,10)
|
|
elseif self.fosterIcon_obj == click_obj then
|
|
if self.model.selectId == 1461 then--座驾
|
|
self:Close()
|
|
OpenFun.Open(146,1)
|
|
elseif self.model.selectId == 1462 then--炫翼
|
|
self:Close()
|
|
OpenFun.Open(146,2)
|
|
elseif self.model.selectId == 1463 then--宝具
|
|
self:Close()
|
|
OpenFun.Open(146,3)
|
|
elseif self.model.selectId == 1464 then--武器
|
|
self:Close()
|
|
OpenFun.Open(146,4)
|
|
elseif self.model.selectId == 1465 then--AI娘
|
|
self:Close()
|
|
OpenFun.Open(146,5)
|
|
elseif self.model.selectId == 1466 then--磁炮
|
|
self:Close()
|
|
OpenFun.Open(146,6)
|
|
elseif self.model.selectId == 1467 then--星翼
|
|
self:Close()
|
|
OpenFun.Open(146,7)
|
|
elseif self.model.selectId == 1468 then--幻甲
|
|
self:Close()
|
|
OpenFun.Open(146,8)
|
|
end
|
|
-- self:Close()
|
|
end
|
|
end
|
|
AddClickEvent(self.like_red_obj, on_click)
|
|
AddClickEvent(self.rankTypeBtn_obj, on_click)
|
|
AddClickEvent(self.csTypeBtn_obj, on_click)
|
|
AddClickEvent(self.kfRankIcon_obj, on_click)
|
|
AddClickEvent(self.fosterIcon_obj, on_click)
|
|
|
|
--切换跨服排行和本服排行
|
|
local function on_change_rank_main_type()
|
|
if self.tabWindowComponent then
|
|
self.tabWindowComponent:DeleteMe()
|
|
self.tabWindowComponent = nil
|
|
end
|
|
|
|
self.model.is_cs_rank = not self.model.is_cs_rank
|
|
local final_rank_tab_data = self.model:GetFinalRankTabData()
|
|
local now_rank_tab_data = self.model.is_cs_rank and RankView.CSTabData or final_rank_tab_data
|
|
self.need_tab_id = self.model:GetRankSubTypeData(self.model.is_cs_rank)
|
|
self.tabWindowComponent = UITabWindow.New(self.transform,now_rank_tab_data,self.switch_callback,
|
|
self.close_win_callback,self.background_wnd,self.winCon, UITabWindow.SizeLarge, false,6,true)
|
|
self.tabWindowComponent:SetTitleText("排行")
|
|
self.tabWindowComponent:SetUIBack({target = self, bg1 = GameResPath.GetViewBigBg("default_bg_2")})
|
|
-- self:MoveUIToBack(self.figure_bg)
|
|
|
|
self:ShowTabRedPointState()
|
|
|
|
--清空当前榜单信息,重新请求协议
|
|
self.model.selectId = 0
|
|
self.model.rank_info = nil
|
|
self.tabWindowComponent:SetTabBarIndex(1,1)
|
|
self:UpdateMainTypeTabCon()
|
|
end
|
|
self:BindEvent(self.model,RankModel.CHANGE_RANK_MIAN_TYPE,on_change_rank_main_type)
|
|
|
|
|
|
--刷新排行列表 每次打开一个榜单时都会请求协议刷新列表
|
|
local function on_update_rank_content()
|
|
self:CreateRankItems()
|
|
end
|
|
self:BindEvent(self.model,RankModel.UPDATE_RANK_CONTENT,on_update_rank_content)
|
|
|
|
--刷新点赞栏状态
|
|
local function on_update_like_con()
|
|
if self.model.selectId and self.now_select_rank_data then
|
|
local is_liked = self.model:GetRankLikeStateByTypeId(self.model.selectId, self.now_select_rank_data.role_id)
|
|
self.like_red_imgex.gray = not is_liked
|
|
end
|
|
end
|
|
self:BindEvent(self.model,RankModel.UPDATE_LIKE_CON,on_update_like_con)
|
|
|
|
--刷新点赞数
|
|
local function on_update_rank_like_num(rank_type,role_id,praise_num)
|
|
if self.model.selectId == 407 then
|
|
if rank_type == self.model.selectId and self.now_select_rank_data and self.now_select_rank_data.guild_id == role_id then
|
|
self.like_num_tmp.text = praise_num
|
|
end
|
|
else
|
|
if rank_type == self.model.selectId and self.now_select_rank_data and self.now_select_rank_data.role_id == role_id then
|
|
self.like_num_tmp.text = praise_num
|
|
end
|
|
end
|
|
|
|
end
|
|
self:BindEvent(self.model,RankModel.UPDATE_LIKE_NUM,on_update_rank_like_num)
|
|
|
|
--刷新跨服人物形象展示
|
|
local function on_update_cs_role_show(vo)
|
|
if self.model.is_cs_rank and self.now_select_rank_data and self.now_select_rank_data.player_id and self.now_select_rank_data.player_id == vo.role_id then
|
|
self:UpdateCSRoleShow(vo)
|
|
end
|
|
end
|
|
self:BindEvent(self.model,RankModel.UPDATE_CS_ROLE_SHOW,on_update_cs_role_show)
|
|
|
|
local function on_ans_update_red_dot()
|
|
self:ShowTabRedPointState()
|
|
end
|
|
self:BindEvent(self.model, RankModel.ANS_UPDATE_RED_DOT, on_ans_update_red_dot)
|
|
|
|
local function ChangeVisible( flag )
|
|
if not flag then
|
|
return
|
|
end
|
|
self:UpdateRoleShow(self.now_choose_rank_item_index)
|
|
end
|
|
self:BindEvent(GlobalEventSystem, BaseView.ChangeVisible, ChangeVisible)
|
|
end
|
|
|
|
function RankView:ShowTabRedPointState()
|
|
if self.model.is_cs_rank then
|
|
for k,v in pairs(Config.ConfigRank.CSRankTab) do
|
|
self.tabWindowComponent:ShowRedPoint(v.id, false)
|
|
end
|
|
else
|
|
local red_info = self.model:GetAllRedDot()
|
|
for k,v in pairs(Config.ConfigRank.RankTab) do
|
|
if v.id >= 1 and v.id <= 3 then
|
|
self.tabWindowComponent:ShowRedPoint(v.id, false)
|
|
else
|
|
self.tabWindowComponent:ShowRedPoint(v.id, red_info[v.id])
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--创建排行榜列表并自动选中第一位,展示第一位的形象
|
|
function RankView:CreateRankItems()
|
|
local rank_info = self.model.rank_info
|
|
|
|
if rank_info == nil then
|
|
return
|
|
end
|
|
|
|
local top_data = {}
|
|
if self.model.is_cs_rank then
|
|
for i=1,3 do
|
|
if rank_info.top_three and rank_info.top_three[i] then
|
|
table.insert(top_data,rank_info.top_three[i])
|
|
else
|
|
local temp = {empty_data = true}
|
|
table.insert(top_data,temp)
|
|
end
|
|
end
|
|
else
|
|
for i=1,3 do
|
|
if rank_info.rank_list and rank_info.rank_list[i] then
|
|
table.insert(top_data,rank_info.rank_list[i])
|
|
else
|
|
local temp = {empty_data = true}
|
|
table.insert(top_data,temp)
|
|
end
|
|
end
|
|
end
|
|
|
|
for k,v in pairs(self.top_item_list) do
|
|
v:SetVisible(false)
|
|
end
|
|
for i,v in ipairs(top_data) do
|
|
local item = self.top_item_list[i]
|
|
if not item then
|
|
item = RankTopItem.New(self.topCon)
|
|
self.top_item_list[i] = item
|
|
end
|
|
item:SetVisible(true)
|
|
item:SetData(v,i)
|
|
if i == 1 then
|
|
item:SetAnchoredPosition(168, -14)
|
|
elseif i == 2 then
|
|
item:SetAnchoredPosition(-2, -14)
|
|
elseif i == 3 then
|
|
item:SetAnchoredPosition(338, -14)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
local tar_index = 1
|
|
|
|
local update_item_fun = function (item, i, v)
|
|
local call_back = function (index)
|
|
tar_index = index
|
|
self:UpdateRoleShow(index)
|
|
self:UpdateEquipCon(index)
|
|
self:UpdateWarSoulCon(index)
|
|
self.rankitem_list_com:IterateItems(function( item, i )
|
|
item:SetSelect(i == tar_index)
|
|
end)
|
|
end
|
|
item:SetData(i,v,call_back, self.cur_need_tab_data, self.cur_tab_index)
|
|
item:SetSelect(i == tar_index)
|
|
end
|
|
|
|
self.rankitem_list_com = self.rankitem_list_com or self:AddUIComponent(UI.ItemListCreator)
|
|
|
|
self.rankitem_list_com:Reset()
|
|
local rankitem_all_info = {
|
|
data_list = rank_info.rank_list,
|
|
item_con = self.Content,
|
|
item_class = RankItem,
|
|
item_width = 511,
|
|
item_height = 51,
|
|
space_x = 0,
|
|
space_y = 0,
|
|
scroll_view = self.ScrollView,
|
|
create_frequency = 0.01,
|
|
reuse_item_num = 16,
|
|
on_update_item = update_item_fun,
|
|
}
|
|
self.rankitem_list_com:UpdateItems(rankitem_all_info)
|
|
|
|
--默认选中
|
|
if rank_info.rank_list[1] then
|
|
self.figureCon_obj:SetActive(true)
|
|
self.emptyCon_obj:SetActive(false)
|
|
self:UpdateRoleShow(1)
|
|
self:UpdateEquipCon(1)
|
|
self:UpdateWarSoulCon(1)
|
|
else
|
|
self.figureCon_obj:SetActive(false)
|
|
self.emptyCon_obj:SetActive(true)
|
|
end
|
|
|
|
--刷新个人排行栏
|
|
self:UpdateMyRank(rank_info)
|
|
end
|
|
|
|
--刷新我的排名栏
|
|
function RankView:UpdateMyRank(rank_info)
|
|
--自己的排行分数
|
|
local rank_score = 0
|
|
rank_score = rank_info.sel_val
|
|
|
|
self.myVipItem:SetData(RoleManager.Instance.mainRoleInfo.vip_flag,RoleManager.Instance.mainRoleInfo.sup_vip_type)
|
|
if self.model.is_cs_rank then
|
|
self.my_name_tmp.text = GetCSLongName(RoleManager.Instance.mainRoleInfo.name, RoleManager.Instance.mainRoleInfo.server_num)
|
|
else
|
|
self.my_name_tmp.text = RoleManager.Instance.mainRoleInfo.name
|
|
end
|
|
lua_resM:setImageSprite(self, self.my_sex_icon_img, "common_asset", RoleManager.Instance.mainRoleInfo.sex == 1 and "com_boy" or "com_girl",true)
|
|
local pos_x, pox_y = GetAnchoredPosition(self.my_name)
|
|
SetAnchoredPositionX(self.my_sex_icon,pos_x + self.my_name_tmp.preferredWidth -18)
|
|
|
|
--排名
|
|
if rank_info.role_rank >= 1 then
|
|
self.my_rank_num_tmp.fontSize = 22
|
|
self.my_rank_num_tmp.text = rank_info.role_rank
|
|
elseif rank_info.role_rank == 0 then
|
|
self.my_rank_num_tmp.fontSize = 16
|
|
self.my_rank_num_tmp.text = "榜外"
|
|
end
|
|
|
|
if self.model.selectId >= 2000 and self.model.selectId <= 2004 then--战力榜
|
|
self.my_rank_power_tmp.text = "战力:"..rank_score
|
|
elseif self.model.selectId >= 3000 and self.model.selectId <= 3004 then--等级榜
|
|
self.my_rank_power_tmp.text = "等级:"..rank_score
|
|
elseif self.model.selectId >= 1520 and self.model.selectId <= 1524 then--装备榜
|
|
self.my_rank_power_tmp.text = "战力:"..rank_score
|
|
elseif self.model.selectId == 411 or self.model.selectId == 413 or self.model.selectId == 112 then--称号&时装&聊天装扮
|
|
local my_suit_num = 0
|
|
if rank_info.sel_sec_val then
|
|
my_suit_num = rank_info.sel_sec_val
|
|
end
|
|
if self.model.selectId == 112 then
|
|
my_suit_num = rank_info.sel_val
|
|
end
|
|
self.my_rank_power_tmp.text = "收集数:"..my_suit_num
|
|
elseif self.model.selectId >= 1461 and self.model.selectId <= 1464 then--进阶
|
|
local foster_type_id = self.model.selectId - 1460
|
|
local my_grade, my_star = FosterModel:getInstance():GetGradeStarByType(foster_type_id)
|
|
self.my_rank_power_tmp.text = string.format(" %s阶%s星", my_grade, my_star)
|
|
elseif self.model.selectId >= 1465 and self.model.selectId <= 1468 then--ai娘
|
|
self.my_rank_power_tmp.text = "等级:"..rank_info.sel_sec_val
|
|
elseif self.model.selectId == 2231 then--人气值
|
|
self.my_rank_power_tmp.text = "人气:"..rank_score
|
|
elseif self.model.selectId == 2232 then--壕气值
|
|
self.my_rank_power_tmp.text = "壕气:"..rank_score
|
|
elseif self.model.selectId == 143 then--战魂
|
|
self.my_rank_power_tmp.text = "战力:"..rank_score
|
|
elseif self.model.selectId == 14600 then--进阶战力榜
|
|
self.my_rank_power_tmp.text = "战力:"..rank_score
|
|
elseif self.model.selectId == 14601 then--ai娘战力榜
|
|
self.my_rank_power_tmp.text = "战力:"..rank_score
|
|
end
|
|
end
|
|
|
|
--选中rankitem后展示形象的总入口
|
|
function RankView:UpdateRoleShow(index)
|
|
if not self.model.rank_info then return end
|
|
if not self.model.rank_info.rank_list then return end
|
|
local rank_data = self.model.rank_info.rank_list[index] -- 拿到排行榜数据列表
|
|
if not rank_data then return end
|
|
|
|
self.now_select_rank_data = rank_data
|
|
|
|
self.now_choose_rank_item_index = index
|
|
|
|
if self.model.is_cs_rank then--跨服排行榜不能直接拿到figure数据,需要单独请求
|
|
local cs_role_id = rank_data.player_id
|
|
self.model:Fire(RankModel.REQUEST_CCMD_EVENT, 22109, cs_role_id)
|
|
return
|
|
end
|
|
|
|
self:UpdateRankPower(rank_data)--形象栏战力 (跨服等级榜拿了figure再执行)
|
|
self:UpdateNameCon(rank_data)--名字栏
|
|
self:UpdateLikeCon(rank_data)--点赞栏 (跨服榜隐藏)
|
|
|
|
|
|
self.role_Con_obj:SetActive(true)
|
|
self.figure_bg_obj:SetActive(false)
|
|
|
|
if self.model.selectId >= 2000 and self.model.selectId <= 2004 then--战力榜
|
|
self:UpdateFigureShow(rank_data)--刷新人物模型
|
|
elseif self.model.selectId >= 3000 and self.model.selectId <= 3004 then--等级榜
|
|
self:UpdateFigureShow(rank_data)--刷新人物模型
|
|
elseif self.model.selectId >= 1520 and self.model.selectId <= 1524 then--装备榜
|
|
self.role_Con_obj:SetActive(false)--隐藏人物con
|
|
-- self.figure_bg_obj:SetActive(true)
|
|
elseif self.model.selectId == 411 or self.model.selectId == 413 or self.model.selectId == 112 then--称号&时装&聊天装扮
|
|
self:UpdateFigureShow(rank_data)--刷新人物模型
|
|
elseif self.model.selectId == 163 then--孩子
|
|
self:UpdateOtherFigureShow(rank_data)--刷新非人模型
|
|
elseif self.model.selectId >= 1461 and self.model.selectId <= 1468 then--进阶
|
|
self:UpdateOtherFigureShow(rank_data)--刷新非人模型
|
|
elseif self.model.selectId >= 2231 and self.model.selectId <= 2232 then--魅力
|
|
self:UpdateFigureShow(rank_data)--刷新人物模型
|
|
elseif self.model.selectId == 143 then--战魂
|
|
self.role_Con_obj:SetActive(false)--隐藏人物con
|
|
elseif self.model.selectId == 14600 then--进阶战力榜
|
|
self:UpdateFigureShow(rank_data)--刷新人物模型
|
|
elseif self.model.selectId == 14601 then--ai娘战力榜
|
|
self:UpdateOtherFigureShow(rank_data)--刷新非人模型
|
|
end
|
|
end
|
|
|
|
function RankView:UpdateCSRoleShow(vo)
|
|
self.role_Con_obj:SetActive(true)
|
|
self.figure_bg_obj:SetActive(false)
|
|
self:UpdateRankPower(self.now_select_rank_data,vo)--形象栏战力 (跨服等级榜拿了figure再执行)
|
|
self:UpdateLikeCon(self.now_select_rank_data)--点赞栏 (跨服榜隐藏)
|
|
if self.model.selectId >= 2000 and self.model.selectId <= 2004 then--战力榜
|
|
self:UpdateFigureShow(vo)--刷新人物模型
|
|
elseif self.model.selectId >= 3000 and self.model.selectId <= 3004 then--等级榜
|
|
self:UpdateFigureShow(vo)--刷新人物模型
|
|
end
|
|
end
|
|
|
|
function RankView:UpdateEquipCon(index)
|
|
if self.model.selectId >= 1520 and self.model.selectId <= 1524 then--装备榜 then
|
|
self.equip_con_obj:SetActive(true)
|
|
else
|
|
self.equip_con_obj:SetActive(false)
|
|
return
|
|
end
|
|
local rank_data = self.model.rank_info.rank_list[index] -- 拿到排行榜数据列表
|
|
self.now_select_rank_data = rank_data
|
|
if not self.rank_equip_view then
|
|
self.rank_equip_view = RankEquipView.New(self.equip_con)
|
|
end
|
|
self.rank_equip_view:SetData(self.now_select_rank_data)
|
|
end
|
|
|
|
function RankView:UpdateWarSoulCon(index)
|
|
if self.model.selectId == 143 then
|
|
self.warSoul_con_obj:SetActive(true)
|
|
else
|
|
self.warSoul_con_obj:SetActive(false)
|
|
return
|
|
end
|
|
local rank_data = self.model.rank_info.rank_list[index] -- 拿到排行榜数据列表
|
|
self.now_select_rank_data = rank_data
|
|
if not self.rank_warSoul_view then
|
|
self.rank_warSoul_view = RankWarSoulView.New(self.warSoul_con)
|
|
end
|
|
self.rank_warSoul_view:SetAnchoredPosition(-15,0)
|
|
self.rank_warSoul_view:SetData(rank_data)
|
|
end
|
|
|
|
--刷新称号栏
|
|
function RankView:UpdateNameCon(rank_data)
|
|
self.designation_con_obj:SetActive(false)
|
|
|
|
if self.model.selectId >= 2000 and self.model.selectId <= 2004 --战力榜
|
|
or self.model.selectId >= 3000 and self.model.selectId <= 3004 --等级榜
|
|
or self.model.selectId == 2231 --人气值
|
|
or self.model.selectId == 407 --社团
|
|
or self.model.selectId == 2232 then--壕气值
|
|
--无
|
|
elseif self.model.selectId >= 1520 and self.model.selectId <= 1524 then --装备榜
|
|
--无
|
|
elseif self.model.selectId == 411 or self.model.selectId == 413 or self.model.selectId == 112 then--称号&时装&聊天装扮
|
|
self.designation_con_obj:SetActive(true)
|
|
self.designation_small_image_obj:SetActive(false)
|
|
self.designation_image_obj:SetActive(false)
|
|
self.name_text_tmp.text = ""
|
|
|
|
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.designation_image)
|
|
local dsgt_cfg = Config.Dsgt[rank_data.dsgt_id]
|
|
if self.dynamic_image_obj then
|
|
self.dynamic_image_obj:SetActive(false)
|
|
end
|
|
if dsgt_cfg then
|
|
if dsgt_cfg.type == 1 then--文字称号(文字称号也用图片了)
|
|
lua_resM:setOutsideImageSprite(self, self.designation_small_image_img, GameResPath.GetDesignImage(dsgt_cfg.id), true)
|
|
self.designation_small_image_obj:SetActive(true)
|
|
elseif dsgt_cfg.type == 2 then
|
|
lua_resM:setOutsideImageSprite(self, self.designation_image_img, GameResPath.GetDesignImage(dsgt_cfg.id), true)
|
|
self.designation_image_obj:SetActive(true)
|
|
elseif dsgt_cfg.type == 3 then
|
|
if not self.dynamic_image_obj then
|
|
self.dynamic_image_obj = UiFactory.createChild(self.designation_image, UIType.Image, "dynamic_image")
|
|
self.dynamic_image_img = self.dynamic_image_obj:GetComponent("Image")
|
|
self.dynamic_image = self.dynamic_image_obj.transform
|
|
SetAnchoredPosition(self.dynamic_image,0,0)
|
|
else
|
|
self.dynamic_image_obj:SetActive(true)
|
|
end
|
|
SetSizeDelta(self.designation_image, 210*0.8,90*0.8)
|
|
self.designation_image_obj:SetActive(true)
|
|
local data = DeepCopy(DesignationModel:GetInstance():GetDynamicDesignationCFG(dsgt_cfg.id))
|
|
for i,v in ipairs(data) do
|
|
v.not_auto_size = true
|
|
end
|
|
local res = Split(data[1].res,"_")--分割出来配置 然后取文字
|
|
local font_res = res[1] or ""
|
|
lua_resM:setImageSprite(self, self.dynamic_image_img, data[1].ab, font_res.."_font", false)
|
|
local action = cc.Animation.New(data,0.15)
|
|
cc.ActionManager:getInstance():addAction(cc.RepeatForever.New(action),self.designation_image.transform)
|
|
end
|
|
end
|
|
elseif self.model.selectId == 143 then--战魂
|
|
--无
|
|
elseif self.model.selectId >= 1461 and self.model.selectId <= 1468 then--进阶
|
|
--无
|
|
elseif self.model.selectId == 14600 then--进阶战力榜
|
|
--无
|
|
elseif self.model.selectId == 14601 then--ai娘战力榜
|
|
--无
|
|
end
|
|
end
|
|
|
|
function RankView:GetFosterName(pet_type,id)
|
|
local foster_type = pet_type - 1460
|
|
for k,v in pairs(Config.Foster) do
|
|
if foster_type == v.type and id == v.grade then
|
|
return Trim(v.name)
|
|
end
|
|
end
|
|
return "暂无数据"
|
|
end
|
|
|
|
function RankView:GetFosterResource(pet_type,id)
|
|
id = id > 10 and 10 or id
|
|
local foster_type = pet_type - 1460
|
|
for k,v in pairs(Config.Foster) do
|
|
if foster_type == v.type and id == v.grade then
|
|
return v.resource
|
|
end
|
|
end
|
|
return 1000
|
|
end
|
|
|
|
--刷新点赞栏
|
|
function RankView:UpdateLikeCon(rank_data)
|
|
if self.model.is_cs_rank then
|
|
self.like_red_obj:SetActive(false)
|
|
self.like_num_tmp.text = ""
|
|
else
|
|
self.like_red_obj:SetActive(true)
|
|
local is_liked = self.model:GetRankLikeStateByTypeId(self.model.selectId, self.now_select_rank_data.role_id)
|
|
self.like_red_imgex.gray = not is_liked
|
|
self.like_num_tmp.text = rank_data.praise_num
|
|
end
|
|
end
|
|
|
|
--刷新排行榜分数栏
|
|
function RankView:UpdateRankPower(rank_data,figure)
|
|
local power_type_label = "战力"
|
|
if not self.model.is_cs_rank then
|
|
if self.model.selectId >= 2000 and self.model.selectId <= 2004 then--战力榜
|
|
self.rank_power_txt.text = rank_data.first_value
|
|
elseif self.model.selectId >= 3000 and self.model.selectId <= 3004 then--等级榜
|
|
self.rank_power_txt.text = rank_data.power
|
|
elseif self.model.selectId >= 1520 and self.model.selectId <= 1524 then--装备榜
|
|
self.rank_power_txt.text = rank_data.first_value
|
|
elseif self.model.selectId == 411 or self.model.selectId == 413 or self.model.selectId == 112 then--称号&时装&聊天装扮
|
|
self.rank_power_txt.text = rank_data.second_value
|
|
elseif self.model.selectId >= 1461 and self.model.selectId <= 1468 then--进阶和ai娘
|
|
self.rank_power_txt.text = rank_data.third_value
|
|
local rank_tab_data = self.model:GetRankTabDataByType(self.model.selectId)
|
|
if rank_tab_data then
|
|
power_type_label = rank_tab_data.name.."战力"
|
|
end
|
|
elseif self.model.selectId == 2231 then--人气值
|
|
self.rank_power_txt.text = rank_data.power
|
|
elseif self.model.selectId == 2232 then--壕气值
|
|
self.rank_power_txt.text = rank_data.power
|
|
elseif self.model.selectId == 143 then--战魂
|
|
self.rank_power_txt.text = rank_data.first_value
|
|
elseif self.model.selectId == 14600 then--进阶战力榜
|
|
self.rank_power_txt.text = rank_data.first_value
|
|
elseif self.model.selectId == 14601 then--ai娘战力榜
|
|
self.rank_power_txt.text = rank_data.first_value
|
|
end
|
|
elseif self.model.is_cs_rank and figure then
|
|
if self.model.selectId >= 2000 and self.model.selectId <= 2004 then--战力榜
|
|
self.rank_power_txt.text = rank_data.first_value
|
|
elseif self.model.selectId >= 3000 and self.model.selectId <= 3004 then--等级榜
|
|
self.rank_power_txt.text = figure.power
|
|
end
|
|
end
|
|
|
|
if self.model.selectId >= 1461 and self.model.selectId <= 1468 then
|
|
SetAnchoredPositionX(self.rank_power, 55)
|
|
SetAnchoredPositionX(self.power_type_label, 55 - self.rank_power_txt.preferredWidth/2 -25 )
|
|
else
|
|
SetAnchoredPositionX(self.rank_power, 32)
|
|
SetAnchoredPositionX(self.power_type_label, 32 - self.rank_power_txt.preferredWidth/2 -25 )
|
|
end
|
|
|
|
self.power_type_label_tmp.text = power_type_label
|
|
end
|
|
|
|
--展示人物模型(战力等级装备外观魅力等榜都需要展示人物模型)
|
|
function RankView:UpdateFigureShow(rank_data)
|
|
if self.model.selectId == 14600 then--进阶总战力榜 人物身上的翅膀武器宝具要替换成阶数对应的
|
|
local f_grade_data = stringtotable(rank_data.extra_values)
|
|
local talisman_id = nil
|
|
local wing_id = nil
|
|
local weapon_res_id = nil
|
|
if f_grade_data then
|
|
for k,v in pairs(f_grade_data) do
|
|
if v[1] == FosterConst.ModuleId.FWing then--炫翼
|
|
wing_id = self:GetFosterResource(v[1]+1460,v[2])
|
|
elseif v[1] == FosterConst.ModuleId.FPearl then--宝具
|
|
talisman_id = self:GetFosterResource(v[1]+1460,v[2])
|
|
elseif v[1] == FosterConst.ModuleId.FWeapon then--武器
|
|
weapon_res_id = GameResPath:GetFWeaponResName( rank_data.career,self:GetFosterResource(v[1]+1460,v[2]) )
|
|
end
|
|
end
|
|
end
|
|
local res_data = {
|
|
father_node = self,
|
|
transform = self.role_Con,
|
|
fashion_type = FuncOpenModel.TypeId.Clothes,
|
|
role_vo = rank_data,
|
|
scale = 255,
|
|
raycast_size = Vector2(340,460),
|
|
ui_model_type = UIModelCommon.ModelType.BackModel,
|
|
talisman_id = talisman_id,
|
|
wing_id = wing_id,
|
|
weapon_res_id = weapon_res_id,
|
|
light_id = rank_data.light_id,
|
|
-- position = Vector3(0,30,0)
|
|
}
|
|
FuncOpenModel:getInstance():SetModelRes(res_data)
|
|
else
|
|
local talisman_id = GetTalismanClotheId(rank_data)
|
|
local res_data = {
|
|
father_node = self,
|
|
transform = self.role_Con,
|
|
fashion_type = FuncOpenModel.TypeId.Clothes,
|
|
role_vo = rank_data,
|
|
scale = 255,
|
|
raycast_size = Vector2(340,460),
|
|
ui_model_type = UIModelCommon.ModelType.BackModel,
|
|
talisman_id = talisman_id,
|
|
light_id = rank_data.light_id,
|
|
-- position = Vector3(0,30,0)
|
|
}
|
|
FuncOpenModel:getInstance():SetModelRes(res_data)
|
|
end
|
|
end
|
|
|
|
--展示非人物模型
|
|
function RankView:UpdateOtherFigureShow(rank_data)
|
|
if self.model.selectId == 14601 then--ai娘战力榜 这个榜要展示ai娘的全套装备,要传一个show_jarvis_all_figure_data进去
|
|
|
|
local f_grade_data = stringtotable(rank_data.extra_values)
|
|
local show_jarvis_all_figure_data = nil
|
|
if f_grade_data then
|
|
show_jarvis_all_figure_data = {}
|
|
for k,v in pairs(f_grade_data) do
|
|
if v[1] == FosterConst.ModuleId.FJarvis then--AI娘
|
|
show_jarvis_all_figure_data.f_jarvis_figure_id = self:GetFosterResource(v[1]+1460,v[2])
|
|
elseif v[1] == FosterConst.ModuleId.FGun then--磁炮
|
|
show_jarvis_all_figure_data.f_gun_figure_id = self:GetFosterResource(v[1]+1460,v[2])
|
|
elseif v[1] == FosterConst.ModuleId.FCloud then--星翼
|
|
show_jarvis_all_figure_data.f_cloud_figure_id = self:GetFosterResource(v[1]+1460,v[2])
|
|
elseif v[1] == FosterConst.ModuleId.FArmour then--幻甲
|
|
show_jarvis_all_figure_data.f_armour_figure_id = self:GetFosterResource(v[1]+1460,v[2])
|
|
end
|
|
end
|
|
end
|
|
|
|
local res_data = {
|
|
father_node = self,
|
|
transform = self.role_Con,
|
|
fashion_type = 1005,
|
|
figure_id = show_jarvis_all_figure_data and show_jarvis_all_figure_data.f_jarvis_figure_id or 0,
|
|
show_jarvis_all_figure_data = show_jarvis_all_figure_data,
|
|
-- scale = 255,
|
|
raycast_size = Vector2(340,460),
|
|
ui_model_type = UIModelCommon.ModelType.BackModel,
|
|
}
|
|
FuncOpenModel:getInstance():SetModelRes(res_data)
|
|
else
|
|
local res_data = {
|
|
father_node = self,
|
|
transform = self.role_Con,
|
|
fashion_type = self.model.selectId-1460+1000,
|
|
figure_id = self:GetFosterResource(self.model.selectId,rank_data.first_value),
|
|
career = rank_data.career,
|
|
-- scale = 255,
|
|
raycast_size = Vector2(340,460),
|
|
ui_model_type = UIModelCommon.ModelType.BackModel,
|
|
}
|
|
FuncOpenModel:getInstance():SetModelRes(res_data)
|
|
end
|
|
end
|
|
|
|
|
|
--切换页签时候同时切换到该榜单的子类型榜单
|
|
function RankView:SwitchTab(index,sub_id)
|
|
--先创建子类型列表
|
|
for k,v in pairs(self.item_list) do
|
|
v:SetVisible(false)
|
|
end
|
|
|
|
--要是传进来的index所属的排行榜未开放,换一个榜显示
|
|
if not self.need_tab_id[index] then
|
|
-- local new_index = 0
|
|
-- for k,v in pairs(self.need_tab_id) do
|
|
-- new_index = v.id
|
|
-- end
|
|
-- if new_index ~= 0 then
|
|
-- index = new_index
|
|
-- else
|
|
-- return
|
|
-- end
|
|
index = RankModel.TabId.Power
|
|
end
|
|
self.cur_tab_index = index
|
|
self:DoOpenAni(index)
|
|
self.tabWindowComponent:SetTabBarIndex(self.cur_tab_index,false,true)
|
|
|
|
local function call_back(data)
|
|
self.cur_need_tab_data = data
|
|
if self.model.selectId == 407 then
|
|
self.subTypeCon_obj:SetActive(false)
|
|
else
|
|
self.subTypeCon_obj:SetActive(true)
|
|
end
|
|
end
|
|
for i,v in ipairs(self.need_tab_id[index].sub_tab) do
|
|
local item = self.item_list[i]
|
|
if not item then
|
|
item = RankSubTypeItem.New(self.subTypeCon)
|
|
self.item_list[i] = item
|
|
end
|
|
if self.model.is_cs_rank then
|
|
item:SetVisible(true)
|
|
else
|
|
item:SetVisible(index > 3)
|
|
end
|
|
item:SetData(i,v,call_back,self.cur_tab_index)
|
|
item:OnClick(sub_id)
|
|
end
|
|
|
|
self.kfRankIcon_obj:SetActive(index <= 3 and not self.model.is_cs_rank)
|
|
self:AddUIEffect("ui_bianqiang", self.kfEffect, self.layer_name, nil, {x=1,y=1}, true, nil,nil,nil,nil,nil)
|
|
|
|
self.fosterIcon_obj:SetActive(index <= 3 and not self.model.is_cs_rank)
|
|
|
|
if self.model.is_cs_rank then
|
|
self.mainTypeCon_obj:SetActive(true)
|
|
else
|
|
self.mainTypeCon_obj:SetActive(index > 3)
|
|
end
|
|
|
|
|
|
SetSizeDeltaY(self.subTypeCon, 72*#self.need_tab_id[index].sub_tab+2)
|
|
end
|
|
|
|
function RankView:DestroySuccess( )
|
|
|
|
self.model:Reset()
|
|
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.designation_image)
|
|
|
|
self:ClearUIEffect(self.kfEffect)
|
|
|
|
if self.tabWindowComponent then
|
|
self.tabWindowComponent:DeleteMe()
|
|
self.tabWindowComponent = nil
|
|
end
|
|
|
|
for i, v in ipairs(self.item_list) do
|
|
v:DeleteMe()
|
|
end
|
|
self.item_list = {}
|
|
|
|
for i, v in ipairs(self.kf_rush_rank_tab_item_list) do
|
|
v:DeleteMe()
|
|
end
|
|
self.kf_rush_rank_tab_item_list = {}
|
|
|
|
for i, v in ipairs(self.top_item_list) do
|
|
v:DeleteMe()
|
|
end
|
|
self.top_item_list = {}
|
|
|
|
if self.rank_equip_view then
|
|
self.rank_equip_view:DeleteMe()
|
|
self.rank_equip_view = nil
|
|
end
|
|
|
|
if self.rank_warSoul_view then
|
|
self.rank_warSoul_view:DeleteMe()
|
|
self.rank_warSoul_view = nil
|
|
end
|
|
|
|
if self.myVipItem then
|
|
self.myVipItem:DeleteMe()
|
|
self.myVipItem = nil
|
|
end
|
|
|
|
end
|