local UIGuildWarDataView = UIViewClass() local OffLineColor = Color.New(174/255, 176/255, 182/255, 1) --离线字色 local OnLineColor = Color.New(1, 1, 1, 1) --在线字色 local SelfColor = Color.New(232/255, 213/255, 136/255, 1) --离线字色 function UIGuildWarDataView:OnOpened(context) self:RegistSystemEvent(EventID.UI_GuildWarInfoUpdate, self.OnGuildWarInfoUpdate) MDL.GuildWar.C2GGetGuildWarPlayerScore() if BattleDataGetter.IsGuildWarLevel() then self:StartRepeatFunc(self.OnUpdateFun, 1) end self.selfRank = {} self.enemyRank = {} local data = MDL.GuildWar.GetBattleInfo() local selfGuildInfo = data.selfCamp.guildInfo local enemyGuildInfo = data.enemyCamp.guildInfo UIUtils.SetLabel(self.group_Teammate.txt_GuildName, selfGuildInfo.guildName) -- self跨服信息 if CTL.GuildWar.IsShowCrossServerUI() then local serverId = selfGuildInfo.zoneInfo.serverId UIUtils.SetActive(self.group_Teammate.txt_CrossServer, true) UIUtils.SetLabel(self.group_Teammate.txt_CrossServer, string.FormatByIdsId(Const_IDS["IDS_CrossSever_SeverInfoText"], CTL.CrossServer.GetServerIDAndServerNameByServerID(serverId)) ) else UIUtils.SetActive(self.group_Teammate.txt_CrossServer, false) end UIUtils.SetLabel(self.group_Enemy.txt_GuildName, enemyGuildInfo.guildName) -- enemy跨服信息 if CTL.GuildWar.IsShowCrossServerUI() then local serverId = enemyGuildInfo.zoneInfo.serverId UIUtils.SetActive(self.group_Enemy.txt_CrossServer, true) UIUtils.SetLabel(self.group_Enemy.txt_CrossServer, string.FormatByIdsId(Const_IDS["IDS_CrossSever_SeverInfoText"], CTL.CrossServer.GetServerIDAndServerNameByServerID(serverId)) ) else UIUtils.SetActive(self.group_Enemy.txt_CrossServer, false) end self.group_Teammate.txt_GuildNameInitiate.text = selfGuildInfo.emblemContent self.group_Enemy.txt_GuildNameInitiate.text = enemyGuildInfo.emblemContent UTL.Item.SetAtlasSprite(self.group_Teammate.img_GuildFrame, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(selfGuildInfo.emblemFrame).Image) UTL.Item.SetAtlasSprite(self.group_Enemy.img_GuildFrame, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(enemyGuildInfo.emblemFrame).Image) self:RegistTriggerEvent(self.group_MyData.group_Features, UIEventTriggerType.PointerDown) self:RegistTriggerEvent(self.group_MyData.group_Features, UIEventTriggerType.PointerUp) end function UIGuildWarDataView:OnGuildWarInfoUpdate(msg) local data = MDL.GuildWar.GetBattleInfo() local isWin = false if data.selfIsRed then self.selfRank = msg.redRank self.enemyRank = msg.blueRank else self.selfRank = msg.blueRank self.enemyRank = msg.redRank end local score = 0 local roomType for i,v in ipairs(self.selfRank) do if v.acid == BattleDataGetter.GetAcID() then score = v.score roomType = v.roomType end end if self.curIndex == nil then self.toggles_Tab:SelectIndex(roomType) else self:ShowArrayByIndex(self.curIndex) end self:ShowSelfInfo(score) end function UIGuildWarDataView:OnValueChanged(comp, value) if comp == self.toggles_Tab then self:ShowArrayByIndex(value) end end function UIGuildWarDataView:ShowMembersCount(selfRank,enemyRank) local selfOnlineCount = 0 local enemyOnlineCount = 0 for i,v in ipairs(selfRank) do if v.inBattle then selfOnlineCount = selfOnlineCount + 1 end end for i,v in ipairs(enemyRank) do if v.inBattle then enemyOnlineCount = enemyOnlineCount + 1 end end selfOnlineCount = UTL.Color.FormatGreenColor(selfOnlineCount) enemyOnlineCount = UTL.Color.FormatGreenColor(enemyOnlineCount) self.group_Teammate.txt_Num.text = string.FormatByIdsId(Const_IDS.IDS_GuildWar_ABattleGroundPlayerNum, selfOnlineCount ,#selfRank) self.group_Enemy.txt_Num.text = string.FormatByIdsId(Const_IDS.IDS_GuildWar_ABattleGroundPlayerNum, enemyOnlineCount ,#enemyRank) end function UIGuildWarDataView:ShowArrayByIndex(index) local selfRank = nil local enemyRank = nil if index == 0 then self.group_Teammate.loop_PlayerData:ReloadAll(self.selfRank) self.group_Enemy.loop_PlayerData:ReloadAll(self.enemyRank) selfRank = self.selfRank enemyRank = self.enemyRank else selfRank = self:FindByType(self.selfRank,index) enemyRank = self:FindByType(self.enemyRank,index) self.group_Teammate.loop_PlayerData:ReloadAll(selfRank) self.group_Enemy.loop_PlayerData:ReloadAll(enemyRank) end self.curIndex = index self:ShowMembersCount(selfRank,enemyRank) end function UIGuildWarDataView:FindByType(rankList, index) local list = {} for i,v in ipairs(rankList) do if v.roomType == index then table.insert(list, v) end end return list end function UIGuildWarDataView:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIGuildWarDataView:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() end end function UIGuildWarDataView:OnCellInit(scrollRect, index, cellTable, data) cellTable.txt_PlayerName.text = data.playerName cellTable.txt_ScoreNum.text = data.score cellTable.txt_KillNum.text = data.killNum cellTable.txt_AssistNum.text = data.assiantNum cellTable.txt_DeathNum.text = data.seriousInjury if index % 2 == 0 then cellTable.img_Bright.gameObject:SetActive(true) cellTable.img_Dark.gameObject:SetActive(false) else cellTable.img_Bright.gameObject:SetActive(false) cellTable.img_Dark.gameObject:SetActive(true) end if data.inBattle then if data.playerName == BattleDataGetter.GetPlayerName() then cellTable.txt_PlayerName.color = SelfColor else cellTable.txt_PlayerName.color = OnLineColor end cellTable.txt_ScoreNum.color = OnLineColor cellTable.txt_KillNum.color = OnLineColor cellTable.txt_AssistNum.color = OnLineColor cellTable.txt_DeathNum.color = OnLineColor else cellTable.txt_PlayerName.color = OffLineColor cellTable.txt_ScoreNum.color = OffLineColor cellTable.txt_KillNum.color = OffLineColor cellTable.txt_AssistNum.color = OffLineColor cellTable.txt_DeathNum.color = OffLineColor end cellTable.img_Kill.gameObject:SetActive(not data.isOnline) end function UIGuildWarDataView:ShowSelfInfo(score) local obj = self.group_MyData obj.txt_WarCapability.text = MDL.Player.GetLineUpGs() obj.txt_GuildName.text = BattleDataGetter.GetPlayerName() CTL.Character.SetSelfPortraitAndFrame(obj.UIHeroHead150) local killNum, continuousKilling, assistNum, seriousInjury, occupycamp, killBoss, wallDemage, handInResource if BattleDataGetter.IsGuildWarWaitingArea() then killNum, continuousKilling, assistNum, seriousInjury, occupycamp, killBoss, wallDemage, handInResource = 0,0,0,0,0,0,0,0 else killNum, continuousKilling, assistNum, seriousInjury, occupycamp, killBoss, wallDemage, handInResource = BattleDataGetter.GetGuildWarBattleInfo_MySelf() end local list = {killNum, continuousKilling, assistNum, seriousInjury, occupycamp, killBoss , handInResource, wallDemage} for i,v in ipairs(list) do obj["txt_PersonalMark_Number_"..i].text = v end obj.txt_PersonalMark_Number.text = score or 0 end function UIGuildWarDataView:OnUpdateFun() MDL.GuildWar.C2GGetGuildWarPlayerScore() end function UIGuildWarDataView:OnPointerDown(comp, eventData) if GameAppInfo.IsVietnamPackage() then self.group_MyData.group_Explain_VN.gameObject:SetActive(true) else self.group_MyData.group_Explain.gameObject:SetActive(true) end end function UIGuildWarDataView:OnPointerUp(comp, eventData) if GameAppInfo.IsVietnamPackage() then self.group_MyData.group_Explain_VN.gameObject:SetActive(false) else self.group_MyData.group_Explain.gameObject:SetActive(false) end end return UIGuildWarDataView