local UIGuildWarPersonalData = UIViewClass() local Scores = DataSheetManager.GuildWarPlayerGraph:GetDataByID(1000).Value_Table local MVPHeroKillPoint = DataSheetManager.ConstData:GetDataByID("MVPHeroKillPoint").IntValue local MVPHeroAssistPoint = DataSheetManager.ConstData:GetDataByID("MVPHeroAssistPoint").IntValue local MVPHeroDeathPoint = DataSheetManager.ConstData:GetDataByID("MVPHeroDeathPoint").IntValue local PolygonMaxValue = 5 function UIGuildWarPersonalData:OnOpened(context) local battleData = context.data if context.isChat then self.event_Save.gameObject:SetActive(false) self.event_Share.gameObject:SetActive(false) self.event_Close.gameObject:SetActive(true) else local remindTime = DataSheetManager.ConstData:GetDataByID("GuildWarPlayerRatingUIRemindTime").IntValue local autoCloseTime = DataSheetManager.ConstData:GetDataByID("GuildWarPlayerRatingUIAutoCloseTime").IntValue self.curShowTips = true end self.txt_PersonalMark_Number.text = battleData.score self.txt_PersonalMark_Number_1.text = battleData.killNum self.txt_PersonalMark_Number_2.text = battleData.continuousKilling self.txt_PersonalMark_Number_3.text = battleData.assiantNum self.txt_PersonalMark_Number_4.text = battleData.seriousInjury self.txt_PersonalMark_Number_5.text = battleData.occupycamp self.txt_PersonalMark_Number_6.text = battleData.killBoss self.txt_PersonalMark_Number_7.text = battleData.handInResource self.txt_PersonalMark_Number_8.text = battleData.wallDemage self.txt_WarCapability.text = battleData.gsSum self.txt_GuildName.text = context.name -- 设置自己头像 CTL.Character.SetSelfPortraitAndFrame(self.UIHeroHead150) self.kdaHeros = battleData.kda self:CalSixData(battleData) self:SetLineUp() self:SetStrongest() self:RegistTriggerEvent(self.group_Features, UIEventTriggerType.PointerDown) self:RegistTriggerEvent(self.group_Features, UIEventTriggerType.PointerUp) end function UIGuildWarPersonalData:SetLineUp() for i=1,3 do local obj = self.group_Frame[i] UTL.Item.ItemSquareIconByHeroId(self.kdaHeros[i].heroId1, obj.img_HeroHead1, obj.bg_HeroHead1, nil, MDL.HeroAwaken.GetIsHeroAwaken(self.kdaHeros[i].heroId1)) UTL.Item.ItemSquareIconByHeroId(self.kdaHeros[i].heroId2, obj.img_HeroHead2, obj.bg_HeroHead2, nil, MDL.HeroAwaken.GetIsHeroAwaken(self.kdaHeros[i].heroId2)) end end function UIGuildWarPersonalData:OnBackButtonPressed() self:OnButtonClicked(self.event_Close) end function UIGuildWarPersonalData:OnButtonClicked(comp) if comp == self.event_BackToTown then MDL.Level.SendRoleLeaveFuben() elseif comp == self.event_Share then self.group_Channel.gameObject:SetActive(not self.group_Channel.gameObject.activeSelf) elseif comp == self.event_Close then self:CloseView() elseif comp == self.btn_World then self:SendMsg(MDL.ChannelChat.GetChannelIdByCfgID(MDL.ChannelChat.ChannelCfgId.World)) CTL.Tips.AddTipsMsg(Const_IDS.IDS_ShareToWorldChannelSucceed) elseif comp == self.btn_Guild then self:SendMsg(MDL.ChannelChat.GetChannelIdByCfgID(MDL.ChannelChat.ChannelCfgId.Legion)) CTL.Tips.AddTipsMsg(Const_IDS.IDS_ShareToGuildChannelSucceed) end end function UIGuildWarPersonalData:SendMsg(id) local excelData = DataSheetManager.GuildWarGroup:GetDataByID(self.context.tagId) local groupName = UIUtils.GetLocalizedTxt(Const_IDS[excelData.GroupName]) local data = MDL.GuildWar.GetBattleInfo() local str = string.FormatByIdsId(Const_IDS.IDS_GuildWar_PlayerRatingShareMsg, groupName, data.selfCamp.guildInfo.guildName, data.enemyCamp.guildInfo.guildName ,self.txt_Mark.text) MDL.ChannelChat.SendGuildWarBattleMsg(self.context.data,str,id) self.group_Channel.gameObject:SetActive(not self.group_Channel.gameObject.activeSelf) end function UIGuildWarPersonalData:SetTitle(score) local decIds = nil local preId = nil local data = nil for i,v in DataSheetManager.GuildWarPlayerRating:GetEnumerator() do if v.ID == score then decIds = v.RatingText data = v break elseif v.ID > score and preId then local preData = DataSheetManager.GuildWarPlayerRating:GetDataByID(preId) decIds = preData.RatingText data = v break end preId = v.ID end if not decIds then local lastData = DataSheetManager.GuildWarPlayerRating:GetDataByID(preId) data = lastData decIds = lastData.RatingText end --Image = 3,UIID = 4, self.txt_Switch:SetState(data.UIID) local itemIcon= string.format(ConstAssetPathConfig.Path28,data.Image) UIUtils.SetImageByAssetBundle(self.img_PersonalMarkFrame,itemIcon) UIUtils.SetLabelText(self.txt_Mark,Const_IDS[decIds]) end function UIGuildWarPersonalData:SetStrongest() local list = self.kdaHeros local heroScore1 = self:CalStrongestScore(list[1].k,list[1].d,list[1].a) local heroScore2 = self:CalStrongestScore(list[2].k,list[2].d,list[3].a) local heroScore3 = self:CalStrongestScore(list[3].k,list[3].d,list[3].a) local info = nil if heroScore1 >= heroScore2 and heroScore1>=heroScore3 then info = list[1] elseif heroScore2 >= heroScore3 and heroScore2 >= heroScore1 then info = list[2] elseif heroScore3 >= heroScore2 and heroScore3 >= heroScore1 then info = list[3] end local heroId = info.heroId1 UTL.Item.ItemSquareIconByHeroId(heroId, self.group_HeroHead1.img_HeroHead, self.group_HeroHead1.bg_HeroHead, nil, MDL.HeroAwaken.GetIsHeroAwaken(heroId)) self.group_FeatureDatas[1].text = info.k self.group_FeatureDatas[2].text = info.a self.group_FeatureDatas[3].text = info.d end function UIGuildWarPersonalData:CalHeroScore(k,d,a) local _, kValue = self:CalData(2,k,true) local _, dValue = self:CalData(5,d,false) local _, aValue = self:CalData(6,a,true) return kValue + dValue + aValue end function UIGuildWarPersonalData:CalSixData(context) local kill,killScore = self:CalData(2,context.killNum,true) local score,scoreValue = self:CalData(1,context.score,true) local continuousKilling,continuousKillingScore = self:CalData(3,context.continuousKilling,true) local assistNum,assistNumScore = self:CalData(6,context.assiantNum,true) local seriousInjury,seriousInjuryScore = self:CalData(5,context.seriousInjury,false) local kdaValue = (context.killNum + context.assiantNum)/(context.seriousInjury == 0 and 1 or context.seriousInjury) local kda,kdaScore = self:CalData(4,kdaValue,true) local param = score..","..kill..","..continuousKilling..","..kda..","..seriousInjury..","..assistNum UIUtils.SetPolygonVerticesValue(self.img_polygon,param) self:SetTitle(kill+score+continuousKilling+assistNum+seriousInjury+kda) self.scores[1].text = assistNumScore self.scores[2].text = scoreValue self.scores[3].text = killScore self.scores[4].text = seriousInjuryScore self.scores[5].text = kdaScore self.scores[6].text = continuousKillingScore end function UIGuildWarPersonalData:CalData(id,value,isAscending) local resScore = nil value = value or 0 local data = DataSheetManager.GuildWarPlayerGraph:GetDataByID(id) for i,v in ipairs(data.Value_Table) do if v.Param == value then resScore = Scores[i].Param break end if isAscending then if v.Param > value then local preData = data.Value_Table[i-1] local preScore = Scores[i-1].Param local curScore = Scores[i].Param resScore = (value - preData.Param)*(curScore-preScore)/(v.Param - preData.Param) + preScore break end else if i == 1 then if v.Param < value then resScore = Scores[i].Param break end end if v.Param < value then local preData = data.Value_Table[i-1] local preScore = Scores[i-1].Param local curScore = Scores[i].Param resScore = (preData.Param - value)*(curScore-preScore)/(preData.Param- v.Param)+ preScore break end end end if not resScore then return PolygonMaxValue,Scores[#Scores].Param else local maxScore = PolygonMaxValue/Scores[#Scores].Param local resValue = resScore*maxScore if resValue> PolygonMaxValue then resValue = PolygonMaxValue return resValue,Scores[#Scores].Param end if resValue <= 1 then resValue = 1 end return resValue,resScore end end function UIGuildWarPersonalData:CalStrongestScore(k,d,a) return k*MVPHeroKillPoint + MVPHeroAssistPoint*a - MVPHeroDeathPoint*d end function UIGuildWarPersonalData:OnPointerDown(comp, eventData) self.group_Explain.gameObject:SetActive(true) end function UIGuildWarPersonalData:OnPointerUp(comp, eventData) self.group_Explain.gameObject:SetActive(false) end return UIGuildWarPersonalData