local UIGuildEscortMainPanel = UIViewClass() -- [[ -- 势力押镖-玩法主界面 -- ]] local GuildEscortMainFuncInfoID = 1735 local RefreshItemId = 131 -------------------- function UIGuildEscortMainPanel:OnCreated() self.refreshItemExpend = DataSheetManager.ConstData:GetDataByID("EscortPefectItemNum").IntValue end function UIGuildEscortMainPanel:OnOpened(context) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshCurLevelEscort) self:RegistSystemEvent(EventID.GuildEscort_RefreshCart, self.RefreshCurLevelEscort) self:RegistSystemEvent(EventID.TeamMemberChanged, self.RefreshTeamInfo) self:RegistSystemEvent(EventID.GuildEscort_RefreshActivityCount, self.RefreshEscortResidueInfo) self.btn_Refresh:SetGray(true) -- 提前设置一次 方式直接设置为false的时候 颜色错乱 self.curLevelEscort = 0 self.showRefreshLevelEffect = false self:InitPanel() self:RefreshEscortResidueInfo() self:RefreshTeamInfo() end function UIGuildEscortMainPanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGuildEscortMainPanel:OnButtonClicked(comp) if self.UITemplateTitlePanel.btn_close == comp then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif self.UITemplateTitlePanel.btn_Info == comp then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = GuildEscortMainFuncInfoID}) elseif self.btn_Team == comp then CTL.Team.OpenTeamPanel() elseif self.btn_Rank == comp then CTL.Rank.OpenRankPanelByType(MDL.Rank.RankType.GuildEscort) elseif self.btn_Confirm == comp then MDL.GuildEscort.EscortStatusCheckRequest(MDL.GuildEscort.EscortType.Transport, function() UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildEscortStart) end) elseif self.btn_Refresh == comp then if CTL.Team.IsInTeam() and not CTL.Team.IsSelfLeader() then CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS.IDS_ERRORCODE_1757_InfoCode_Escort_NoTeamLeader)) else if self.curLevelEscort == MDL.GuildEscort.PerfectEscort then CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Escort_AlreadyBest)) else MDL.GuildEscort.CartRefreshRequest(false) end end elseif self.btn_Get == comp then -- 领取完美镖按钮 if self.curLevelEscort == MDL.GuildEscort.PerfectEscort then CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Escort_AlreadyBest)) return end local itemCount = UTL.Item.GetItemStockCount(RefreshItemId) if itemCount < self.refreshItemExpend then local sourcesList = MDL.ItemSources.GetItemSourcesById(RefreshItemId) if #sourcesList > 0 then local itemData = DataSheetManager.ItemData:GetDataByID(RefreshItemId) UTL.MessageBox.ShowOKCancelBox(nil, string.FormatByIdsId(Const_IDS.IDS_GoldHeroActivity_LackItem, UIUtils.GetLocalizedTxt(Const_IDS[itemData.Name])), function() CTL.ItemSources.ExecuteSourceFunctionById(sourcesList[1].sourceId, RefreshItemId) end, nil, UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildBoss_ButtonGo)) end else MDL.GuildEscort.CartRefreshRequest(true) end elseif self.btn_item == comp then UTL.ItemTips.ShowCommonTipsById(RefreshItemId) end end function UIGuildEscortMainPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.scroll_EscortList then cellTable.state_Type:SetState(data.ID - 1) -- 设置是否是当前选中 & 已经锁住(等级小于当前选中等级) UIUtils.SetActive(cellTable.group_Choosed, data.ID == self.curLevelEscort) -- 设置选中特效 if data.ID == self.curLevelEscort then UIUtils.SetActive(cellTable.group_Choosed, true) cellTable.effect_SelectedLight:PlayUIEffect() else UIUtils.SetActive(cellTable.group_Choosed, false) cellTable.effect_SelectedLight:StopUIEffect() end UIUtils.SetActive(cellTable.img_Locked, data.ID < self.curLevelEscort) if data.ID == self.curLevelEscort and self.showRefreshLevelEffect then -- 这里处理特效 self.showRefreshLevelEffect = false end -- 设置奖励 local rewardData = DataSheetManager.EscortPersonReward:GetDataByID(data.EscortPersonRewardID).Item_Table for i, reward in ipairs(rewardData) do local item = cellTable.Content[i] if not item then item = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.Content, self.itemTemplate_Reward.gameObject) end UTL.Item.SetItemCell(item, reward.ItemID, reward.ItemNum) UIUtils.SetActive(item.gameObject, true) end for i = #rewardData + 1, #cellTable.Content do UIUtils.SetActive(cellTable.Content[i].gameObject, false) end -- 设置红点 if data.ID == MDL.GuildEscort.PerfectEscort then local itemCount = UTL.Item.GetItemStockCount(RefreshItemId) UIUtils.SetActive(cellTable.RedPoint, itemCount >= self.refreshItemExpend) else UIUtils.SetActive(cellTable.RedPoint, false) end end end function UIGuildEscortMainPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect ~= self.scroll_EscortList then return end for i = 1, #cellTable.Content do if cellTable.Content[i].event_Click == target then local rewardData = DataSheetManager.EscortPersonReward:GetDataByID(data.EscortPersonRewardID).Item_Table UTL.ItemTips.ShowCommonTipsById(rewardData[i].ItemID) end end end -------------------- function UIGuildEscortMainPanel:InitPanel() -- 设置标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_Escort_FunctionName) -- 设置领取完美镖的道具 UTL.Item.ItemSquareIcon(self.img_Item, nil, RefreshItemId) local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildEscort) local _, time = CTL.Activities.GetDetailsTimeDesc(activityData, true) UIUtils.SetLabel(self.lab_DateInfo, string.FormatByIdsId(Const_IDS.IDS_Escort_Time, time)) UIUtils.SetLabel(self.text_BuffDesc, string.FormatByIdsId(Const_IDS.IDS_Escort_TeamNum3, CTL.GuildEscort.EscortTeamAwardUp, CTL.GuildEscort.EscortTeamAwardUp)) self:RefreshCurLevelEscort() end -- 刷新(运镖、劫镖)次数 function UIGuildEscortMainPanel:RefreshEscortResidueInfo() local residueNum, limitNum = MDL.GuildEscort.GetEscortNumLimit() if residueNum <= 0 then UIUtils.SetLabel(self.text_EscortTimes, string.FormatByIdsId(Const_IDS.IDS_Escort_ActivityNum2, UTL.Color.FormatRedColor(residueNum), limitNum)) else UIUtils.SetLabel(self.text_EscortTimes, string.FormatByIdsId(Const_IDS.IDS_Escort_ActivityNum2, UTL.Color.FormatGreenColor(residueNum), limitNum)) end residueNum, limitNum = MDL.GuildEscort.GetCutEscortNumLimit() if residueNum <= 0 then UIUtils.SetLabel(self.text_RobTimes, string.FormatByIdsId(Const_IDS.IDS_Escort_ActivityNum3, UTL.Color.FormatRedColor(residueNum), limitNum)) else UIUtils.SetLabel(self.text_RobTimes, string.FormatByIdsId(Const_IDS.IDS_Escort_ActivityNum3, UTL.Color.FormatGreenColor(residueNum), limitNum)) end end -- 刷新队伍信息 function UIGuildEscortMainPanel:RefreshTeamInfo() -- 如果是没组队 人数也算一个人 local teamMemberNum, ratio = CTL.GuildEscort.GetTeamBonus() UIUtils.SetLabel(self.text_Speed, string.FormatByIdsId(Const_IDS.IDS_Escort_TeamNum1, ratio)) UIUtils.SetLabel(self.text_Reward, string.FormatByIdsId(Const_IDS.IDS_Escort_TeamNum2, ratio)) UIUtils.SetLabel(self.lab_TeamDesc, string.FormatByIdsId(Const_IDS.IDS_DigTreasure_TreasureCave_TeamNum, teamMemberNum)) end -- 刷新当先押镖级别 function UIGuildEscortMainPanel:RefreshCurLevelEscort() -- 设置领完美标道具数量 local itemCount = UTL.Item.GetItemStockCount(RefreshItemId) if itemCount < self.refreshItemExpend then UIUtils.SetLabel(self.txt_Cost, string.format("%s/%s", UTL.Color.FormatRedColor(itemCount), self.refreshItemExpend)) else UIUtils.SetLabel(self.txt_Cost, string.format("%s/%s", UTL.Color.FormatGreenColor(itemCount), self.refreshItemExpend)) end local levelEscort = MDL.GuildEscort.GetCurLevelEscort() self.showRefreshLevelEffect = self.curLevelEscort ~= levelEscort self.curLevelEscort = levelEscort -- 此处先ClearCells,在adddata一下 不使用RefreshCells,避免特效报错, 之后可以去掉ClearCells self.scroll_EscortList:ClearCells() if self.scroll_EscortList.Count == 0 then for _, v in DataSheetManager.GuildEscortData:GetEnumerator() do self.scroll_EscortList:AddData(v, 0) end else self.scroll_EscortList:RefreshCells(false) end self:RefreshFreeInfo() end -- 刷新换标次数 function UIGuildEscortMainPanel:RefreshFreeInfo() local residueNum, limitNum, refreshCount = MDL.GuildEscort.GetEscortRefreshFreeLimit() local isGray = self.curLevelEscort == MDL.GuildEscort.PerfectEscort self.btn_Refresh:SetGray(isGray, true) if residueNum <= 0 then self.btn_Refresh:SetRedPoint(false) self.obj_RefreshState:SetState(1) local costGold = 0 for _, v in DataSheetManager.GuildEscortRefresh:GetEnumerator() do if (refreshCount - limitNum + 1) >= v.ID then -- 加1的原因是计算下一次消耗 costGold = v.CostGold end end UIUtils.SetLabel(self.txt_Number, costGold) else if CTL.Activities.IsOpeningTime(LuaConst.ActivityType.GuildEscort) and not isGray then self.btn_Refresh:SetRedPoint(true) else self.btn_Refresh:SetRedPoint(false) end self.obj_RefreshState:SetState(0) UIUtils.SetLabel(self.lab_RefreshDesc, string.FormatByIdsId(Const_IDS.IDS_Escort_ActivityNum1, UTL.Color.FormatGreenColor(residueNum), limitNum)) end end return UIGuildEscortMainPanel