local UIWorldBossBattleRank = require "View/WordBoss/UIWorldBossBattleRank" local UICountryWorldBossBattleRank = UIViewClass(UIWorldBossBattleRank) local CountryIconName = { [LuaConst.EHeroKingdomType.WEI] = "gb_msz_wei.png", [LuaConst.EHeroKingdomType.SHU] = "gb_msz_shu.png", [LuaConst.EHeroKingdomType.WU] = "gb_msz_wu.png", [LuaConst.EHeroKingdomType.QUN] = "gb_msz_qun.png", } --------------------------- function UICountryWorldBossBattleRank:OnOpened(context) self:RegistSystemEvent(EventID.UI_CountryWorldBoss_UpdateOccupierInfo, self.UpdateOccupierInfo) end function UICountryWorldBossBattleRank:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.LoopScroll_Battle then UIWorldBossBattleRank.OnCellInit(self, scrollRect, index, cellTable, data) if not data.assistantName then -- 设置boss占有状态 local hasExtraReward = false -- 自身是否有额外奖励 local curOccupierPlayerID = BattleDataGetter.GetCurOccupierPlayerID() or BattleDataGetter.GetFinalOccupierPlayerID() if self:IncludeTargetPlayerId(data.info.playerIDList, curOccupierPlayerID) then UIUtils.SetActive(cellTable.effect_Owner, true) cellTable.effect_Owner:PlayUIEffect() hasExtraReward = true else cellTable.effect_Owner:StopUIEffect() UIUtils.SetActive(cellTable.effect_Owner, false) end -- 设置每个队伍的国别(只有相同国别玩家才可以进入队伍,所以设置国别使用队伍中的第一的玩家所在国别) local playerInfo = BattleDataGetter.GetPlayerInfo(data.info.playerIDList[1]) self:GetCountryIndexByCountryId(playerInfo.countryId, cellTable.group_Country, cellTable.uistate_Country) -- 设置是否是战胜国 if curOccupierPlayerID then local curOccupierplayerInfo = BattleDataGetter.GetPlayerInfo(curOccupierPlayerID) if curOccupierplayerInfo.countryId == playerInfo.countryId then hasExtraReward = true end end UIUtils.SetActive(cellTable.img_ExtraReward, hasExtraReward) end end end --------------------------- function UICountryWorldBossBattleRank:InitMyInfo() UIWorldBossBattleRank.InitMyInfo(self) -- 设置自身国家(使用战斗中的信息) local playerInfo = BattleDataGetter.GetPlayerInfo(BattleDataGetter.GetCurPlayerID()) if playerInfo then self:GetCountryIndexByCountryId(playerInfo.countryId, self.group_Country, self.uistate_Country) end -- 设置占领者信息 self:UpdateOccupierInfo() end function UICountryWorldBossBattleRank:UpdateDamageInfo(isForce) UIWorldBossBattleRank.UpdateDamageInfo(self, isForce) local curOccupierPlayerID = BattleDataGetter.GetCurOccupierPlayerID() or BattleDataGetter.GetFinalOccupierPlayerID() if curOccupierPlayerID ~= nil then local curOccupierPlayerInfo = BattleDataGetter.GetPlayerInfo(curOccupierPlayerID) local curOccupierPlayerIDList = BattleDataGetter.GetPlayerIDListOfTeam(curOccupierPlayerInfo.teamId) local hasExtraReward = false -- 自身是否有额外奖励 -- 设置自身占领特效 if self:IncludeTargetPlayerId(curOccupierPlayerIDList, BattleDataGetter.GetCurPlayerID()) then hasExtraReward = true end -- 设置是否是战胜国 & 对boss造成过伤害 if not hasExtraReward then hasExtraReward = self:IsVictoryCountry(curOccupierPlayerInfo) end UIUtils.SetActive(self.img_ExtraReward, hasExtraReward) else UIUtils.SetActive(self.img_ExtraReward, false) end end function UICountryWorldBossBattleRank:ReloadRankList(infoList) -- 设置伤害列表 for index, info in ipairs(infoList) do table.insert(self.loopDataList, {info = info, index = index}) table.insert(self.loopPrefabIndexs, 0) -- 设置帮助者列表 if self.DownTeamLeaderNameList[info.teamId] then local assistantList = self.worldBossBattle:GetAssistantListByTeamID(info.teamId) for _,assistant in ipairs(assistantList) do table.insert(self.loopDataList, assistant) table.insert(self.loopPrefabIndexs, 1) end end end self.LoopScroll_Battle:ReloadAll(self.loopDataList, self.loopPrefabIndexs) end -- 设置占领者信息(需要同步 额外奖励、伤害列表、占领国家) function UICountryWorldBossBattleRank:UpdateOccupierInfo() local curOccupierPlayerID = BattleDataGetter.GetCurOccupierPlayerID() or BattleDataGetter.GetFinalOccupierPlayerID() if curOccupierPlayerID ~= nil then UIUtils.SetActive(self.group_Owner.gameObject, true) UIUtils.SetActive(self.group_OwnerEmpty, false) local curOccupierPlayerInfo = BattleDataGetter.GetPlayerInfo(curOccupierPlayerID) if curOccupierPlayerInfo then local playerName = curOccupierPlayerInfo.teamLeaderName if MDL.Team.IsTeamId(curOccupierPlayerInfo.teamId) then playerName = string.FormatByIdsId(Const_IDS.IDS_Team_WorldBoss_Team, playerName) end UIUtils.SetLabel(self.group_Owner.txt_Name, playerName) self:GetCountryIndexByCountryId(curOccupierPlayerInfo.countryId, self.group_Owner.img_Country, self.group_Owner.uistate_Country, self.group_Owner.img_Country) end local curOccupierPlayerIDList = BattleDataGetter.GetPlayerIDListOfTeam(curOccupierPlayerInfo.teamId) local hasExtraReward = false -- 自身是否有额外奖励 -- 设置自身占领特效 if self:IncludeTargetPlayerId(curOccupierPlayerIDList, BattleDataGetter.GetCurPlayerID()) then hasExtraReward = true UIUtils.SetActive(self.effect_Owner, true) self.effect_Owner:PlayUIEffect() else self.effect_Owner:StopUIEffect() UIUtils.SetActive(self.effect_Owner, false) end -- 是否是战胜国 & 对boss造成过伤害 if not hasExtraReward then hasExtraReward = self:IsVictoryCountry(curOccupierPlayerInfo) end UIUtils.SetActive(self.img_ExtraReward, hasExtraReward) else self.effect_Owner:StopUIEffect() UIUtils.SetActive(self.effect_Owner, false) UIUtils.SetActive(self.img_ExtraReward, false) UIUtils.SetActive(self.group_OwnerEmpty, true) UIUtils.SetActive(self.group_Owner.gameObject, false) end -- 占领者信息发生变化需要刷新一下排行列表 self.LoopScroll_Battle:RefreshCells() end -- 玩家列表中是否包含目标PlayerId function UICountryWorldBossBattleRank:IncludeTargetPlayerId(playerIDList, targetPlayerId) for _, playerID in ipairs(playerIDList) do if playerID == targetPlayerId then return true end end return false end function UICountryWorldBossBattleRank:GetCountryIndexByCountryId(countryId, stateRootObj, stateObj, localImage) if countryId == nil or countryId < LuaConst.EHeroKingdomType.WEI or countryId > LuaConst.EHeroKingdomType.QUN then UIUtils.SetActive(stateRootObj.gameObject, false) else UIUtils.SetActive(stateRootObj.gameObject, true) stateObj:SetState(countryId - 1) -- c# index从0开始 if localImage then UTL.Item.SetLocalizationImage(nil, localImage, CountryIconName[countryId]) end end end function UICountryWorldBossBattleRank:IsVictoryCountry(curOccupierPlayerInfo) local playerInfo = BattleDataGetter.GetPlayerInfo(BattleDataGetter.GetCurPlayerID()) if playerInfo.countryId == curOccupierPlayerInfo.countryId then local damage = BattleDataGetter.GetDamageOfPlayer(BattleDataGetter.GetCurPlayerID()) damage = damage and FP.tonumberV1(damage) or 0 return damage > 0 end return false end return UICountryWorldBossBattleRank