local UITeamMatchPanel = UIViewClass()
local TeamMatchRefuseDelayTime = DataSheetManager.ConstData:GetDataByID("TeamMatchRefuseDelay").IntValue
local TeamMatchSuccessDelay = DataSheetManager.ConstData:GetDataByID("TeamMatchSuccessRefuseDelay").IntValue
local MatchErrorProtectionTime = 15
local TREASURE_ID_ADVANCED = 52 --高级藏宝图cfgID
local RED_COLOR_STR = "%d"
local GRAY_COLOR_STR = "%s"
function UITeamMatchPanel:OnOpened(context)
AuxUtil.StopAllTimeline()
CTL.Sound.PlayGameSound("UI_task")
self:RegistSystemEvent(EventID.UI_TeamMatch_MemberStateChanged, self.CheckMemberReady)
if not context then
logging.error(LTAG.ERROR, "没有匹配的相关信息!")
end
self.activityId = context.activityId
local activityData = DataSheetManager.ActivityData:GetDataByID(self.activityId)
UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS[activityData.Activity])
UIUtils.SetActive(self.UICommonPopUp.btn_Close, false)
local chooseTime = context.time
self:SetTimeAndAutoChoice(chooseTime, activityData.AutomaticAgree)
local matchMemberInfo = MDL.TeamMatch.GetMatchMemberInfo()
for i, v in ipairs(self.group_MatchHead) do
if matchMemberInfo[i] then
self:RefreshMemberHeadInfo(matchMemberInfo[i], v)
UIUtils.SetActive(v.gameObject, true)
else
UIUtils.SetActive(v.gameObject, false)
end
end
if self.activityId == LuaConst.ActivityType.GuildEscort then
UIUtils.SetLabelText(self.txt_GoPlay, Const_IDS["IDS_Escort_GetReady"])
else
UIUtils.SetLabelText(self.txt_GoPlay, Const_IDS["IDS_TeamConfirm_AllReadyIntoCopymap"])
end
self.delayExit = false
self:SetPushStyle(LuaConst.PushStyleEnum.CLOSENOTRECOVER)
if CTL.Team.IsSelfLeader() or CTL.Team.IsActivityAutoReady(self.activityId) then
self:OnClickReady()
end
if self.txt_Tip then
self.txt_Tip.text = string.FormatByIdsId(Const_IDS.IDS_DigTreasure_Team_ReadyTips, self.UICommonPopUp.txt_Title.text)
end
self:SetExtraRewardInfo(context.activityId)
self:StartRepeatFunc(self.MatchErrorProtectionClose, MatchErrorProtectionTime + chooseTime, 1)
end
function UITeamMatchPanel:MatchErrorProtectionClose()
CTL.Tips.AddTipsMsg(Const_IDS.IDS_OnlineTips_TryAgain)
self:CloseView()
end
function UITeamMatchPanel:RefreshMemberHeadInfo(memberInfo, cell)
CTL.Character.SetPortraitAndFrame(cell.UIHeroHead190, memberInfo.PortraitId, memberInfo.FrameId, memberInfo.PlayerLevel)
cell.lab_RoleName.text = memberInfo.PlayerName
--将确认勾选先默认隐藏
UIUtils.SetActive(cell.img_Ready, false)
UIUtils.SetActive(cell.img_Refuse, false)
CTL.Player.OperateGenderImage(cell.image_Gender, memberInfo.sex)
--同势力显示徽记
if MDL.Guild.IsSameGuild(memberInfo.guildId) then
UIUtils.SetLabel(cell.txt_GuildInitiate,memberInfo.emblemContent)
if memberInfo.emblemFrame > 0 then
UTL.Item.SetAtlasSprite(cell.img_GuildMark, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(memberInfo.emblemFrame).Image)
end
UIUtils.SetActive(cell.txt_GuildInitiate, true)
UIUtils.SetActive(cell.img_GuildMark, true)
else
UIUtils.SetActive(cell.txt_GuildInitiate, false)
UIUtils.SetActive(cell.img_GuildMark, false)
end
end
function UITeamMatchPanel:CheckMemberReady(state, playerName)
local index = MDL.TeamMatch.GetMatchMemberIndexByName(playerName)
if state then
CTL.Sound.PlayGameSound("UI_online")
UIUtils.SetActive(self.group_MatchHead[index].img_Ready, true)
UIUtils.SetActive(self.group_MatchHead[index].img_Refuse, false)
if MDL.TeamMatch.IsMatchSuccessful() then
self.fill_Yellow:EndTimer()
self.fill_Blue:EndTimer()
UIUtils.SetActive(self.bg_MatchTime, false)
--先单独判断你是不是3V3,后边添加方法统一进行判断
if not self.delayExit and (self.activityId == LuaConst.ActivityType.TVT or self.activityId == LuaConst.ActivityType.SyncFourCountryWar) then
UIUtils.SetLabelText(self.txt_GoPlay, Const_IDS["IDS_TeamConfirm_AllReadyIntoMatch"])
self.delayExit = true
self:StopRepeatFunc(self.OnUpdateFun)
self:StartRepeatFunc(self.OnUpdateFun, TeamMatchSuccessDelay)
end
end
else
self.btn_Ready:SetGray(true)
self.btn_Refuse:SetGray(true)
if self.group_MatchHead[index] == nil then
logging.error(LTAG.ERROR,"self.group_MatchHead index 越界",index)
else
UIUtils.SetActive(self.group_MatchHead[index].img_Ready, false)
UIUtils.SetActive(self.group_MatchHead[index].img_Refuse, true)
end
if CTL.TeamMatch.IsShowRefuseIn(self.activityId) then
if self.activityId == LuaConst.ActivityType.GuildEscort then
CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Escort_RefuseStart"]), playerName)
else
CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS["IDS_TeamConfirm_RefuseIn"]), playerName)
end
else
CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS["IDS_TeamConfirm_RefuseMatch"]), playerName)
end
if not self.delayExit then
self.delayExit = true
self:StopRepeatFunc(self.OnUpdateFun)
self:StartRepeatFunc(self.OnUpdateFun, TeamMatchRefuseDelayTime)
end
end
self.state_Button:SetState(MDL.TeamMatch.GetMatchConfirmState())
end
function UITeamMatchPanel:SetTimeAndAutoChoice(time, isAutoReady)
UIUtils.SetActive(self.fill_Blue.gameObject, not isAutoReady)
UIUtils.SetActive(self.img_AutoRefuseBg, not isAutoReady)
UIUtils.SetActive(self.fill_Yellow.gameObject, isAutoReady)
UIUtils.SetActive(self.img_AutoReadyBg, isAutoReady)
UIUtils.SetActive(self.bg_MatchTime, true)
if isAutoReady then
self.fill_Yellow:ResetAndBeginCustomTimer(false, time, 0, UIUtils.GetLocalizedTxt(Const_IDS["IDS_TeamMatch_AutoAgree"]), 1)
else
self.fill_Blue:ResetAndBeginCustomTimer(false, time, 0, UIUtils.GetLocalizedTxt(Const_IDS["IDS_TeamMatch_AutoRefuse"]), 1)
end
self.isAutoReady = isAutoReady
self:StartRepeatFunc(self.OnUpdateFun, time)
end
function UITeamMatchPanel:OnUpdateFun(deltaTime, timeSinceUpdate)
if self.delayExit then
self:CloseView()
end
end
function UITeamMatchPanel:OnClickReady()
MDL.TeamMatch.MatchStateConfirmReq(true)
self.btn_Ready:SetGray(true)
self.btn_Refuse:SetGray(true)
end
function UITeamMatchPanel:OnClickCancel()
MDL.TeamMatch.MatchStateConfirmReq(false)
self.btn_Ready:SetGray(true)
self.btn_Refuse:SetGray(true)
self:CloseView()
end
function UITeamMatchPanel:OnButtonClicked(comp)
if comp == self.btn_Ready then
self:OnClickReady()
elseif comp == self.btn_Refuse then
self:OnClickCancel()
end
end
function UITeamMatchPanel:OnClosed()
MDL.TeamMatch.ClearMatchInfo()
UIUtils.SetActive(self.UICommonPopUp.btn_Close, true)
end
function UITeamMatchPanel:OnValueChanged(comp, state)
if comp == self.toggle_extra then
local info = MDL.Task.GetTreasureRewardInfo()
if state ~= info.isOpenSwitch then
MDL.Task.ChangeDigTreasureSwitchReq(state)
end
end
end
function UITeamMatchPanel:SetExtraRewardInfo(activityId)
if activityId == LuaConst.ActivityType.TreasureDungeon then
local info = MDL.Task.GetTreasureRewardInfo()
local extraRewardCount = info.rewardCountLeft
local extraTotalCount = DataSheetManager.ConstData:GetDataByID("DigTreasureDailyHelpTimes").IntValue
local numLabel = extraRewardCount .. "/" .. extraTotalCount
local treasureAdvancedCount = MDL.Bag.GetItemCount(TREASURE_ID_ADVANCED)
-- 队长与队员不同的显示逻辑
if CTL.Team.IsSelfLeader() then
UIUtils.SetLabelText(self.txt_ChallengeChances, Const_IDS.IDS_DigTreasure_NewHint3)
if extraRewardCount > 0 then
UIUtils.SetActive(self.group_ExtraRewardNum.gameObject, true)
self.toggle_extra.isOn = info.isOpenSwitch
UIUtils.SetLabelText(self.txt_tip, Const_IDS.IDS_DigTreasure_NewHint1)
UIUtils.SetLabel(self.txt_num, numLabel)
end
else
UIUtils.SetActive(self.group_DigTreasureTips.gameObject, true)
self.txt_ChallengeChances.text = nil
UIUtils.SetActive(self.group_ExtraRewardNum.gameObject, true)
if extraRewardCount > 0 then
UIUtils.SetLabel(self.txt_num1, numLabel)
UIUtils.SetLabel(self.txt_num2, treasureAdvancedCount)
self.toggle_extra.isOn = info.isOpenSwitch
UIUtils.SetLabelText(self.txt_tip, Const_IDS.IDS_DigTreasure_NewHint1)
UIUtils.SetLabel(self.txt_num, numLabel)
else
UIUtils.SetActive(self.group_ExtraRewardNum.gameObject, false)
UIUtils.SetActive(self.group_txt.gameObject, false)
UIUtils.SetActive(self.txt_ExtraRewardTip.gameObject, true)
if treasureAdvancedCount > 0 then
UIUtils.SetLabelText(self.txt_ExtraRewardTip, Const_IDS.IDS_DigTreasure_NewHint4)
UIUtils.SetLabel(self.txt_num2, treasureAdvancedCount)
else
self.txt_ExtraRewardTip.text = string.format(GRAY_COLOR_STR, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DigTreasure_NewHint5))
self.txt_num2.text = string.format(RED_COLOR_STR, treasureAdvancedCount)
end
end
end
else
self.txt_ChallengeChances.text = CTL.TeamMatch.GetMatchDesc(activityId)
end
end
return UITeamMatchPanel