local UIHorseSoulGachaMain = UIViewClass() local WishInitialChance = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("WishInitialChance").FloatValue) -- 心愿单初始概率 local WishNotInitialChance = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("WishNotInitialChance").FloatValue) -- 心愿单歪一次之后的概率 local HorseSoullargeDrawItemNum = DataSheetManager.ConstData:GetDataByID("HorseSoullargeDrawItemNum").IntValue -- 魂珠抽卡道具持有超过X后显示大量抽取按键 local HorseSoullargeDrawNum = DataSheetManager.ConstData:GetDataByID("HorseSoullargeDrawNum").IntValue -- 大量抽取按键抽x次 function UIHorseSoulGachaMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_HorseSoul_Gacha_RefreshUI, self.RefreshGachaView) --标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_HorseSoul_Button1) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) self.wishInitialChance = (WishInitialChance * 100).."%" self.wishNotInitialChance = (WishNotInitialChance * 100).."%" UIUtils.SetActive(self.btn_RuleBG, false) UIUtils.SetActive(self.group_Rule, false) self:RefreshGachaView() end function UIHorseSoulGachaMain:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) end function UIHorseSoulGachaMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIHorseSoulGachaMain: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_Check then UIManager.OpenView(Const_UI_Lua.UIEnum.UIHorseSoulGachaRule) elseif comp == self.btn_RuleBG then UIUtils.SetActive(self.btn_RuleBG, false) UIUtils.SetActive(self.group_Rule, false) elseif comp == self.btn_ScoreReward then UIUtils.SetActive(self.btn_RuleBG, true) UIUtils.SetActive(self.group_Rule, true) elseif comp == self.btn_1 then self:ProcessDrawCardOne() elseif comp == self.btn_10 then self:ProcessDrawCardTen() elseif comp == self.btn_100 then self:ProcessDrawCardHun() elseif comp == self.UIItem_Process.event_Click then -- 进度奖励 if self.curRewardProcess >= self.rewardProcessData.DrawNum then MDL.HorseSoul.GetDrawSoulNumRewardReq(self.rewardLevelID) else UTL.ItemTips.ShowCommonTipsById(self.rewardProcessData.ItemID) end elseif comp == self.Item_RedWish.event_Click then -- 红色心愿 if self.isUnLockRedWish then UIManager.OpenView(Const_UI_Lua.UIEnum.UIHorseSoulGachaHeartWish, {wishType = 1}) MDL.HorseSoul.RedWishUnLockRedPoint = false self.Item_RedWish.event_Click:SetRedPoint(MDL.HorseSoul.RedWishUnLockRedPoint) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HorseSoul_DrawHint16) end elseif comp == self.Item_GoldWish.event_Click then -- 金色心愿 if self.isUnLockGoldWish then UIManager.OpenView(Const_UI_Lua.UIEnum.UIHorseSoulGachaHeartWish, {wishType = 2}) MDL.HorseSoul.GoldWishUnLockRedPoint = false self.Item_GoldWish.event_Click:SetRedPoint(MDL.HorseSoul.GoldWishUnLockRedPoint) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HorseSoul_DrawHint16) end end end function UIHorseSoulGachaMain:RefreshGachaView() self.drawHorseSoulServerInfo = MDL.HorseSoul.GetDrawHorseSoulInfo() self.curDrawPoolID = self.drawHorseSoulServerInfo.drawPoolID self.todayDrawNum = MDL.HorseSoul.GetHorseSoulDailyDrawNum() - self.drawHorseSoulServerInfo.todayDrawNum self.curRewardProcess = self.drawHorseSoulServerInfo.numRewardRemainNum self.upPoolProgress = self.drawHorseSoulServerInfo.upPoolProgress self.rewardLevelID = self.drawHorseSoulServerInfo.numRewardStageID self.rewardProcessData = DataSheetManager.HorseSoulDrawReward:GetDataByID(self.rewardLevelID) self.gachaPoolData = DataSheetManager.HorseSoulDrawData:GetDataByID(self.curDrawPoolID) self.nextPoolData = DataSheetManager.HorseSoulDrawData:GetDataByID(self.gachaPoolData.LevelUpPoolID) self.itemStoreId = self.gachaPoolData.Item -- 刷新背景图 UIUtils.SetTextureByAssetBundle(self.img_BG, self.gachaPoolData.BackgroundPic) self.effect_BG:PlayUIEffect(self.gachaPoolData.BackgroundPicEffect, 0) self:SetProcessInfo() self:SetWishInfo() -- 每日招募次数限制 UIUtils.SetLabel(self.lab_Times, string.FormatByIdsId(Const_IDS.IDS_HorseSoul_DrawHint2, self.todayDrawNum > 0 and UTL.Color.FormatWhiteColor(self.todayDrawNum) or UTL.Color.FormatRedColor(self.todayDrawNum), MDL.HorseSoul.GetHorseSoulDailyDrawNum())) -- 当前卡池进度 local targetNum = self.gachaPoolData.LevelUpSoulNum UIUtils.SetLabel(self.txt_LevelUpTip, string.FormatByIdsId(Const_IDS.IDS_HorseSoul_DrawHint7, targetNum - self.upPoolProgress, UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.QualityColor:GetDataByID(self.gachaPoolData.Quality).ColorText]), self.gachaPoolData.Quality))) self.Fill_Score.fillAmount = self.upPoolProgress / targetNum if self.gachaPoolData.LevelUpPoolID < self.curDrawPoolID then UIUtils.SetActive(self.group_Score, false) else UIUtils.SetActive(self.group_Score, true) UIUtils.SetImageByAssetBundle(self.img_ScoreRewardIcon, self.nextPoolData.DrawIcon) end -- 单抽 UTL.Item.SetCurrencyImageIcon(self.img_Icon_one, self.itemStoreId) UIUtils.SetLabel(self.txt_One, CTL.ActivityGacha.GetGachaCostNumShow(self.itemStoreId, self.gachaPoolData.OneDrawItemNum)) -- 十连抽 UTL.Item.SetCurrencyImageIcon(self.img_Icon_ten, self.itemStoreId) UIUtils.SetLabel(self.txt_Ten, CTL.ActivityGacha.GetGachaCostNumShow(self.itemStoreId, self.gachaPoolData.TenDrawItemNum)) self.btn_10:SetRedPoint(MDL.HorseSoul.IsShowDrawTenCardRP()) -- 100抽 local isShow100 = UTL.Item.GetItemStockCount(self.itemStoreId) >= HorseSoullargeDrawItemNum UIUtils.SetActive(self.btn_100, isShow100) if isShow100 then UTL.Item.SetCurrencyImageIcon(self.img_Icon_Hun, self.itemStoreId) UIUtils.SetLabel(self.txt_Hun, HorseSoullargeDrawNum) UIUtils.SetLabel(self.lab_Hun, string.FormatByIdsId(Const_IDS.IDS_HorseSoul_Button_LargeDraw, HorseSoullargeDrawNum)) self.btn_100:SetRedPoint(MDL.HorseSoul.IsShowDrawTenCardRP()) end local colorName = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.QualityColor:GetDataByID(self.nextPoolData.Quality).ColorText]), self.nextPoolData.Quality) UIUtils.SetLabel(self.lab_Rule, string.FormatByIdsId(Const_IDS.IDS_HorseSoul_DrawHint8, colorName, colorName)) end -- 抽卡累计奖励 function UIHorseSoulGachaMain:SetProcessInfo() -- 抽卡累计奖励 local itemData = DataSheetManager.ItemData:GetDataByID(self.rewardProcessData.ItemID) UTL.Item.ItemSquareIcon(self.UIItem_Process.img_ProcessIcon, self.UIItem_Process.sprite_Rank, self.rewardProcessData.ItemID) UTL.Color.SetQualityImageByType(self.UIItem_Process.img_ProcessBG, itemData.Color, UTL.Color.QualityType.FormationHorseTreasureEquipBg) UIUtils.SetLabel(self.UIItem_Process.lab_Num, self.rewardProcessData.ItemNum) UIUtils.SetLabel(self.UIItem_Process.lab_Process, string.format("%s/%s", self.curRewardProcess, self.rewardProcessData.DrawNum)) if self.curRewardProcess >= self.rewardProcessData.DrawNum then self.UIItem_Process.effect_Light:PlayUIEffect() else self.UIItem_Process.effect_Light:StopUIEffect() end end function UIHorseSoulGachaMain:SetWishInfo() -- 心愿魂珠 local redWishInfo, goldWishInfo = MDL.HorseSoul.GetSelectWishInfo(1), MDL.HorseSoul.GetSelectWishInfo(2) local redWishUnLock, goldWishUnLock = self.isUnLockRedWish, self.isUnLockGoldWish self.isUnLockRedWish = redWishInfo and redWishInfo.isUnlock or false self.isUnLockGoldWish = goldWishInfo and goldWishInfo.isUnlock or false local isShowRedEffect = self.isUnLockRedWish and self.isUnLockRedWish ~= redWishUnLock local isShowGoldEffect = self.isUnLockGoldWish and self.isUnLockGoldWish ~= goldWishUnLock if redWishUnLock ~= nil and isShowRedEffect then self.Item_RedWish.effect_Active:PlayUIEffect() else self.Item_RedWish.effect_Active:StopUIEffect() end if goldWishUnLock ~= nil and isShowGoldEffect then self.Item_GoldWish.effect_Active:PlayUIEffect() else self.Item_GoldWish.effect_Active:StopUIEffect() end self.Item_RedWish.event_Click:SetRedPoint(MDL.HorseSoul.RedWishUnLockRedPoint) if self.isUnLockRedWish then if redWishInfo.wishSoulID > 0 then self.Item_RedWish.state_RedWish:SetState(0) UTL.Item.SetItemCell(self.Item_RedWish.item, redWishInfo.wishSoulID) if redWishInfo.isMustGet then UIUtils.SetLabel(self.Item_RedWish.txt_Discount, self.wishNotInitialChance) else UIUtils.SetLabel(self.Item_RedWish.txt_Discount, self.wishInitialChance) end else self.Item_RedWish.state_RedWish:SetState(2) end else self.Item_RedWish.state_RedWish:SetState(1) end self.Item_GoldWish.event_Click:SetRedPoint(MDL.HorseSoul.GoldWishUnLockRedPoint) if self.isUnLockGoldWish then if goldWishInfo.wishSoulID > 0 then self.Item_GoldWish.state_GoldWish:SetState(0) UTL.Item.SetItemCell(self.Item_GoldWish.item, goldWishInfo.wishSoulID) if goldWishInfo.isMustGet then UIUtils.SetLabel(self.Item_GoldWish.txt_Discount, self.wishNotInitialChance) else UIUtils.SetLabel(self.Item_GoldWish.txt_Discount, self.wishInitialChance) end CTL.HorseSoul.SetStarLevel(self.Item_GoldWish.item.group_Star, 0) else self.Item_GoldWish.state_GoldWish:SetState(2) end else self.Item_GoldWish.state_GoldWish:SetState(1) end UIUtils.SetLabel(self.lab_wontInfo, "") if self.isUnLockRedWish then if self.isUnLockGoldWish then UIUtils.SetLabelText(self.lab_wontInfo, Const_IDS.IDS_HorseSoul_DrawHint19) else -- 解锁金色心愿条件 local GoldWishUnlockDrawNum = DataSheetManager.HorseSoulDrawWish:GetDataByWishID(2).UnlockDrawNum -- 金色心愿解锁需要抽数 UIUtils.SetLabel(self.lab_wontInfo, string.FormatByIdsId(Const_IDS.IDS_HorseSoul_DrawHint6, GoldWishUnlockDrawNum - self.drawHorseSoulServerInfo.drawNum, UIUtils.GetLocalizedTxt(Const_IDS.IDS_HorseSoul_DrawHint5))) end else -- 解锁红色心愿条件 local RedWishUnlockDrawNum = DataSheetManager.HorseSoulDrawWish:GetDataByWishID(1).UnlockDrawNum -- 红色心愿解锁需要抽数 UIUtils.SetLabel(self.lab_wontInfo, string.FormatByIdsId(Const_IDS.IDS_HorseSoul_DrawHint6, RedWishUnlockDrawNum - self.drawHorseSoulServerInfo.drawNum, UIUtils.GetLocalizedTxt(Const_IDS.IDS_HorseSoul_DrawHint4))) end end function UIHorseSoulGachaMain:ProcessDrawCardOne() local canBuy, ids = MDL.HorseSoul.CanDrawCardByCount(1) if not canBuy then CTL.Tips.AddTipsMsg(ids) return end local countInBag = MDL.Bag.GetItemCount(self.itemStoreId) --付费购买 if countInBag >= self.gachaPoolData.OneDrawItemNum then --购买 MDL.HorseSoul.DrawHorseSoulReq(self.curDrawPoolID, 1) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HorseSoul_DrawHint10) end end function UIHorseSoulGachaMain:ProcessDrawCardTen() local canBuy, ids = MDL.HorseSoul.CanDrawCardByCount(10) if not canBuy then CTL.Tips.AddTipsMsg(ids) return end local countInBag = MDL.Bag.GetItemCount(self.itemStoreId) if countInBag >= self.gachaPoolData.TenDrawItemNum then --购买 MDL.HorseSoul.DrawHorseSoulReq(self.curDrawPoolID, 10) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HorseSoul_DrawHint10) end end function UIHorseSoulGachaMain:ProcessDrawCardHun() local canBuy, ids = MDL.HorseSoul.CanDrawCardByCount(HorseSoullargeDrawNum) if not canBuy then CTL.Tips.AddTipsMsg(ids) return end local countInBag = MDL.Bag.GetItemCount(self.itemStoreId) if countInBag >= HorseSoullargeDrawNum then --购买 MDL.HorseSoul.DrawHorseSoulReq(self.curDrawPoolID, HorseSoullargeDrawNum) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HorseSoul_DrawHint10) end end return UIHorseSoulGachaMain