local UIGachaMainLimit = require("View/DrawCard/TimeLimit/UIGachaMainLimit") local UISuperGoldDrawCardMain = UIViewClass(UIGachaMainLimit) local EmptyLightObjPath = ConstAssetPathConfig.EmptyLightObjPath local CommonScene = ConstAssetPathConfig.Common2DScenePrefab local RankReqFrequency = 5 local ChooseHeroFragmentItemID = 432 local ChooseWeaponFragmentItemID = 433 function UISuperGoldDrawCardMain:OnOpened(context) self.activityType = MDL.OperationActivity.ActivityType.SuperGold self:RegistSystemEvent(EventID.UI_SuperGold_ActivityEnd, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_OACommon_RankRefresh, self.RefreshRankList) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) if self.heroModel then self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.heroModel) end self:SetPortrait() CTL.SuperGoldMain.SetIsOpenedActivity(self.activityId, true) end function UISuperGoldDrawCardMain:RefreshPanel() self:RefreshDrawCardConsumeItem() -- 彩金将进度奖励预览全地区保持一致 self:SetCommonRewardInfo() self:InitChooseView() end function UISuperGoldDrawCardMain:SetPortrait() local modelData = {} for k, v in DataSheetManager.SuperGoldActivityModeData:GetEnumerator() do if v.DrawCardPoolID == self.drawCardPoolId then modelData = v break end end local drawCardPrefabMode = modelData.DrawCardPrefabMode local MainViewPrefabModeEnum = CTL.GoldenHeroMain.MainViewPrefabMode if drawCardPrefabMode == MainViewPrefabModeEnum.OrthoGraphic then -- 这里实际上还是RT,后续会修改为场景渲染,目前暂时先这么写 self.renderModel:ShowHeroModel(modelData.DrawCardCameraRenderId, modelData.DrawCardMainPrefabHero, nil, 1, EmptyLightObjPath) -- JWS2-34363 -- 周瑜抽卡用的是renderModel组件,同时可能打开玩家信息界面UICharacterInfoPopUp用的也是RenderModel组件 -- 两个模型生成在同一个位置,显示bug是能看到两个模型 -- 临时处理一下挪一下模型位置,后续计划重构renderModel组件独立管理所有模型 -- 这里的常量是运行时的位置 self.renderModel:SetRenderSceneObjPos(0, 3000, 0) elseif drawCardPrefabMode == MainViewPrefabModeEnum.RealBgScene then UTL.UIRender.Create2DSceneTrans(self.modelComponentDataHandle, CommonScene, 1600, 0, 1600, modelData.DrawCardHeroBackground, false) UTL.UIRender.CreateNonPlayerModel(self.modelComponentDataHandle, modelData.DrawCardMainPrefabHero, modelData.DrawCardHeroSize, EmptyLightObjPath) UTL.UIRender.SetHeroParentPos(self.modelComponentDataHandle, modelData.DrawCardHeroOffsetX, modelData.DrawCardHeroOffsetY) end UIUtils.SetActive(self.bg_Bottom, drawCardPrefabMode ~= MainViewPrefabModeEnum.RealBgScene) if self.renderModel then UIUtils.SetActive(self.renderModel, drawCardPrefabMode == MainViewPrefabModeEnum.OrthoGraphic) end end function UISuperGoldDrawCardMain:InitView() ---所有的彩金抽卡排行榜都是这个ID,所以直接写死 self.rankName = DataSheetManager.SuperGoldDrawCardRankData:GetDataByID(1).Enum self.modeData = DataSheetManager.SuperGoldActivityModeData:GetDataByHeroType(self.heroType) --标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[self.modeData.DrawName]) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) local heroId = self.modeData.HeroID local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) if self.txt_HeroName then UIUtils.SetLabelText(self.txt_HeroName, Const_IDS[heroData.NameIDS]) end UTL.Toggle.InitToggleGroupByIDS(self.toggle_Rank, "txt", {Const_IDS.IDS_SuperGoldHeroActivity_DrawCard_Tab_1, Const_IDS.IDS_SuperGoldHeroActivity_DrawCard_Tab_2}) self.toggle_Rank:SelectIndex(0) CTL.SuperGoldMain.OpenCurrencyPanel(self.heroType, self.__viewClassPath, self.currency_Info, {activityType = self.activityType, activityId = self.activityId, title = "IDS_DrawCard_Title_QuickBuy"}) --因为是氪金排行榜,所以刷新频率很快 self:StartRepeatFunc(self.SendRankReq, RankReqFrequency, -1) UIUtils.SetActive(self.txt_TimeOutTips, false) end function UISuperGoldDrawCardMain:SendRankReq() MDL.OACommon.ActivityCrossRankGetRecordReq(self.activityId, self.rankName) end function UISuperGoldDrawCardMain:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) self:CloseSubViews() self:CloseView(true) end end end function UISuperGoldDrawCardMain:SetProgressItemIcon() UIUtils.SetImageByAssetBundle(self.img_Item, self.drawCardRewardData.BoxIcon) self.txt_ItemNum.text = "" end function UISuperGoldDrawCardMain:RefreshEndTime() local activityInfo = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId) local extraEndTime = self.modeData.TotalRankPreTime * UTL.Time.TotalSecondsOneHour local endTimeNum = MDL.SuperGoldMain.GetEndFuncTime(self.activityId) - extraEndTime local endTime = os.date(UTL.Time.FormatDateEnum.YMDHM, endTimeNum) self.lab_RemainTime.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_SuperGoldHeroActivity_NewHint_3) .. endTime self.isOutOfTime = UTL.Time.GetServerTimestamp() > endTimeNum if self.isOutOfTime then UIUtils.SetLabelText(self.txt_TimeOutTips, Const_IDS.IDS_GoldHeroActivity_RankTip) UIUtils.SetActive(self.txt_TimeOutTips, true) end end function UISuperGoldDrawCardMain:RefreshDrawCardConsumeItem() UIGachaMainLimit.RefreshDrawCardConsumeItem(self) local itemId, countInBag = CTL.ActivityGacha.GetConsumeItemInfos(self.drawCardPoolId) UTL.Item.SetCurrencyImageIcon(self.img_Icon_One, itemId) UIUtils.SetLabel(self.txt_One, CTL.ActivityGacha.GetGachaCostNumShow(itemId, 1)) UTL.Item.SetCurrencyImageIcon(self.img_Icon_Ten, itemId) UIUtils.SetLabel(self.txt_Ten, CTL.ActivityGacha.GetGachaCostNumShow(itemId, 10)) end function UISuperGoldDrawCardMain:OnClickRewardInfo() local info = MDL.ActivityGacha.GetActivityDrawInfo(self.activityId) UIManager.OpenView(Const_UI_Lua.UIEnum.UISuperGoldDrawCardReward, {activityId = self.activityId, poolId = self.drawCardPoolId, curRewardIndex = self:GetRewardIndex(info), curDrawCount = info.drawCount}) end function UISuperGoldDrawCardMain:OnClickBottomReward() if self.canClaimReward then local rewardIndex = self:GetRewardIndex(MDL.ActivityGacha.GetActivityDrawInfo(self.activityId)) MDL.ActivityGacha.RequestActivityDrawNumReward(self.activityId, self.activityType, rewardIndex + 1) else self:ShowProgressReward(self.drawCardRewardData.Item_Table) end end function UISuperGoldDrawCardMain:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_Exchange then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGachaShop, {drawCardType = CTL.DrawCard.DrawCardType.Limit, activityId = self.activityId, activityType = self.activityType, drawCardPoolId = self.drawCardPoolId, drawCardStoreId = self.drawCardStoreId, heroType = self.heroType}) elseif comp == self.btn_Info or comp == self.btn_ProbabilityInfo then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGachaSummary, {drawCardType = CTL.DrawCard.DrawCardType.Limit, activityId = self.activityId, activityType = self.activityType, drawCardPoolId = self.drawCardPoolId}) elseif comp == self.btn_RewardInfo then self:OnClickRewardInfo() elseif comp == self.btn_Reward then self:OnClickBottomReward() elseif comp == self.btn_Gacha1 then self:DrawCardProcess(1) elseif comp == self.btn_Gacha10 then self:DrawCardProcess(10) elseif comp == self.btn_Switch then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldHeroOptional, { drawCardType = CTL.DrawCard.DrawCardType.Limit, heroType = self.heroType, activityId = self.activityId, activityType = self.activityType, drawCardStoreId = self.drawCardStoreId}) else self:OnOtherButtonClicked(comp) end end function UISuperGoldDrawCardMain:OnOtherButtonClicked(comp) if comp == self.btn_PreviewBg then self:HideProgressReward() elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.SuperGoldDrawCard}) else for i, v in ipairs(self.group_Preview) do if comp == v.event_Click then UTL.ItemTips.ShowCommonTipsById(self.drawCardRewardData.Item_Table[i].ItemID) end end for i, v in ipairs(self.group_RankSelf.group_Reward) do if comp == v.event_Click then local rewardData = DataSheetManager.SuperGoldDrawCardRank:GetDataByHeroType_RankID(self.heroType, self.rankId) if CTL.ActivityGacha.IsCanSwitchCardHero(self.activityId, self.drawCardStoreId, self.curHeroID, false, self.activityType) then local itemData = DataSheetManager.ItemData:GetDataByID(rewardData.Reward_Table[i].Item) if itemData.FirstType == LuaConst.ItemType.HeroFragment then UTL.ItemTips.ShowCommonTipsById(ChooseHeroFragmentItemID) elseif itemData.FirstType == LuaConst.ItemType.WeaponFragment then UTL.ItemTips.ShowCommonTipsById(ChooseWeaponFragmentItemID) end else UTL.ItemTips.ShowCommonTipsById(rewardData.Reward_Table[i].Item) end end end end end function UISuperGoldDrawCardMain:GetRewardIndex(drawInfo) for i, v in ipairs(drawInfo.rewardList) do if v == 0 then return i end end return #drawInfo.rewardList end function UISuperGoldDrawCardMain:ShowProgressReward(data) local previewObj = self.group_Preview.gameObject UIUtils.SetActive(self.btn_PreviewBg, true) UIUtils.SetActive(previewObj, true) for i, v in ipairs(self.group_Preview) do local itemData = data[i] if itemData then UIUtils.SetActive(v.gameObject.transform.parent, true) UTL.Item.SetItemCell(v, itemData.ItemID, itemData.ItemNum) else UIUtils.SetActive(v.gameObject.transform.parent, false) end end end function UISuperGoldDrawCardMain:HideProgressReward() UIUtils.SetActive(self.btn_PreviewBg, false) UIUtils.SetActive(self.group_Preview.gameObject, false) end function UISuperGoldDrawCardMain:OnValueChanged(comp, index) if comp == self.toggle_Rank then self.state_Rank:SetState(index) if index == 0 then self:SendRankReq() elseif index == 1 then self:RefreshRankReward() end elseif comp == self.toggle_Skip then CTL.ActivityGacha.SetSkipAnim(self.activityType, index) end end function UISuperGoldDrawCardMain:RefreshRankList(activityId, rankName) local records = MDL.OACommon.GetRankRecordsByActivityId(activityId, rankName) self.loop_Rank:ReloadAll(records) UIUtils.SetActive(self.group_Empty, self.loop_Rank.Count == 0) self:RefreshSelfRankRecord(activityId, rankName) end function UISuperGoldDrawCardMain:RefreshSelfRankRecord(activityId, rankName) local myRank = MDL.OACommon.GetMyRankByActivityId(activityId, rankName) local score = myRank.param1 local rank = myRank.index self.group_RankSelf.txt_MyRank.text = rank > 0 and rank or "--" self.rankId = 0 local isScoreEnough = true for i, v in DataSheetManager.SuperGoldDrawCardRank:GetDataByHeroType_RankID(self.heroType) do if rank > 0 and rank <= v.Rank2 then local limitScore = v.LimitIntegration if limitScore and limitScore > 0 then if score >= limitScore then self.rankId = i break else isScoreEnough = false end else self.rankId = i end end end UIUtils.SetActive(self.group_RankSelf.group_RankDrop, not isScoreEnough) self.group_RankSelf.txt_Score.text = score or 0 if self.rankId > 0 then self.group_RankSelf.state_RankReward:SetState(1) local rewardTable = DataSheetManager.SuperGoldDrawCardRank:GetDataByHeroType_RankID(self.heroType, self.rankId).Reward_Table for i, v in ipairs(self.group_RankSelf.group_Reward) do local itemInfo = rewardTable[i] if itemInfo then UIUtils.SetActive(v.gameObject.transform.parent, true) if CTL.ActivityGacha.IsCanSwitchCardHero(self.activityId, self.drawCardStoreId, self.curHeroID, false, self.activityType) then local itemData = DataSheetManager.ItemData:GetDataByID(itemInfo.Item) if itemData.FirstType == LuaConst.ItemType.HeroFragment then UTL.Item.SetItemCell(v, ChooseHeroFragmentItemID, itemInfo.ItemNum) elseif itemData.FirstType == LuaConst.ItemType.WeaponFragment then UTL.Item.SetItemCell(v, ChooseWeaponFragmentItemID, itemInfo.ItemNum) end else UTL.Item.SetItemCell(v, itemInfo.Item, itemInfo.ItemNum) end else UIUtils.SetActive(v.gameObject.transform.parent, false) end end else self.group_RankSelf.state_RankReward:SetState(0) end end function UISuperGoldDrawCardMain:RefreshRankReward() if self.loop_RewardRank.Count > 0 then self.loop_RewardRank:ClearCells() end for i, v in DataSheetManager.SuperGoldDrawCardRank:GetDataByHeroType_RankID(self.heroType) do self.loop_RewardRank:AddData(v, 0) end UIUtils.SetActive(self.group_Empty, false) end function UISuperGoldDrawCardMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Rank then if cellTable.state_Bg then cellTable.state_Bg:SetState(index % 2) end local rank = data.index if rank > 0 then cellTable.bg_Rank:SetState(rank >= 4 and 3 or rank - 1) cellTable.txt_Rank.text = rank end cellTable.txt_Name.text = data.name cellTable.txt_Server.text = string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Rank_ServerIDS), data.serverId) cellTable.txt_Score.text = data.param1 elseif scrollRect == self.loop_RewardRank then if cellTable.state_Bg then cellTable.state_Bg:SetState(index % 2) end cellTable.bg_Rank:SetState(index > 3 and 3 or index) if data.Rank1 == data.Rank2 then cellTable.txt_Rank.text = data.Rank1 else cellTable.txt_Rank.text = data.Rank1 .. "-" .. data.Rank2 end cellTable.txt_Score.text = data.LimitIntegration or 0 local rewardTable = data.Reward_Table for i, v in ipairs(cellTable.group_Reward) do local itemInfo = rewardTable[i] if itemInfo then UIUtils.SetActive(v.gameObject.transform.parent, true) if CTL.ActivityGacha.IsCanSwitchCardHero(self.activityId, self.drawCardStoreId, self.curHeroID, false, self.activityType) then local itemData = DataSheetManager.ItemData:GetDataByID(itemInfo.Item) if itemData.FirstType == LuaConst.ItemType.HeroFragment then UTL.Item.SetItemCell(v, ChooseHeroFragmentItemID, itemInfo.ItemNum) elseif itemData.FirstType == LuaConst.ItemType.WeaponFragment then UTL.Item.SetItemCell(v, ChooseWeaponFragmentItemID, itemInfo.ItemNum) end else UTL.Item.SetItemCell(v, itemInfo.Item, itemInfo.ItemNum) end else UIUtils.SetActive(v.gameObject.transform.parent, false) end end end end function UISuperGoldDrawCardMain:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Rank then CTL.PlayerInteract.OpenFriendInteractView(data.acid) elseif scrollRect == self.loop_RewardRank then for i, v in ipairs(cellTable.group_Reward) do if target == v.event_Click then if CTL.ActivityGacha.IsCanSwitchCardHero(self.activityId, self.drawCardStoreId, self.curHeroID, false, self.activityType) then local itemData = DataSheetManager.ItemData:GetDataByID(data.Reward_Table[i].Item) if itemData.FirstType == LuaConst.ItemType.HeroFragment then UTL.ItemTips.ShowCommonTipsById(ChooseHeroFragmentItemID) elseif itemData.FirstType == LuaConst.ItemType.WeaponFragment then UTL.ItemTips.ShowCommonTipsById(ChooseWeaponFragmentItemID) end else UTL.ItemTips.ShowCommonTipsById(data.Reward_Table[i].Item) end end end end end return UISuperGoldDrawCardMain