local UICommandTheWorldMain = UIViewClass() local ScenePath = ConstAssetPathConfig.ScenePath local ItemIconPath = ConstAssetPathConfig.ItemIconPath local LocalSeverTabIndex = 1 --本服排行Tab索引 local BattleAreaTabIndex = 2 --战区排行Tab索引 --势力宝箱和小兵ID对应列表 local BoxLevelAndMonsterModelId = MDL.CommandTheWorld.BoxLevelAndMonsterModelId --region 生命周期方法 function UICommandTheWorldMain:OnOpened(context) UIManager.ActiveUIModle(false, "UICommandTheWorldMain") self:RegistSystemEvent(EventID.UI_RefreshCurrency,self.ShowGuildBoxInfo) --刷新道具信息 self:RegistSystemEvent(EventID.UI_CommandTheWorld_RefreshMainPanelRankAndDevote, self.ShowRankAndDevote) --刷新排行和捐献 self:RegistSystemEvent(EventID.UI_CommandTheWorld_RefreshMainPanelBox, self.ShowGuildBoxInfo) --刷新势力宝箱 self:RegistSystemEvent(EventID.UI_CommandTheWorld_ShowUseItemTips,self.ShowUseItemTips) --显示捐献道具提示 self:RegistSystemEvent(EventID.UI_Guild_BeKickOutRefresh, self.OnBeKickOutRefresh) --玩家势力信息变化时,发宝箱请求,刷数据 self:RegistSystemEvent(EventID.UI_CommandTheWorld_CommandWorldDevoteItemsReq,self.CommandWorldDevoteItemsReq) --捐道具请求事件 self:RegistSystemEvent(EventID.UI_CommandTheWorld_EndAndCloseActivity,self.EndAndCloseActivity) --关闭活动 self:RegistSystemEvent(CTL.RedPoint.RedPointKey.CommandTheWorld_RewardInTask,self.RefreshRedPoint) --刷新红点 self:RegistSystemEvent(CTL.RedPoint.RedPointKey.CommandTheWorld_RewardInGift,self.RefreshRedPoint) --刷新红点 self:RegistSystemEvent(EventID.TimeLine_Update, self.OnTimeLineActive) --设置标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_BattlefieldMuster_Title) self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.obj_Model) UTL.UIRender.Create3DSceneTrans(self.modelComponentDataHandle, ScenePath, 1600, 0, 1600, 0, 0, 0, UTL.UIRender.LayerActiveType.UI2DBGCommonShow) UTL.UIRender.SetCameraParam(self.modelComponentDataHandle, nil, nil, 45.5) self:InitData() end function UICommandTheWorldMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UICommandTheWorldMain:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then --玩法说明 if MDL.CommandTheWorld.IsSingleSerActivity() then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.CommandTheWorldSingle}) else UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.CommandTheWorld}) end elseif comp == self.btn_RankOpen then --展开排行榜 self:OnClickUnfoldRank() elseif comp == self.btn_RankClose then --收起排行榜 self:OnClickFoldRank() elseif comp == self.btn_RankReward then --充值有礼 self:OnClickGift() elseif comp == self.btn_Rank then -- 排行奖励 self:OnClickRankReward() elseif comp == self.btn_FightInfo then -- 活跃任务 self:OnClickTask() elseif comp == self.btn_PointReward then --兑换商城 self:OnClickStore() elseif comp == self.ButtonBox then --点击宝箱,显示宝箱列表 CTL.Sound.PlayGameSound("UI_click_03") if CTL.CommandTheWorld.IsSingleSerActivityRankEnd() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_BattlefieldMuster_Box_Single) return end MDL.CommandTheWorld.GetCommandWorldGuildTreasureBoxReq() UIManager.OpenView(Const_UI_Lua.UIEnum.UICommandTheWorldWindow,{popWindowType = CTL.CommandTheWorld.PopWindowType.Reward}) elseif comp == self.group_Item.btn_Item1 then --点击A道具 self:OnClickUseItemA() elseif comp == self.group_Item.btn_Item2 then --点击B道具 self:OnClickUseItemB() elseif comp == self.top1 then --点击前三的事件 if self.TopArrayId[1] and BattleDataGetter.GetAcID() ~= self.TopArrayId[1] then MDL.PlayerInteract.GetPlayerInteractiveInfoReq(self.TopArrayId[1]) end elseif comp == self.top2 then --点击前三的事件 if self.TopArrayId[2] and BattleDataGetter.GetAcID() ~= self.TopArrayId[2] then MDL.PlayerInteract.GetPlayerInteractiveInfoReq(self.TopArrayId[2]) end elseif comp == self.top3 and BattleDataGetter.GetAcID() ~= self.TopArrayId[3] then --点击前三的事件 if self.TopArrayId[3] then MDL.PlayerInteract.GetPlayerInteractiveInfoReq(self.TopArrayId[3]) end end end function UICommandTheWorldMain:OnValueChanged(comp, index) if comp == self.group_RankTab then self:OnClickTab(index) end end function UICommandTheWorldMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_InfoList then --捐献信息 if self.currentTab == LocalSeverTabIndex then--本服 if GameAppInfo.IsChinesePackage() then UIUtils.SetLabel(cellTable.txt_BossName, string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_Record,data.guildName,data.name," "..UTL.Item.GetItemColorName(data.item.itemID),UTL.Item.GetItemColorContent(data.item.itemID,data.item.itemCount))) else UIUtils.SetLabel(cellTable.txt_BossName, string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_Record,data.guildName,data.name,UTL.Item.GetItemColorName(data.item.itemID),UTL.Item.GetItemColorContent(data.item.itemID,data.item.itemCount))) end --势力徽记信息 UIUtils.SetActive(cellTable.img_GuildEmblem,true) CTL.Guild.SetGuildEmblem(cellTable.img_GuildEmblem, cellTable.lab_EmblemName, data.emblemFrame, data.emblemContent) else --跨服 UIUtils.SetLabel(cellTable.txt_BossName,string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_Record,"S."..tostring(data.serverID),data.name,UTL.Item.GetItemColorName(data.item.itemID),UTL.Item.GetItemColorContent(data.item.itemID,data.item.itemCount))) UIUtils.SetActive(cellTable.img_GuildEmblem,false) end elseif scrollRect == self.loop_RankList then --排行信息 UIUtils.SetLabel(cellTable.txt_Rank,tostring(data.index)) UIUtils.SetLabel(cellTable.txt_Integral,tostring(data.param1)) if self.currentTab == LocalSeverTabIndex then--本服 UIUtils.SetActive(cellTable.txt_Server,false) --势力相关信息 local guildName = "" if data.guildSingleInfo then guildName = data.guildSingleInfo.guildName end if guildName~= "" then --有势力 UIUtils.SetActive(cellTable.img_GuildIcon,true) CTL.Guild.SetGuildEmblem(cellTable.img_GuildIcon, cellTable.txt_Guild, data.guildSingleInfo.emblemFrame, data.guildSingleInfo.emblemContent) else --退出势力/无势力 UIUtils.SetActive(cellTable.img_GuildIcon,false) UIUtils.SetLabel(cellTable.txt_Guild,"") end --玩家自己名字变色 if BattleDataGetter.GetAcID() == data.acid then UIUtils.SetLabel(cellTable.txt_Name,UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Green,data.name)) elseif data.guildSingleInfo and MDL.Guild.IsSameGuild(data.guildSingleInfo.guildID) then --同势力名字变色 UIUtils.SetLabel(cellTable.txt_Name,UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue,data.name)) else UIUtils.SetLabel(cellTable.txt_Name,tostring(data.name)) end else --跨服 --玩家自己名字变色 if BattleDataGetter.GetAcID() == data.acid then UIUtils.SetLabel(cellTable.txt_Name,UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Green, data.name)) else UIUtils.SetLabel(cellTable.txt_Name,tostring(data.name)) end UIUtils.SetActive(cellTable.txt_Server,true) UIUtils.SetLabel(cellTable.txt_Server,"S."..tostring(data.param2)) UIUtils.SetActive(cellTable.img_GuildIcon,false) end end end function UICommandTheWorldMain:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_RankList then --排行信息 MDL.PlayerInteract.GetPlayerInteractiveInfoReq(data.acid) end end function UICommandTheWorldMain:OnClosed() self:UnloadAllSoliders() UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) UIManager.ActiveUIModle(true, "UICommandTheWorldMain") end --endregion --region 显示榜一展示信息 --显示榜一展示信息 function UICommandTheWorldMain:ShowTopInfo(commonShowRoleHeadInfo) self:ShowTopHero(commonShowRoleHeadInfo) local guildBoxLevel = MDL.CommandTheWorld.GetGuildBoxLevel() if self.lastGuildBoxLevel ~= guildBoxLevel then self.lastGuildBoxLevel = guildBoxLevel self:LoadSoldiers(self:GetSoldiersId(self.lastGuildBoxLevel)) end end --超过12级的显示12级小兵 function UICommandTheWorldMain:GetSoldiersId(lastGuildBoxLevel) if lastGuildBoxLevel > #BoxLevelAndMonsterModelId then return BoxLevelAndMonsterModelId[#BoxLevelAndMonsterModelId] else return BoxLevelAndMonsterModelId[lastGuildBoxLevel] end end --榜一主将展示 function UICommandTheWorldMain:ShowTopHero(commonShowRoleHeadInfo) UIUtils.SetActive(self.HeadInfo,true) --UI信息 --榜一名字 if BattleDataGetter.GetAcID() == commonShowRoleHeadInfo.acid then UIUtils.SetLabel(self.txt_PlayerName,UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Green, commonShowRoleHeadInfo.name)) else UIUtils.SetLabel(self.txt_PlayerName,commonShowRoleHeadInfo.name) end --本服显示势力名,同势力显示蓝色 if self.currentTab == LocalSeverTabIndex then if MDL.Guild.IsSameGuild(commonShowRoleHeadInfo.guildId) then UIUtils.SetLabel(self.txt_PlayerGuild,UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue, commonShowRoleHeadInfo.guildName)) else UIUtils.SetLabel(self.txt_PlayerGuild, commonShowRoleHeadInfo.guildName) end if commonShowRoleHeadInfo.guildName ~= "" then UIUtils.SetActive(self.img_PlayerGuildIcon,true) CTL.Guild.SetGuildEmblem(self.img_PlayerGuildIcon, self.txt_PlayerGuildIcon, commonShowRoleHeadInfo.EmblemFrame, commonShowRoleHeadInfo.EmblemContent) else UIUtils.SetActive(self.img_PlayerGuildIcon,false) end else --跨服排行显示服务器名,同服务器名显示蓝色 self.txt_PlayerGuild.text = CTL.CrossServer.GetServerShowStr(commonShowRoleHeadInfo.ShowServerId, CTL.CrossServer.IsSameServer(commonShowRoleHeadInfo.MergeServerId)) UIUtils.SetActive(self.img_PlayerGuildIcon, false) end --主将信息 (增加了避免重复加载的逻辑) if commonShowRoleHeadInfo.horseAppearanceId > 0 then self.horseId = commonShowRoleHeadInfo.horseAppearanceId else self.horseId = commonShowRoleHeadInfo.HorseID end self.heroId = commonShowRoleHeadInfo.mainHeroId --保底没有马数据的时候,给1号马 if self.horseId == 0 then self.horseId = 1 end local heroInfo = tostring(self.horseId).."_"..tostring(self.heroId) if self.lastHeroInfo ~= heroInfo then self.lastHeroInfo = heroInfo self:LoadSceneAndHeroHorse(commonShowRoleHeadInfo) self:SetHeadInfoHeightByHeroId(self.heroId) end end --自适应头顶信息高度 function UICommandTheWorldMain:SetHeadInfoHeightByHeroId(heroId) local normalHeight = -98 local highHeight = -68 if heroId == 5 or heroId == 22 or heroId == 23 then --董卓/吕布/黄盖 self.HeadInfo.transform:SetLocalPosition(168, highHeight, 0) else self.HeadInfo.transform:SetLocalPosition(168, normalHeight, 0) end end --卸载所有士兵 function UICommandTheWorldMain:UnloadAllSoliders() if self.AllSoliders and #self.AllSoliders > 0 then for i, v in ipairs(self.AllSoliders) do v:Dispose(false) end end self.AllSoliders = nil end function UICommandTheWorldMain:LoadSoldiers(modelId) self:UnloadAllSoliders() self.AllSoliders = {} local soliderPosArray = {} soliderPosArray[1]={x=4.03,z=-2.262} soliderPosArray[2]={x=4.03,z=-6.066} soliderPosArray[3]={x=4.03,z=-9.886} soliderPosArray[4]={x=-3.438,z=-2.262} soliderPosArray[5]={x=-3.438,z=-6.066} soliderPosArray[6]={x=-3.438,z=-9.886} for i = 1, 6 do local x,z = soliderPosArray[i].x,soliderPosArray[i].z local renderEntity --士兵区分左右手 if i<= 3 then renderEntity = self:LoadSoldier(modelId.right,x,z) else renderEntity = self:LoadSoldier(modelId.left,x,z) end table.insert(self.AllSoliders,renderEntity) end end function UICommandTheWorldMain:LoadSoldier(modelId,posX,posZ) local layer = LuaConst.Layer.Soldier_Friend --层级写死 local camp = 1 --阵营 随便写一个 local modelData = DataSheetManager.MonsterModelData:GetDataByID(modelId) --创建Entity local renderEntity = AuxUtil.LoadRenderEntity(not LevelManager.IsNoBattleLevel(), layer, camp, -1) -- 最后一个参数设置-1 为不剔除 local ctrlPath = self:GetAnimatorCtrlPath(modelData) local equipmentID = modelData.EquipmentID local pathId, combinePathId = 0, 0 local combinePath = modelData.CombinePath if string.isNilOrEmpty(combinePath) then pathId = UTL.String.GetIdByString(modelData.Path) else combinePathId = UTL.String.GetIdByString(modelData.CombinePath) end local ctrlPathId,animAppendId = 0,0 if string.isNilOrEmpty(modelData.AnimAppend) then ctrlPathId = UTL.String.GetIdByString(ctrlPath) else animAppendId = UTL.String.GetIdByString(modelData.AnimAppend) end local materialId=-1 if not string.isNilOrEmpty(modelData.material) then materialId=UTL.String.GetIdByString(modelData.material) end --设置模型 if renderEntity:SetModel(modelData.ID, pathId, combinePathId, modelData.ModelScale, ctrlPathId, animAppendId, materialId, modelData.VisualCost, modelData.DmgNumHeight, modelData.ModelSizeRate) then self:CreateEquip(renderEntity, modelData.ID, equipmentID) end renderEntity:SetVisible(true) --设置位置 local scenePosX,scenePosZ = 1600,1600 --创建出的场景的默认位置 renderEntity:SetTrans(scenePosX + posX,scenePosZ + posZ,0,0) renderEntity:SetTransY(-0.009) return renderEntity end --没有榜首信息时,加载场景显示1级小兵 function UICommandTheWorldMain:OnlyShowSceneAndLevel1Solider() if not self.loadOnlySceneAndLevel1Solider then --摄像机的位置必须重设,不然第二次打开时如果时池子里拿出来的不对 AuxUtil.MainCameraTrans.parent:SetLocalPosition(-0.64, 5 ,10.24) --加载1级小兵 self:LoadSoldiers(BoxLevelAndMonsterModelId[1]) UIUtils.SetActive(self.HeadInfo,false) self.loadOnlySceneAndLevel1Solider = true end end function UICommandTheWorldMain:LoadSceneAndHeroHorse(headInfo) UTL.UIRender.SetModelRootUnderHeroParent(self.modelComponentDataHandle) UTL.UIRender.SetHeroParentPos(self.modelComponentDataHandle, 0, 0, 0) UTL.UIRender.SetCameraParam(self.modelComponentDataHandle, nil, nil, 45.5) UTL.UIRender.SetSenceShadow(self.modelComponentDataHandle, false) local isStandOnHorse if headInfo.horseAppearanceId > 0 then local appearanceData = MDL.WarHorse.GetAppearanceInfoByID(headInfo.horseAppearanceId) UTL.UIRender.CreateHorse3DModel(self.modelComponentDataHandle, self.horseId, headInfo.horseAppearanceId, UTL.UIRender.LayerActiveType.HorseShow, true) isStandOnHorse = UTL.UIRender.GetOnHorseAnim(appearanceData) else local horseData = DataSheetManager.HorseData:GetDataByHorseID(self.horseId) UTL.UIRender.CreateHorse3DModel(self.modelComponentDataHandle, self.horseId, 0, UTL.UIRender.LayerActiveType.HorseShow, true) isStandOnHorse = UTL.UIRender.GetOnHorseAnim(horseData) end UTL.UIRender.StartRideHorse(self.modelComponentDataHandle, self.horseId, headInfo.HeroID, headInfo) if not isStandOnHorse then UTL.UIRender.DriverEntityPlayAnim(self.modelComponentDataHandle, "ride_idle_loop") else UTL.UIRender.DriverEntityPlayAnim(self.modelComponentDataHandle, LuaConst.Animation_idle_loop) end local weaponSoul = CTL.DivineWeaponForgeSoul.GetWeaponSoulSkillByProtoMap(headInfo.HeroID, headInfo.weaponSoul) if weaponSoul then UTL.UIRender.LoadPlayerWeaponSoul(self.modelComponentDataHandle, weaponSoul) end UTL.UIRender.SetHeroParentRot(self.modelComponentDataHandle, 0, -45, 0) UTL.UIRender.SetModelRootLocalScale(self.modelComponentDataHandle, 1.2, 1.2, 1.2) --摄像机的位置必须重设,不然第二次打开时如果时池子里拿出来的不对 AuxUtil.MainCameraTrans.parent:SetLocalPosition(-0.64, 5, 10.24) end function UICommandTheWorldMain:GetAnimatorCtrlPath(modelData) local animCtrlPath = modelData.AnimCtlPath if animCtrlPath and animCtrlPath ~= "" then return animCtrlPath end local modelPath = modelData.Path local animCtlID= modelData.AnimCtlID if animCtlID and animCtlID ~= "" then animCtrlPath = string.match(modelPath, "^(.*)/").."/"..animCtlID..".controller" end return animCtrlPath end function UICommandTheWorldMain:CreateEquip(renderEntity, modelID, equipID) local equipData = DataSheetManager.EquipPartsData:GetDataByID(equipID) if not equipData then return end for i,v in ipairs(equipData.EquipPart_Table) do local slotInt = ExpSystemManager.GetEquipPartSlotInt(v) local animCtrlPath = v.HasAnim and string.gsub(v.Prefeb,".prefab" ,".controller") or "" local animCtrlPathId=UTL.String.GetIdByString(animCtrlPath) local pathId=UTL.String.GetIdByString(v.Prefeb) renderEntity:SetEquipOrWeapon(modelID, pathId, slotInt, animCtrlPathId,v.IsParent, false) end end --endregion --timline 激活时关闭UI function UICommandTheWorldMain:OnTimeLineActive() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end --刷红点 function UICommandTheWorldMain:RefreshRedPoint() self.btn_FightInfo:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.CommandTheWorld_RewardInTask)) self.btn_RankReward:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.CommandTheWorld_RewardInGift)) end function UICommandTheWorldMain:OnBeKickOutRefresh() MDL.CommandTheWorld.GetCommandWorldGuildTreasureBoxReq() if not MDL.Guild.IsHasGuild() then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.CommandTheWorld_GetRewardInBox) end end function UICommandTheWorldMain:InitData() --收起排行榜 self.state_RankList:SetState(0) --设置数据 self:InitTab() self:ShowRankAndDevote() self:ShowGuildBoxInfo() self:RefreshRedPoint() --定时刷新活动时间 self:StartRepeatFunc(self.RefreshActivityTime, 1, -1) --定时刷新榜单 self:StartRepeatFunc(self.RefreshLocalRankDataTiming, 1, -1) self:StartRepeatFunc(self.RefreshWarZoneRankDataTiming, 1, -1) end function UICommandTheWorldMain:EndAndCloseActivity() self:CloseView(true) end --更新刷新排行榜的时间的配置 function UICommandTheWorldMain:UpdateRefreshRankTimeSetting() local nextUpdateTime = MDL.CommandTheWorld.GetRefreshRankTimeByType(self.currentTab) self.UpdateRankInterval = nextUpdateTime - UTL.Time.GetServerTimestamp() if self.currentTab == LocalSeverTabIndex then self:StopRepeatFunc(self.SendLocalRankReq) self:StartRepeatFunc(self.SendLocalRankReq, self.UpdateRankInterval, -1) else self:StopRepeatFunc(self.SendCrossRankReq) self:StartRepeatFunc(self.SendCrossRankReq, self.UpdateRankInterval, -1) end end function UICommandTheWorldMain:InitTab() if MDL.CommandTheWorld.IsSingleSerActivity() then UTL.Toggle.InitToggleGroupByIDS(self.group_RankTab, "lab_1",{Const_IDS.IDS_MyServer}) self.group_RankTab:GetToggleComponent(LocalSeverTabIndex,"Chk_1").transform:SetSizeDelta(520, 87) else UTL.Toggle.InitToggleGroupByIDS(self.group_RankTab, "lab_1",{Const_IDS.IDS_MyServer, Const_IDS.IDS_BattlefieldMuster_WarZone}) self.stateServer = self.group_RankTab:GetToggleComponent(BattleAreaTabIndex,"state_Txt") if CTL.CommandTheWorld.IsBeforeBattleAreaOpen() then --没开启 self.stateServer:SetState(0) elseif CTL.CommandTheWorld.IsBattleAreaEnd() then --已结束 self.stateServer:SetState(2) else --开启中 self.stateServer:SetState(1) end end self.stateLocal = self.group_RankTab:GetToggleComponent(LocalSeverTabIndex,"state_Txt") if CTL.CommandTheWorld.IsLocalServerEnd() then --已结束 self.stateLocal:SetState(2) else --开启中 self.stateLocal:SetState(1) end --本服没结束或是战区没开始的时候就选中本服排行,否则选中战区 if CTL.CommandTheWorld.IsLocalServerOpen() then self.currentTab = LocalSeverTabIndex elseif CTL.CommandTheWorld.IsBattleAreaOpen() then self.currentTab = BattleAreaTabIndex else self.currentTab = LocalSeverTabIndex end self:RefreshActivityTime() self.group_RankTab:SelectIndex(self.currentTab - 1) end --刷新活动的剩余时间 function UICommandTheWorldMain:RefreshActivityTime() --本服开启后的剩余时间 if CTL.CommandTheWorld.IsLocalServerOpen() then local remainTimeStr = "" local remainTime = CTL.CommandTheWorld.GetRemainTimeOfLocalServer() if remainTime < 0 then remainTime = 0 end --显示倒计时 -- 超过24小时 remainTimeStr = UTL.Time.FormatTimeForDayOrClock(remainTime) self.group_RankTab:SetToggleText(1, "txt",string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_BattlefieldMuster_CloseTime),remainTimeStr)) end --本服开启结束 if CTL.CommandTheWorld.IsLocalServerEnd() then local remainTimeStr = UTL.Color.FormatRedColor(UIUtils.GetLocalizedTxt(Const_IDS["IDS_ActivityItem_End"])) self.group_RankTab:SetToggleText(1, "txt",remainTimeStr) end if CTL.CommandTheWorld.IsBeforeBattleAreaOpen() then --战区排行没打开的时候 if not MDL.CommandTheWorld.IsSingleSerActivity() then -- 显示X月Y日开启 local openTime = CTL.CommandTheWorld.GetBattleAreaOpenTime() if GameAppInfo.IsVietnamPackage() then self.group_RankTab:SetToggleText(2, "txt", string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_OpenTime, UTL.Time.OsDateOriginal("%d", openTime), UTL.Time.OsDateOriginal("%m", openTime))) else self.group_RankTab:SetToggleText(2, "txt", string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_OpenTime,UTL.Time.FormatTimeSimple(openTime))) end end --本服排行结算阶段 if CTL.CommandTheWorld.IsLocalRankSummary() then if self.IsShowSeverTips == nil then UIUtils.SetActive(self.group_RankInfo,true) self.IsShowSeverTips = true end if MDL.CommandTheWorld.IsSingleSerActivity() then UIUtils.SetLabelText(self.txt_RankInfo, Const_IDS.IDS_BattlefieldMuster_Closetips_Single) else local remainOpenTime = CTL.CommandTheWorld.GetRemainOpenTimeOfBattleServer() local remainTimeStr = UTL.Time.FormatTimeClockBySeconds(remainOpenTime) UIUtils.SetLabel(self.txt_RankInfo, string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_BattlefieldMuster_Closetips),remainTimeStr)) end end elseif CTL.CommandTheWorld.IsBattleAreaOpen() then --战区排行 开启状态 --隐藏战区排行开启倒计时 if self.IsShowSeverTips then UIUtils.SetActive(self.group_RankInfo,false) self.IsShowSeverTips = false end --刷新状态 if not self.hasChangeServerTabState then self.stateServer:SetState(1) self.hasChangeServerTabState = true end local remainTimeStr = "" local remainTime = CTL.CommandTheWorld.GetRemainTimeOfBattleServer() if remainTime < 0 then remainTime = 0 end --显示倒计时 -- 超过24小时 remainTimeStr = UTL.Time.FormatTimeForDayOrClock(remainTime) self.group_RankTab:SetToggleText(2, "txt", string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_BattlefieldMuster_CloseTime),remainTimeStr)) else self:StopRepeatFunc(self.RefreshActivityTime) self:ShowHonourShowPanel() end end --自动定时刷新本服数据 function UICommandTheWorldMain:RefreshLocalRankDataTiming() if self.currentTab == LocalSeverTabIndex then --请求本服排行 MDL.CommandTheWorld.GetCommandWorldRankAndDevoteReq(MDL.CommandTheWorld.CommandWorldType.LocalRank) end end --自动定时刷新战区数据 function UICommandTheWorldMain:RefreshWarZoneRankDataTiming() if self.currentTab == BattleAreaTabIndex then --请求跨服排行 MDL.CommandTheWorld.GetCommandWorldRankAndDevoteReq(MDL.CommandTheWorld.CommandWorldType.CrossRank) end end --显示左侧的排行榜信息和贡献信息 function UICommandTheWorldMain:ShowRankAndDevote() self.IsNoRankData = true --是否无人入榜 local rankFullData --本服 if self.currentTab == LocalSeverTabIndex then rankFullData = MDL.CommandTheWorld.GetLocalRankFullData() else --跨服 rankFullData = MDL.CommandTheWorld.GetCrossRankFullData() end --每次更新一下刷新时间 if #rankFullData > 0 then self:UpdateRefreshRankTimeSetting() end --前三 self:ShowTop3PlayerInfo(rankFullData.perHeadInfo,rankFullData.perRankInfo) --榜单信息 if IsServerDataNotNil(rankFullData.perRankInfo) then self:ShowRank(rankFullData.perRankInfo.records) self:ShowMyInfo(rankFullData.perRankInfo.myRank) end --捐献信息 if IsServerDataNotNil(rankFullData.devoteRecord) then self:ShowContributeInfo(rankFullData.devoteRecord) end --榜一信息 if IsServerDataNotNil(rankFullData.ListOneShowInfo) then self:ShowTopInfo(rankFullData.ListOneShowInfo) else UIUtils.SetActive(self.img_PlayerGuildIcon,false) self:OnlyShowSceneAndLevel1Solider() --没有榜一信息时只展示场景和1级小兵 end --无人入榜,有数据再隐藏 UIUtils.SetActive(self.group_Empty,self.IsNoRankData) end --显示排行信息 function UICommandTheWorldMain:ShowRank(records) if self.state_RankList.CurState == 1 then --榜单显示状态,直接添加数据 if IsServerDataNotNil(records) then local data = {} for i,v in ipairs(records) do --只显示前三名以后的排行信息 if i > 3 then table.insert(data,v) end self.IsNoRankData = false end self.loop_RankList:ReloadAll(data) end else --榜单隐藏状态,缓存 self.CacheRankData = records end end --根据缓存加载榜单数据 function UICommandTheWorldMain:ShowRankByCache() if IsServerDataNotNil(self.CacheRankData) then local data = {} for i,v in ipairs(self.CacheRankData) do --只显示前三名以后的排行信息 if i > 3 then table.insert(data,v) end self.IsNoRankData = false end self.loop_RankList:ReloadAll(data) end end --显示玩家自己的信息 function UICommandTheWorldMain:ShowMyInfo(myRank) if myRank.index > 0 then --入榜 UIUtils.SetLabel(self.group_SelfIntegral.txt_Rank,string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_MyRanking, tostring(myRank.index))) UIUtils.SetLabel(self.group_SelfIntegral.txt_Integral,string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_Prestige,tostring(myRank.param1))) else --未入榜 UIUtils.SetLabelText(self.group_SelfIntegral.txt_Rank,Const_IDS.IDS_Rank_Unranked) local integral = MDL.CommandTheWorld.GetIntegralByType(self.currentTab) if myRank.param1 >= integral then UIUtils.SetLabel(self.group_SelfIntegral.txt_Integral,string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_Prestige,tostring(myRank.param1))) else UIUtils.SetLabel(self.group_SelfIntegral.txt_Integral, string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_RankCondition, tostring(myRank.param1),tostring(MDL.CommandTheWorld.GetIntegralByType(self.currentTab)))) end end end --显示捐献信息 function UICommandTheWorldMain:ShowContributeInfo(devoteRecord) if self.state_RankList.CurState == 0 then --贡献显示状态,直接添加数据 --需要倒序处理 local temp = {} for i,v in ipairs(devoteRecord) do table.insert(temp,v) end table.reverseTable(temp) self.loop_InfoList:ReloadAll(temp) else --贡献隐藏状态,缓存数据 self.CacheContributeData = devoteRecord end end function UICommandTheWorldMain:ShowContributeInfoByCache() if self.CacheContributeData then --需要倒序处理 local temp = {} for i,v in ipairs(self.CacheContributeData) do table.insert(temp,v) end table.reverseTable(temp) self.loop_InfoList:ReloadAll(temp) end end --显示榜首玩家信息 -- perRankInfo RankPersonalInfo 类型,个人榜单信息 -- headInfos CommonShowRoleHeadInfo 类型,前三名信息 function UICommandTheWorldMain:ShowTop3PlayerInfo(headInfos,perRankInfo) self.TopArray = { [1]=self.top1Objs, [2]=self.top2Objs, [3]=self.top3Objs, } self.TopUIArray = { [1]=self.top1, [2]=self.top2, [3]=self.top3, } self.TopArrayId = {} for i,v in ipairs(self.TopUIArray) do UIUtils.SetActive(v,false) end --头像\名字\势力徽记 if headInfos then for i,v in ipairs(headInfos) do self.IsNoRankData = false local record = perRankInfo.records[i] UIUtils.SetActive(self.TopUIArray[i],true) self.TopArrayId[i] = record.acid CTL.Character.SetImgPortrait(self.TopArray[i].img_HeroHead, v.PortraitId) --设置等级 local tlData = DataSheetManager.TeamLevelData:GetDataByTeamLevel(v.level) if tlData ~= nil then local _levelStr = UTL.Item.GetNobilityByTeamLevel(tlData.TeamLevel) -- 爵位转换 local teamLevelName = string.FormatByIdsId(Const_IDS[tlData.TeamLevelName], _levelStr) UIUtils.SetLabel(self.TopArray[i].txt_Level, teamLevelName) else UIUtils.SetLabel(self.TopArray[i].txt_Level,tostring(v.level)) end --跨服显示所属服 if self.currentTab == LocalSeverTabIndex then UIUtils.SetLabel(self.TopArray[i].txt_Server, "") else --同服修改颜色 if MDL.Login.GetServerShowId() == record.param2 then UIUtils.SetLabel(self.TopArray[i].txt_Server, UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue, "S."..tostring(record.param2))) else UIUtils.SetLabel(self.TopArray[i].txt_Server, "S."..tostring(record.param2)) end end UIUtils.SetLabel(self.TopArray[i].txt_Integral,tostring(record.param1)) --名字太长时截断显示 local name = record.name if name and #name > 3 then name = UTL.String.CutZHStrByLength(name, 3) name = name.."..." end --势力、名字 if self.currentTab == LocalSeverTabIndex then UIUtils.SetActive(self.TopArray[i].img_GuildIcon,true) if record.guildSingleInfo.guildName ~="" then --有势力 if record.guildSingleInfo.emblemFrame then UIUtils.SetActive(self.TopArray[i].img_GuildIcon,true) CTL.Guild.SetGuildEmblem(self.TopArray[i].img_GuildIcon, self.TopArray[i].txt_Guild, record.guildSingleInfo.emblemFrame, record.guildSingleInfo.emblemContent) end else --退出势力 UIUtils.SetActive(self.TopArray[i].img_GuildIcon,false) UIUtils.SetLabel(self.TopArray[i].txt_Guild,"") end --玩家自己修改颜色 if BattleDataGetter.GetAcID() == record.acid then UIUtils.SetLabel(self.TopArray[i].txt_Name,UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Green, name)) elseif MDL.Guild.IsSameGuild(record.guildSingleInfo.guildID) then--本服同势力修改玩家名字颜色 UIUtils.SetLabel(self.TopArray[i].txt_Name,UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue,name)) else UIUtils.SetLabel(self.TopArray[i].txt_Name,name) end else UIUtils.SetActive(self.TopArray[i].img_GuildIcon,false) --玩家自己修改名字颜色 if BattleDataGetter.GetAcID() == record.acid then UIUtils.SetLabel(self.TopArray[i].txt_Name,UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Green, name)) else UIUtils.SetLabel(self.TopArray[i].txt_Name,name) end end end end end --显示势力宝箱信息 function UICommandTheWorldMain:ShowGuildBoxInfo() --宝箱信息 local boxInfo = MDL.CommandTheWorld.GetBoxInfo() if boxInfo then UIUtils.SetLabel(self.txt_BoxName,string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_PrestigeLevel,tostring(boxInfo.BoxLevel))) UIUtils.SetLabel(self.txt_Progress,string.format("%s/%s",tostring(boxInfo.BoxExp),tostring(boxInfo.BoxMaxExpOfLevel))) if boxInfo.BoxMaxExpOfLevel ~=nil and boxInfo.BoxMaxExpOfLevel >0 then UIUtils.SetAtlasImageFillAmount(self.img_Full,boxInfo.BoxExp/boxInfo.BoxMaxExpOfLevel) end end --设定势力宝箱状态 if CTL.CommandTheWorld.HasCanGetRewardInBox() then self.state_Box:SetState(1) self.effect_shine:PlayUIEffect() else self.state_Box:SetState(0) self.effect_shine:StopUIEffect() end -- 道具信息 if MDL.CommandTheWorld.IsSingleSerActivity() then UIUtils.SetLabelText(self.lab_Notice,Const_IDS.IDS_BattlefieldMuster_Recovery_Single) else UIUtils.SetLabelText(self.lab_Notice,Const_IDS.IDS_BattlefieldMuster_Recovery) end local itemACount = CTL.CommandTheWorld.GetItemACount() local itemBCount = CTL.CommandTheWorld.GetItemBCount() if itemACount > 0 then UIUtils.SetActive(self.group_Item.item_Empty1,false) UIUtils.SetActive(self.group_Item.img_NumBg1,true) UIUtils.SetLabel(self.group_Item.txt_Num1,tostring(itemACount)) if (CTL.CommandTheWorld.IsLocalServerOpen() or CTL.CommandTheWorld.IsBattleAreaOpen()) then self.group_Item.btn_Item1:SetRedPoint(true) else self.group_Item.btn_Item1:SetRedPoint(false) end else UIUtils.SetActive(self.group_Item.item_Empty1,true) UIUtils.SetActive(self.group_Item.img_NumBg1,false) self.group_Item.btn_Item1:SetRedPoint(false) end local itemAData = DataSheetManager.ItemData:GetDataByID(CTL.CommandTheWorld.GetItemAID()) if itemAData then UIUtils.SetImageByAssetBundle(self.group_Item.img_Item1,string.format(ItemIconPath,itemAData.Icon)) end if itemBCount > 0 then UIUtils.SetActive(self.group_Item.item_Empty2,false) UIUtils.SetActive(self.group_Item.img_NumBg2,true) UIUtils.SetLabel(self.group_Item.txt_Num2,tostring(itemBCount)) if (CTL.CommandTheWorld.IsLocalServerOpen() or CTL.CommandTheWorld.IsBattleAreaOpen()) then self.group_Item.btn_Item2:SetRedPoint(true) else self.group_Item.btn_Item2:SetRedPoint(false) end else UIUtils.SetActive(self.group_Item.item_Empty2,true) UIUtils.SetActive(self.group_Item.img_NumBg2,false) self.group_Item.btn_Item2:SetRedPoint(false) end local itemBData = DataSheetManager.ItemData:GetDataByID(CTL.CommandTheWorld.GetItemBID()) if itemBData then UIUtils.SetImageByAssetBundle(self.group_Item.img_Item2,string.format(ItemIconPath,itemBData.Icon)) end --道具加成 local infoA = MDL.CommandTheWorld.GetCommandWorldRelation(CTL.CommandTheWorld.GetItemAID()) UIUtils.SetLabel(self.group_Item.txt_Prestige1,"+"..tostring(infoA.Integral)) UIUtils.SetLabel(self.group_Item.txt_MilitaryExploitsIcon1,"+"..tostring(infoA.CurrencyNum)) UTL.Item.SetCurrencyImageIcon(self.group_Item.img_MilitaryExploitsIcon1, infoA.Currency) local infoB = MDL.CommandTheWorld.GetCommandWorldRelation(CTL.CommandTheWorld.GetItemBID()) UIUtils.SetLabel(self.group_Item.txt_Prestige2,"+"..tostring(infoB.Integral)) UIUtils.SetLabel(self.group_Item.txt_MilitaryExploitsIcon2,"+"..tostring(infoB.CurrencyNum)) UTL.Item.SetCurrencyImageIcon(self.group_Item.img_MilitaryExploitsIcon2, infoB.Currency) end --region 点击的所有事件 function UICommandTheWorldMain:OnClickTab(index) --切换Tab 时 重置加载状态 self.loadOnlySceneAndLevel1Solider = false self.lastHeroInfo = "" --index是从0 开始的 if (index + 1) == LocalSeverTabIndex then self.currentTab = LocalSeverTabIndex self:ShowRankAndDevote() else --开启的话刷新,否则提示战区排行暂未开启 if CTL.CommandTheWorld.IsBattleAreaOpen() then self.currentTab = BattleAreaTabIndex self:ShowRankAndDevote() else CTL.Tips.AddTipsMsg(Const_IDS.IDS_BattlefieldMuster_Unopened) self:StartRepeatFunc(self.SelectTab, 0.01, 1) --需要延时执行,不然有bug end end end function UICommandTheWorldMain:SelectTab() self.group_RankTab:SelectIndex(self.currentTab - 1) end --点击排行奖励 function UICommandTheWorldMain:OnClickRankReward() if CTL.CommandTheWorld.IsBattleAreaEnd() then --结束显示荣耀榜展示界面 self:ShowHonourShowPanel() else UIManager.OpenView(Const_UI_Lua.UIEnum.UICommandTheWorldWindow,{popWindowType = CTL.CommandTheWorld.PopWindowType.Rank}) end end --显示荣耀榜展示界面 function UICommandTheWorldMain:ShowHonourShowPanel() --先关闭打开的二级子界面 UIManager.CloseView(Const_UI_Lua.UIEnum.UIUseItemPop) UIManager.CloseView(Const_UI_Lua.UIEnum.UIPreviewItemTips) UIManager.CloseView(Const_UI_Lua.UIEnum.UICommonNoteView) UIManager.CloseView(Const_UI_Lua.UIEnum.OperationActivity.UIGetActivityItemPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UICommandTheWorldActiveTask) UIManager.CloseView(Const_UI_Lua.UIEnum.UICommandTheWorldRank) UIManager.CloseView(Const_UI_Lua.UIEnum.UICommandTheWorldRecharge) UIManager.CloseView(Const_UI_Lua.UIEnum.UICommandTheWorldReward) UIManager.CloseView(Const_UI_Lua.UIEnum.UICommandTheWorldWindow) self:CloseView(true) CTL.CommandTheWorld.ShowHonourShowPanel() end --点击活跃任务 function UICommandTheWorldMain:OnClickTask() if not CTL.CommandTheWorld.IsBattleAreaEnd() then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommandTheWorldActiveTask,{activityType = MDL.OperationActivity.ActivityType.BattlefieldMuster, activityId = MDL.CommandTheWorld.GetActivityId()}) else self:ShowHonourShowPanel() end end --点击充值有礼 function UICommandTheWorldMain:OnClickGift() if CTL.CommandTheWorld.IsBattleAreaEnd() then --结束显示荣耀榜展示界面 self:ShowHonourShowPanel() else if CTL.CommandTheWorld.IsCanShowGift() then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommandTheWorldRecharge, {activityType = MDL.OperationActivity.ActivityType.BattlefieldMuster, activityId = MDL.CommandTheWorld.GetActivityId() }) else if MDL.CommandTheWorld.IsSingleSerActivity() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_BattlefieldMuster_WarZoneRankTips_Single) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_BattlefieldMuster_WarZoneRankTips) end end end end --点击商店 function UICommandTheWorldMain:OnClickStore() if CTL.CommandTheWorld.IsBattleAreaEnd() then --结束显示荣耀榜展示界面 self:ShowHonourShowPanel() else UIManager.OpenView(Const_UI_Lua.UIEnum.UICommandTheWorldWindow,{popWindowType = CTL.CommandTheWorld.PopWindowType.Store}) end end function UICommandTheWorldMain:SendLocalRankReq() MDL.CommandTheWorld.GetCommandWorldRankAndDevoteReq(MDL.CommandTheWorld.CommandWorldType.LocalRank) end function UICommandTheWorldMain:SendCrossRankReq() MDL.CommandTheWorld.GetCommandWorldRankAndDevoteReq(MDL.CommandTheWorld.CommandWorldType.CrossRank) end function UICommandTheWorldMain:SendRankReq() MDL.CommandTheWorld.SendRankReq(self.currentTab) end --展开排名 function UICommandTheWorldMain:OnClickUnfoldRank() if not self.IsNoRankData then self.state_RankList:SetState(1) self:ShowRankByCache() end self:SendRankReq() end --收起排名 function UICommandTheWorldMain:OnClickFoldRank() self.state_RankList:SetState(0) self:ShowContributeInfoByCache() self:SendRankReq() end --使用活动道具A function UICommandTheWorldMain:OnClickUseItemA() local itemCount = CTL.CommandTheWorld.GetItemACount() local itemID = CTL.CommandTheWorld.GetItemAID() self:ClickItemBase(itemID,itemCount) end function UICommandTheWorldMain:ClickItemBase(itemID,itemCount) if itemCount > 0 then if CTL.CommandTheWorld.IsLocalServerOpen() or CTL.CommandTheWorld.IsBattleAreaOpen() then if MDL.Guild.IsHasGuild() then if itemCount == 1 then MDL.CommandTheWorld.CommandWorldDevoteItemsReq(itemID,itemCount) self.lastUseItemIntegral = CTL.CommandTheWorld.GetItemIntegral(itemID,itemCount) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIUseItemPop, { EventParamId = itemID, ItemId = itemID, TitleIDS = Const_IDS.IDS_BattlefieldMuster_UseItem,TipIDS = Const_IDS.IDS_BattlefieldMuster_UseItemTips, BuyEvent = EventID.UI_CommandTheWorld_CommandWorldDevoteItemsReq}) end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Bag_Tips_NoGuild) end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_BattlefieldMuster_Unused) end else --获取运营通用道具 if CTL.CommandTheWorld.IsSingleSerActivityRankEnd() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_BattlefieldMuster_Closetips_Single) return end local battleEndTime if MDL.CommandTheWorld.IsSingleSerActivity() then battleEndTime = CTL.CommandTheWorld.GetLocalServerRankEndTime() else battleEndTime = CTL.CommandTheWorld.GetBattleAreaEndTime() end CTL.OperationActivity.OpenGetActivityItemPanel(itemID,MDL.CommandTheWorld.GetActivityId(),MDL.OperationActivity.ActivityType.BattlefieldMuster,battleEndTime) end end --捐道具请求事件 function UICommandTheWorldMain:CommandWorldDevoteItemsReq(itemID,itemCount) if CTL.CommandTheWorld.IsLocalServerOpen() or CTL.CommandTheWorld.IsBattleAreaOpen() then if MDL.Guild.IsHasGuild() then MDL.CommandTheWorld.CommandWorldDevoteItemsReq(itemID,itemCount) self.lastUseItemIntegral = CTL.CommandTheWorld.GetItemIntegral(itemID,itemCount) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Bag_Tips_NoGuild) end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_BattlefieldMuster_Unused) end end --显示贡献道具提示 function UICommandTheWorldMain:ShowUseItemTips() if self.lastUseItemIntegral and self.lastUseItemIntegral > 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_BattlefieldMuster_UseTips,self.lastUseItemIntegral) self.lastUseItemIntegral = nil end end --使用活动道具B function UICommandTheWorldMain:OnClickUseItemB() local itemCount = CTL.CommandTheWorld.GetItemBCount() local itemID = CTL.CommandTheWorld.GetItemBID() self:ClickItemBase(itemID,itemCount) end --endregion return UICommandTheWorldMain