local FriendRecharge_Controller = {} local private = {} local FriendRechargeActiveView = { Const_UI_Lua.UIEnum.OperationActivity.UIFriendRechargeMain, Const_UI_Lua.UIEnum.OperationActivity.UIFriendRechargeInviteList, Const_UI_Lua.UIEnum.OperationActivity.UIFriendRechargePurchase, Const_UI_Lua.UIEnum.OperationActivity.UIFriendRechargePurchaseLv, Const_UI_Lua.UIEnum.OperationActivity.UIFriendRechargerLevelUp, } local EventSystem = require('Event/EventSystem') function FriendRecharge_Controller.OnStartup() EventSystem.Regist(EventID.UI_OperationActivity_InfoChanged, private.CheckFuncOpenIssue) EventSystem.Regist(EventID.AcquireSystemRedAfterUnlock, private.CheckFuncOpenIssue) EventSystem.Regist(EventID.FunctionUnlockUpdate, private.RefreshInfoByFunction) private.ActivityType = MDL.OperationActivity.ActivityType.FriendRecharge private.endTimerHandle = {} end function FriendRecharge_Controller.OpenFriendRechargeMainPanel() local activityId = MDL.FriendRecharge.GetFriendRechargeActivityID() local info = MDL.OperationActivity.GetOperationActivityInfo(private.ActivityType, activityId) if info then if CTL.OperationActivity.IsOperationActivityOpen(info) then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIFriendRechargeMain) end end end -- 设置自己和邀约队友信息 function FriendRecharge_Controller.SetTeamMemberInfo(group_Player, memberInfo, isTeam) if isTeam then group_Player.state_Switch:SetState(0) CTL.Character.SetSelfPortraitAndFrame(group_Player.player1.UIHeroHead) if memberInfo then group_Player.player2.state_Member:SetState(0) else group_Player.player2.state_Member:SetState(1) end else group_Player.state_Switch:SetState(1) CTL.Character.SetSelfPortraitAndFrame(group_Player.player_Self.UIHeroHead) end end function FriendRecharge_Controller:SetFriendRechargePlayerInfo(cellTable, playerInfo) --好友的数据字段名首字母都是小写,陌生人和势力的数据中字段名都是大写 -- 头像 CTL.Character.SetPortraitAndFrame(cellTable.UIHeroHead, playerInfo.PortraitId or playerInfo.portraitId, playerInfo.FrameId or playerInfo.frameId) -- 玩家名、性别 local server = "" if CTL.CrossServer.IsInCrossServerScene() then server = CTL.CrossServer.GetServerShowStr(playerInfo.ShowServerId or playerInfo.showServerId, not (playerInfo.IsCross or playerInfo.isCross)) end cellTable.lab_RoleName.text = playerInfo.name .. server CTL.Player.OperateGenderImage(cellTable.image_Gender, playerInfo.sex) local guildId = playerInfo.guildID local emblemContent = playerInfo.EmblemContent local emblemFrame = playerInfo.EmblemFrame --同势力显示不同颜色的工会名字 if MDL.Guild.IsSameGuild(guildId) then UIUtils.SetLabel(cellTable.lab_GuildName, UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue, playerInfo.guildName)) else UIUtils.SetLabelText(cellTable.lab_GuildName, Const_IDS["IDS_TeamUI_ActiveInvitation_NoGuild"]) end --有工会的话显示势力名字、徽记显示 if not string.isNilOrEmpty(playerInfo.guildName) then cellTable.lab_GuildName.text = playerInfo.guildName UIUtils.SetLabel(cellTable.txt_GuildInitiate, emblemContent) if emblemFrame > 0 then UTL.Item.SetAtlasSprite(cellTable.img_GuildMark, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(emblemFrame).Image) end UIUtils.SetActive(cellTable.txt_GuildInitiate, true) UIUtils.SetActive(cellTable.img_GuildMark, true) else UIUtils.SetActive(cellTable.txt_GuildInitiate, false) UIUtils.SetActive(cellTable.img_GuildMark, false) end UIUtils.SetActive(cellTable.img_Online, playerInfo.isOnline) end function FriendRecharge_Controller:SetLevel(group_Level, isTeam) local rechargeBaseInfo = MDL.FriendRecharge.GetRechargeBaseInfo() local activityId = MDL.FriendRecharge.GetFriendRechargeActivityID() local maxLevel = MDL.OperationActivity.FriendRechargeReward:GetDataLengthByActivityID(activityId) local curLevelData = MDL.OperationActivity.FriendRechargeReward:GetDataByActivityID_Level(activityId, rechargeBaseInfo.friendRechargeLv) UIUtils.SetLabel(group_Level.txt_Lv, string.FormatByIdsId(Const_IDS.IDS_Handbook_Hero_LevelNum, rechargeBaseInfo.friendRechargeLv)) if curLevelData.Exp > 0 then UIUtils.SetLabel(group_Level.txt_Num, rechargeBaseInfo.friendRechargeExp.."/"..curLevelData.Exp) group_Level.slider_Score.value = rechargeBaseInfo.friendRechargeExp / curLevelData.Exp else UIUtils.SetLabel(group_Level.txt_Num, "") group_Level.slider_Score.value = 1 end group_Level.state_ModelLevel:SetState(isTeam and 0 or 1) UIUtils.SetActive(group_Level.btn_Lock, not rechargeBaseInfo.isUnlock) UIUtils.SetActive(group_Level.btn_Buy, rechargeBaseInfo.isUnlock and rechargeBaseInfo.friendRechargeLv < maxLevel) group_Level.state_Empty:SetState(rechargeBaseInfo.friendRechargeLv < maxLevel and 0 or 1) end --GMS开关变化时刷新 function private.RefreshInfoByFunction(funcId, isUnlock) if funcId == MDL.Unlock.FunctionType.FriendRecharge then if not isUnlock then private.ForceCloseActivityView(funcId) end end end -- 关闭活动界面 function private.ForceCloseActivityView() logging.log(LTAG.LOG, "FriendRecharge Function(include GMS) ActivityEnd ") private.EndAndCloseActivityView(MDL.FriendRecharge.GetFriendRechargeActivityID()) end function private.EndAndCloseActivityView(activityId) private.ShutDownPartActivityView(activityId) end function private.CheckFuncOpenIssue() if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.FriendRecharge) then private.ForceCloseActivityView() return end local activityTypeInfo = MDL.OperationActivity.GetOperationActivityInfo(MDL.OperationActivity.ActivityType.FestivalLogin, MDL.FriendRecharge.GetFriendRechargeActivityID()) if activityTypeInfo and activityTypeInfo.activityId then local activityId = activityTypeInfo.activityId if private.endTimerHandle[activityId] then TimerUtil.Remove(private.endTimerHandle[activityId]) private.endTimerHandle[activityId] = nil end if not CTL.OperationActivity.IsOperationActivityOpen(activityTypeInfo) then private.EndAndCloseActivityView(activityId) else local deltaTime = activityTypeInfo.endTime - UTL.Time.GetServerTimestamp() if deltaTime <= UTL.Time.TotalSecondsOneDay then private.endTimerHandle[activityId] = TimerUtil.Interval(function() private.EndAndCloseActivityView(activityId) end, deltaTime - 1, 1) --时间减1s是为了防止有误差导致玩家点击出现报错 end end end end function private.ShutDownPartActivityView(activityId) for i, v in ipairs(FriendRechargeActiveView) do EventSystem.Dispatch(EventID.UI_OperationActivity_CloseView, v, activityId) end end return FriendRecharge_Controller