local UIDigTreasureBattelResult = UIViewClass() local DigTreasureFinishTime = DataSheetManager.ConstData:GetDataByID("DigTreasureFinishTime").IntValue --自动退出时间 local DigTreasureFinishTimeAuto = DataSheetManager.ConstData:GetDataByID("DigTreasureFinishTimeAuto").IntValue --弹tips提示时间 local TagType = 2 --用于设置 item cell 的样式,对应 private.SymbolShow 表。 function UIDigTreasureBattelResult:OnOpened(context) self.group_ResultInfo:PlayAnim() self:RegistSystemEvent(EventID.Interact_BattleResultThumbsUp, self.ThumbsUpRefresh) if context.hasReward then --这里需要区分协议信息是从 ShowDigTreasureSummary 还是 OnPushDigTreasureResult 回来的。 if context.digTreasureInfo and context.digTreasureInfo.extraRewards then for i, v in ipairs(context.digTreasureInfo.extraRewards) do self.loop_Materials:AddData({extraRewards = v, type = 2}, 0) end end if context.digTreasureInfo and context.digTreasureInfo.rewards then for i, v in ipairs(context.digTreasureInfo.rewards) do self.loop_Materials:AddData({rewards = v, type = 1}, 0) end end if context.extraRewards then for i, v in ipairs(context.extraRewards) do self.loop_Materials:AddData({extraRewards = v, type = 2}, 0) end end if context.rewards then for i, v in ipairs(context.rewards) do self.loop_Materials:AddData({rewards = v, type = 1}, 0) end end CTL.Sound.PlayGameSound("MUSIC_Victory") else UIUtils.SetActive(self.reward_Group, false) if context.headInfos then CTL.Sound.PlayGameSound("MUSIC_Victory") UIUtils.SetLabelText(self.txt_NoReward, Const_IDS.IDS_DigTreasure_NoHelpTime) else CTL.Sound.PlayGameSound("MUSIC_Fail") UIUtils.SetLabelText(self.txt_NoReward, Const_IDS.IDS_DigTreasure_Defeat) end end self.txt_TimeSpent.text = string.FormatByIdsId(Const_IDS.IDS_GuildWar_TotalTime, UTL.Time.FormatTimeSeconds(context.passTime)) if context.headInfos then self:SetPlayerInfo(1) self:SetPlayerInfo(2) self:SetPlayerInfo(3) self:ThumbsUpRefresh() UIUtils.SetActive(self.team_Group, true) CTL.Task.OnSyncDigTreasureQuickUse() local levelInfoData = BattleDataGetter.GetLevelInfoData() local levelName = UIUtils.GetLocalizedTxt(Const_IDS[levelInfoData.LevelNameIDS]) self.txt_FinalLevel.text = string.FormatByIdsId(Const_IDS.IDS_DigTreasure_Result, levelName) self:StartRepeatFunc(self.OnBattleFinishFun,DigTreasureFinishTime - DigTreasureFinishTimeAuto,1) else UIUtils.SetActive(self.team_Group, false) self:StartRepeatFunc(self.OnBattleExitFun, 0) end UIManager.ActiveUIModle(false, "UIDigTreasureBattelResult") end function UIDigTreasureBattelResult:OnBattleFinishFun(deltaTime, time) self:StartRepeatFunc(self.OnBattleExitFun, 0) end function UIDigTreasureBattelResult:OnBattleExitFun(deltaTime, time) if time >= DigTreasureFinishTimeAuto then MDL.Level.SendRoleLeaveFuben() self:CloseView() end self.txt_Back.text = string.FormatByIdsId(Const_IDS.IDS_ClimbTower_AutoQuit, DigTreasureFinishTimeAuto - time) end function UIDigTreasureBattelResult:OnButtonClicked(comp) if comp == self.event_Exit then MDL.Level.SendRoleLeaveFuben() else for i, v in ipairs(self.players) do if v.img_AddFriend == comp then self.players[i].group_Add:SetState(1) MDL.Friend.SendApplyFriend(self.context.headInfos[i].acid) elseif v.img_ThumbUp == comp then MDL.ThumbsUp.ThumbsUpReq(self.context.thumbsUpID, self.context.headInfos[i].acid) elseif v.img_ThumbUpped == comp then CTL.Tips.AddTipsMsg(Const_IDS.IDS_RecommendFriends_AlreadyThumbUp) CTL.Sound.PlayGameSound("UI_invalid") end end end end function UIDigTreasureBattelResult:OnCellInit(scrollRect, index, cellTable, data) if data.type == 1 then UTL.Item.SetItemCell(cellTable.Item, data.rewards.ItemId, data.rewards.ItemCount) elseif data.type == 2 then UTL.Item.SetItemCell(cellTable.Item, data.extraRewards.ItemId, data.extraRewards.ItemCount, nil, TagType, nil) end end function UIDigTreasureBattelResult:OnCellClicked(scrollRect, index, cellTable, target, data) if data.extraRewards and data.extraRewards.ItemId then UTL.ItemTips.ShowCommonTipsById(data.extraRewards.ItemId, true, false) else UTL.ItemTips.ShowCommonTipsById(data.rewards.ItemId, true, false) end end function UIDigTreasureBattelResult:SetPlayerInfo(index) local collection = self.players[index] local playerInfo = self.context.headInfos[index] if playerInfo == nil then collection.gameObject:SetActive(false) return end collection.gameObject:SetActive(true) CTL.Character.SetPortraitAndFrame(collection.UIHeroHead150, playerInfo.PortraitId, playerInfo.FrameId, playerInfo.level) collection.txt_PlayerName.text = playerInfo.name if playerInfo.acid == BattleDataGetter.GetAcID() then UIUtils.SetActive(collection.group_Add, false) UIUtils.SetActive(collection.group_ThumbUp, false) else UIUtils.SetActive(collection.group_Add, true) UIUtils.SetActive(collection.group_ThumbUp, true) if MDL.Friend.IsPlayerFriend(playerInfo.acid) then collection.group_Add:SetState(1) else collection.group_Add:SetState(0) end end end function UIDigTreasureBattelResult:SetPlayerThumbsUp(index) local collection = self.players[index] local playerInfo = self.context.headInfos[index] if playerInfo == nil then return end local thumbInfo = MDL.ThumbsUp.GetThumbsUpTipsList() local num = MDL.ThumbsUp.GetThumbsUpNumber(playerInfo.acid) if playerInfo.acid == BattleDataGetter.GetAcID() then collection.group_ThumbUp:SetState(1) UIUtils.SetActive(collection.group_ThumbUp, num > 0) else if MDL.ThumbsUp.SelfThumbsUpPlayer(playerInfo.acid) then collection.group_ThumbUp:SetState(1) else collection.group_ThumbUp:SetState(0) end end if num >= 1 then collection.txt_LikesNumber.text = num UIUtils.SetActive(collection.img_NumberBg, true) else collection.txt_LikesNumber.text = nil UIUtils.SetActive(collection.img_NumberBg, false) end end function UIDigTreasureBattelResult:ThumbsUpRefresh(msg) if msg and msg.TargetACID == BattleDataGetter.GetAcID() then local info = self:GetPlayerInfo(msg.OriginACID) if info then CTL.ThumbsUp.ShowThumbsUpTips(LuaConst.ActivityType.TreasureDungeon, false, info.name, info.mainHeroId) end end self:SetPlayerThumbsUp(1) self:SetPlayerThumbsUp(2) self:SetPlayerThumbsUp(3) end function UIDigTreasureBattelResult:GetPlayerInfo(acid) for i,v in ipairs(self.context.headInfos) do if acid == v.acid then return v end end end function UIDigTreasureBattelResult:OnClosed() UIManager.ActiveUIModle(true, "UIDigTreasureBattelResult") MDL.ThumbsUp.ClearThumbsUpList() end return UIDigTreasureBattelResult