local UIHeroLightEffectTool = require "View/Common/UIHeroLightEffectTool" local UITeamMyTeam = UIViewClass() local ConstShowParams = { [1] = { posX = 0.6, posY = -2.6, scale = 0.8 }, [2] = { posX = -0.9, posY = -2.6, scale = 0.8 }, [3] = { posX = -2.4, posY = -2.6, scale = 0.8 }, } local ConstShowParams_RatioPad4_3 = { [1] = { posX = 0.3, posY = -2.3 , scale = 0.7 }, [2] = { posX = -0.8, posY = -2.3, scale = 0.7 }, [3] = { posX = -2, posY = -2.3, scale = 0.7 }, } local ConstLightPath = ConstAssetPathConfig.LightLeft function UITeamMyTeam:OnOpened(context) UIUtils.SetActive(self.btn_MatchTeam, false) self:RegistSystemEvent(EventID.UI_Team_TeamInfoChange, self.RefreshMyTeamPanel) self:RegistSystemEvent(EventID.UI_Team_MemberInfoChange, self.RefreshTeammateInfo) self:RegistSystemEvent(EventID.UI_Team_MemberInfoChange, self.RefreshButtonState) self:RegistSystemEvent(EventID.UI_Team_LeaveTeam, self.SelectParentToggleIndex) self:RegistSystemEvent(EventID.UI_Team_ApplyInfoHandle, self.RefreshApplyButtonRedPoint) MDL.Team.TeamOtherPeopleInfoReq() self:RefreshApplyButtonRedPoint(true) self:InitScene() self:RefreshMyTeamPanel() self.parentView = context.parentView self.toggle_AutoAccept.isOn = MDL.Team.IsAutoAccept UIUtils.SetActive(self.toggle_AutoAccept, true) self.toggle_AutoFollow.isOn = MDL.Team.IsAutoFollow UIUtils.SetActive(self.toggle_AutoFollow, true) self:SetShoutCountdown(CTL.Team.GetShutTimeCD()) end function UITeamMyTeam:InitScene() self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.obj_Model) UTL.UIRender.Create2DSceneTrans(self.modelComponentDataHandle, ConstAssetPathConfig.Common2DScenePrefab, 1600, 0, 1600, ConstAssetPathConfig.DefaultImage, true) UTL.UIRender.SetHeroParentPos(self.modelComponentDataHandle, 0.5, 1.2, 0) -- 设置模型位移信息 end function UITeamMyTeam:OnCreated() self.heroLightEffectDatas = UIHeroLightEffectTool.CreateHeroLightEffectDatas(true) end function UITeamMyTeam:RefreshApplyButtonRedPoint(isAdd) local length = #MDL.Team.GetApplyTeamList() length = isAdd and length or length - 1 self.btn_ApplyList:SetRedPoint(length > 0) end function UITeamMyTeam:SelectParentToggleIndex() if not CTL.Team.IsInTeam() then self.parentView:SelectToggleIndex(0) end end function UITeamMyTeam:OnClickShout(isGuild) if isGuild then if MDL.Guild.IsHasGuild() == false then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Chat_ConditionLegion) return end end local cdTime = CTL.Team.GetShutTimeCD() self:SetShoutCountdown(cdTime) if cdTime == 0 then CTL.Team.ShutTeamRecruitMsg(false, isGuild) self:SetShoutCountdown(CTL.Team.GetShutTimeCD()) end end function UITeamMyTeam:SetShoutCountdown(cdTime) if cdTime > 0 then self.txt_ShoutCountTime:ResetAndBeginCustomTimer(false, cdTime, 0, UIUtils.GetLocalizedTxt(Const_IDS["IDS_TeamUI_Myteam_RecruitingTime"]), 1) self.event_Shout:SetGray(true) self:StartRepeatFunc(self.OnUpdateFun, cdTime) else self.txt_ShoutCountTime:EndTimer() self.event_Shout:SetGray(false) self:StopRepeatFunc(self.OnUpdateFun) end end function UITeamMyTeam:OnUpdateFun(deltaTime, timeSinceUpdate) self:SetShoutCountdown(CTL.Team.GetShutTimeCD()) end function UITeamMyTeam:OnButtonClicked(comp) if comp == self.btn_SetAim then UIManager.OpenView(Const_UI_Lua.UIEnum.UITeamCreatePanel) elseif comp == self.btn_ApplyList then UIManager.OpenView(Const_UI_Lua.UIEnum.UITeamApplyPanel) elseif comp == self.btn_Leave then MDL.Team.TeamLeaveReq() elseif comp == self.btn_MatchTeam then elseif comp == self.btn_StartTask then self:OnClickEnterPlay() elseif comp == self.btn_FollowLeader then MDL.Team.TeamFollowReq(true) elseif comp == self.btn_CancelFollow then MDL.Team.TeamFollowReq(false) elseif comp == self.event_Shout then UIUtils.SetActive(self.img_ChannelBg, true) elseif comp == self.btn_RecruitChannel then UIUtils.SetActive(self.img_ChannelBg, false) self:OnClickShout(false) elseif comp == self.btn_GuildChannel then UIUtils.SetActive(self.img_ChannelBg, false) self:OnClickShout(true) elseif comp == self.img_ChannelBg then UIUtils.SetActive(self.img_ChannelBg, false) elseif comp == self.event_CallTogether then MDL.Team.TeamCallMemberReq() else for i, v in ipairs(self.group_TeammateInfo) do if comp == v.img_Empty then UIManager.OpenView(Const_UI_Lua.UIEnum.UITeamInviteInPanel) return elseif comp == v.group_Info then local px, py = comp.transform.parent:GetLocalPosition() CTL.Team.OpenTeamInteractive(MDL.Team.GetAllMembersInfo()[i].memberId, nil, px, py) return end end end end function UITeamMyTeam:OnClickEnterPlay() local teamTarget = MDL.Team.GetTeamInfo().target CTL.Team.EnterTeamPlayByTarget(teamTarget.mainTarget, teamTarget.subTarget) end function UITeamMyTeam:RefreshMyTeamPanel() self:RefreshTeamInfo() self:RefreshTeammateInfo() self:RefreshButtonState() end function UITeamMyTeam:RefreshTeammateInfo() self:StopHeroLightEffect() if self.modelComponentDataHandle then UTL.UIRender.DisposePlayerModel(self.modelComponentDataHandle) end local teammateInfo = MDL.Team.GetAllMembersInfo() for i, v in ipairs(self.group_TeammateInfo) do self:RefreshPlayerInfo(teammateInfo[i] or nil, v) if IsServerDataNotNil(teammateInfo[i]) then local resolutionRatio = UIUtils.GetScreenResolutionRatio() if resolutionRatio == LuaConst.ScreenResolutionRatio.RatioPad4_3 or resolutionRatio == LuaConst.ScreenResolutionRatio.RatioPadOther then UTL.UIRender.DelayLoadMultiBattleModel(self.modelComponentDataHandle, teammateInfo[i].playerShowInfo, ConstShowParams_RatioPad4_3[i], ConstLightPath) else UTL.UIRender.DelayLoadMultiBattleModel(self.modelComponentDataHandle, teammateInfo[i].playerShowInfo, ConstShowParams[i], ConstLightPath) end self:BeginHeroLightEffect(teammateInfo[i].detailInfo.lightEffectIds, i) end end end function UITeamMyTeam:RefreshButtonState() local isSelfLeader = CTL.Team.IsSelfLeader() UIUtils.SetActive(self.event_CallTogether.gameObject, isSelfLeader) UIUtils.SetActive(self.btn_SetAim.gameObject, isSelfLeader) self.state_Button:SetState(isSelfLeader and 0 or 1) if CTL.Team.IsSpecifiedTarget(MDL.Team.GetTeamInfo().target.mainTarget) then UIUtils.SetActive(self.btn_StartTask, false) end if not isSelfLeader then if MDL.Team.GetSelfMemberInfo().state == MDL.Team.MemberState.Following then UIUtils.SetActive(self.btn_FollowLeader, false) UIUtils.SetActive(self.btn_CancelFollow, true) else UIUtils.SetActive(self.btn_FollowLeader, true) UIUtils.SetActive(self.btn_CancelFollow, false) end end end function UITeamMyTeam:RefreshTeamInfo() local teamInfo = MDL.Team.GetTeamInfo() local teamLimit = teamInfo.limit local teamTarget = teamInfo.target if CTL.Team.IsSpecifiedTarget(teamTarget.mainTarget) then self.lab_TeamAimName:SetText(UIUtils.GetLocalizedTxt(CTL.Team.GetSpecifiedTargetTitle(teamTarget.mainTarget))) else self.lab_TeamAimName:SetText(MDL.Team.GetTeamTargetName(teamTarget.mainTarget, teamTarget.subTarget or 0)) end if teamLimit.level == 0 then UIUtils.SetLabelText(self.lab_LimitLevelNum, Const_IDS["IDS_TeamUI_ApplyLimit_None"]) else self.lab_LimitLevelNum.text = MDL.HeroSelect.GetTeamLevelName(teamLimit.level) -- 爵位转换 end if teamLimit.power == 0 then UIUtils.SetLabelText(self.lab_LimitCENum, Const_IDS["IDS_TeamUI_ApplyLimit_None"]) else self.lab_LimitCENum.text = teamLimit.power end end function UITeamMyTeam:RefreshPlayerInfo(memberInfo, cell) if memberInfo then UIUtils.SetActive(cell.img_Empty, false) UIUtils.SetActive(cell.group_Info, true) local baseInfo = memberInfo.playerShowInfo cell.lab_CE.text = baseInfo.gsSum cell.lab_RoleName.text = MDL.Team.GetMemberNameById(memberInfo.memberId) --有工会,显示势力名、徽记 if not string.isNilOrEmpty(baseInfo.guildName) then UIUtils.SetActive(cell.txt_GuildName,true) UIUtils.SetLabel(cell.txt_GuildName,baseInfo.guildName) UIUtils.SetLabel(cell.txt_GuildInitiate,baseInfo.EmblemContent) --有可能刚开始消息还没推过来,所以存在为0的情况 if baseInfo.EmblemFrame > 0 then UTL.Item.SetAtlasSprite(cell.img_GuildMark, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(baseInfo.EmblemFrame).Image) end UIUtils.SetActive(cell.txt_GuildInitiate,true ) UIUtils.SetActive(cell.img_GuildMark,true ) UIUtils.SetActive(cell.group_Guild,true ) else UIUtils.SetActive(cell.txt_GuildName,false ) UIUtils.SetActive(cell.txt_GuildInitiate,false ) UIUtils.SetActive(cell.img_GuildMark,false ) UIUtils.SetActive(cell.group_Guild,false ) end --同工会显示不同颜色势力名字 if MDL.Guild.IsSameGuild(baseInfo.guildId) then UIUtils.SetLabel(cell.txt_GuildName,UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue, baseInfo.guildName)) end local isCaptain = CTL.Team.IsTeamLeader(memberInfo.memberId) UIUtils.SetActive(cell.ico_Leader, isCaptain) CTL.Player.OperateGenderImage(cell.group_Gender, baseInfo.sex) else UIUtils.SetActive(cell.img_Empty, true) UIUtils.SetActive(cell.group_Info, false) end end function UITeamMyTeam:OnValueChanged(comp, state) if comp == self.toggle_AutoAccept then MDL.Team.IsAutoAccept = self.toggle_AutoAccept.isOn elseif comp == self.toggle_AutoFollow then MDL.Team.IsAutoFollow = self.toggle_AutoFollow.isOn end end function UITeamMyTeam:OnClosed() self:StopHeroLightEffect(true) if self.modelComponentDataHandle then UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) end end function UITeamMyTeam:StopHeroLightEffect(isDispose) UIHeroLightEffectTool.StopHeroLightEffect(self.heroLightEffectDatas) if isDispose then self.heroLightEffectDatas = nil end end function UITeamMyTeam:BeginHeroLightEffect(heroLightEffects,index) for _, lightEffectID in ipairs(heroLightEffects) do UIHeroLightEffectTool.PlayHeroLightEffect(self.heroLightEffectDatas,self, index, UIHeroLightEffectTool.PlayLightEffectFuncEnum.PlayerModel,lightEffectID, index) end end function UITeamMyTeam:PlayModelEffect(index, effectPath) return UTL.UIRender.PlayPsEffectByRenderEntityIndex(self.modelComponentDataHandle, effectPath, index) end return UITeamMyTeam