-- 金/彩金活动自选卡池 local UIGoldHeroOptional = UIViewClass() function UIGoldHeroOptional:OnOpened(context) self.activityId = context.activityId self.heroType = context.heroType self.activityType = context.activityType self.drawCardStoreId = context.drawCardStoreId self.drawCardType = context.drawCardType self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self.selectHeroID = 0 self.cellTableList = {} self:InitOptionalView() self.group_Remind.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GoldHeroChoose_Hint_5) self.lab_Title.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GoldHeroChoose_Hint_2) end function UIGoldHeroOptional:OnButtonClicked(comp) if comp == self.btn_Cancel or comp == self.btn_Close then if not MDL.ActivityGacha.GetActivityDrawInfo(self.activityId).isOpen then MDL.ActivityGacha.RequestActivityCardPoolChooseRequest(self.activityId, self.activityType, self.curDrawCardPoolID) end self:CloseView() elseif comp == self.btn_Confirm then if self.selectHeroID == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroChoose_Hint_2) else local poolID = 0 if self.activityType == MDL.OperationActivity.ActivityType.GoldenHero then for k, v in DataSheetManager.GoldHeroActivityModeData:GetEnumerator() do if v.SynergyBossHeroID == self.selectHeroID then poolID = v.DrawCardPoolID break end end elseif self.activityType == MDL.OperationActivity.ActivityType.SuperGold then for k, v in DataSheetManager.SuperGoldActivityModeData:GetEnumerator() do if v.HeroID == self.selectHeroID then poolID = v.DrawCardPoolID break end end end UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldHeroOptionalPupup, { activityId = self.activityId, activityType = self.activityType, drawCardPoolId = poolID, leftHeroID = self.curHeroID, rightHeroID = self.selectHeroID }) end elseif comp == self.btn_Info then if self.activityType == MDL.OperationActivity.ActivityType.GoldenHero then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.GoldHeroOptional }) elseif self.activityType == MDL.OperationActivity.ActivityType.SuperGold then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.SuperGoldOptional }) end end end function UIGoldHeroOptional:InitOptionalView() local activityPoolID = MDL.ActivityGacha.GetActivityDrawInfo(self.activityId).cardPoolId local modelData = {} if self.activityType == MDL.OperationActivity.ActivityType.GoldenHero then modelData = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType) elseif self.activityType == MDL.OperationActivity.ActivityType.SuperGold then modelData = DataSheetManager.SuperGoldActivityModeData:GetDataByHeroType(self.heroType) end self.curDrawCardPoolID = activityPoolID > 0 and activityPoolID or modelData.DrawCardPoolID if activityPoolID <= 0 then if self.activityType == MDL.OperationActivity.ActivityType.GoldenHero then self.curHeroID = modelData.SynergyBossHeroID elseif self.activityType == MDL.OperationActivity.ActivityType.SuperGold then self.curHeroID = modelData.HeroID end else if self.activityType == MDL.OperationActivity.ActivityType.GoldenHero then for k, v in DataSheetManager.GoldHeroActivityModeData:GetEnumerator() do if v.DrawCardPoolID == self.curDrawCardPoolID or v.AwakenDrawCardPoolID == self.curDrawCardPoolID then self.curHeroID = v.SynergyBossHeroID break end end elseif self.activityType == MDL.OperationActivity.ActivityType.SuperGold then for k, v in DataSheetManager.SuperGoldActivityModeData:GetEnumerator() do if v.DrawCardPoolID == self.curDrawCardPoolID then self.curHeroID = v.HeroID break end end end end local cardPoolList = MDL.ActivityGacha.GetGoldHeroChooseList(self.drawCardStoreId, self.curHeroID) self.loop_Hero:ReloadAll(cardPoolList) if #cardPoolList < 6 then self.loop_Hero:SetMovementType(3) else self.loop_Hero:SetMovementType(1) end end function UIGoldHeroOptional:OnCellInit(scrollRect, index, cellTable, data) local heroData = DataSheetManager.HeroNum:GetDataByID(data) cellTable.state_Type:SetState(0) if heroData.HeroQuality == LuaConst.QualityColor.Gold then cellTable.state_Golden:SetState(0) elseif heroData.HeroQuality == LuaConst.QualityColor.DarkGold then cellTable.state_Golden:SetState(1) end local isAwaken = MDL.HeroAwaken.GetIsHeroAwaken(data) UTL.Item.SetHeroHalfCardImageByHeroId(cellTable.img_Hero, data, isAwaken) CTL.HeroSelect.SetHeroName(data, cellTable.group_Name, cellTable.img_Name, cellTable.txt_Name) if MDL.HeroSelect.IsHasHero(data) then cellTable.group_Break:SetState(1) if isAwaken then UIUtils.SetLabel(cellTable.txt_BreakLevel, string.FormatByIdsId(Const_IDS.IDS_HeroAwaken_Level, MDL.HeroAwaken.GetCurStar(data))) else UIUtils.SetLabel(cellTable.txt_BreakLevel, string.FormatByIdsId(Const_IDS.IDS_HeroStarLevel, "+" .. MDL.HeroStar.GetHeroStarLevel(data))) end else cellTable.group_Break:SetState(0) end UIUtils.SetActive(cellTable.group_Now, self.curHeroID == data) self.cellTableList[index + 1] = cellTable end function UIGoldHeroOptional:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_Select then if self.curHeroID == data then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroChoose_Hint_6) return else if self.selectHeroID ~= data then self.selectHeroID = data for k, v in ipairs(self.cellTableList) do if k == index + 1 then v.effect_Select:PlayUIEffect() else v.effect_Select:StopUIEffect() end end end end end end function UIGoldHeroOptional:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end return UIGoldHeroOptional