2021-06-29 11:30:26 +08:00
|
|
|
|
----- 心愿抽卡弹窗 -----
|
|
|
|
|
local this = {}
|
2021-06-29 18:10:15 +08:00
|
|
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
2021-06-30 10:23:57 +08:00
|
|
|
|
local specialConfig = ConfigManager.GetConfig(ConfigName.SpecialConfig)
|
2021-06-29 11:30:26 +08:00
|
|
|
|
|
|
|
|
|
function this:InitComponent(gameObject)
|
|
|
|
|
self.spLoader = SpriteLoader.New()
|
2023-05-27 19:04:30 +08:00
|
|
|
|
self.okBtn = Util.GetGameObject(gameObject,"okBtn")
|
|
|
|
|
self.helpBtn = Util.GetGameObject(gameObject, "helpBtn")
|
2021-06-29 15:25:05 +08:00
|
|
|
|
self.scroll = Util.GetGameObject(gameObject,"selectList")
|
|
|
|
|
self.itemPre = Util.GetGameObject(gameObject,"itemPre")
|
|
|
|
|
-- 设置循环滚动,万一内容不停地加
|
|
|
|
|
local rootHight = self.scroll.transform.rect.height
|
|
|
|
|
local width = self.scroll.transform.rect.width
|
2023-05-27 19:04:30 +08:00
|
|
|
|
self.infoTxt=Util.GetGameObject(gameObject,"Bg/tiao1/Text (1)"):GetComponent("Text")
|
2023-08-29 17:58:24 +08:00
|
|
|
|
self.infoTxt2=Util.GetGameObject(gameObject,"Bg/tiao2/Text (1)"):GetComponent("Text")
|
2023-12-07 00:09:44 +08:00
|
|
|
|
self.infoTxt2.text="英雄<color=#31FF00>每日</color>只可<color=#31FF00>选择并获取一次</color>概率提升"
|
2021-06-29 15:25:05 +08:00
|
|
|
|
self.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scroll.transform,
|
2021-06-29 18:10:15 +08:00
|
|
|
|
self.itemPre, nil, Vector2.New(width, rootHight), 1, 5, Vector2.New(20, 45))
|
2021-06-29 15:25:05 +08:00
|
|
|
|
self.scrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
self.scrollView.moveTween.Strength = 2
|
|
|
|
|
|
2021-06-29 18:10:15 +08:00
|
|
|
|
self.itemList = {}
|
|
|
|
|
self.maskList = {}
|
2021-06-29 15:25:05 +08:00
|
|
|
|
--wishList
|
|
|
|
|
self.wishListObj = {}
|
2021-06-30 13:51:47 +08:00
|
|
|
|
self.bgObjlist = {}
|
2021-06-29 15:25:05 +08:00
|
|
|
|
for i = 1, 3 do
|
|
|
|
|
self.wishListObj[i] = Util.GetGameObject(gameObject,"wishList/hero ("..i..")")
|
2021-06-30 13:51:47 +08:00
|
|
|
|
self.bgObjlist[i] = Util.GetGameObject(gameObject,"Bg/bglist/obj"..i)
|
2024-12-23 16:21:08 +08:00
|
|
|
|
Util.GetGameObject(self.bgObjlist[i], "frame"):GetComponent("Image").sprite = self.spLoader:LoadSprite("UI_hz_beibao_duigoudi")
|
2023-05-27 19:04:30 +08:00
|
|
|
|
--心愿神将现在只显示一个
|
|
|
|
|
if i>1 then
|
|
|
|
|
self.wishListObj[i]:SetActive(false)
|
|
|
|
|
self.bgObjlist[i]:SetActive(false)
|
|
|
|
|
else
|
|
|
|
|
self.wishListObj[i]:SetActive(true)
|
|
|
|
|
self.bgObjlist[i]:SetActive(true)
|
|
|
|
|
end
|
2021-06-29 15:25:05 +08:00
|
|
|
|
end
|
|
|
|
|
--tabList
|
|
|
|
|
self.tabListObj = {}
|
|
|
|
|
self.selectBtn = Util.GetGameObject(gameObject,"Tabs/grid/selectBtn")
|
|
|
|
|
for j = 1, 4 do
|
2021-06-29 18:10:15 +08:00
|
|
|
|
self.maskList[j] = {}
|
|
|
|
|
self.itemList[j] = {}
|
2021-06-29 15:25:05 +08:00
|
|
|
|
self.tabListObj[j] = Util.GetGameObject(gameObject,"Tabs/grid/Btn"..j)
|
|
|
|
|
end
|
2021-06-29 11:30:26 +08:00
|
|
|
|
|
2023-05-27 19:04:30 +08:00
|
|
|
|
|
2021-07-10 18:50:39 +08:00
|
|
|
|
self.helpPosition = self.helpBtn:GetComponent("RectTransform").localPosition
|
2021-06-29 18:10:15 +08:00
|
|
|
|
end
|
2021-06-29 11:30:26 +08:00
|
|
|
|
|
2021-06-29 15:25:05 +08:00
|
|
|
|
function this:BindEvent()
|
|
|
|
|
for i = 1, 4 do
|
|
|
|
|
Util.AddOnceClick(self.tabListObj[i],function ()
|
|
|
|
|
self.curSelect = i
|
2021-06-29 20:29:22 +08:00
|
|
|
|
this:Refresh(true,false)
|
2021-06-29 15:25:05 +08:00
|
|
|
|
end)
|
|
|
|
|
end
|
2021-06-30 13:51:47 +08:00
|
|
|
|
for i = 1, 3 do
|
2023-05-27 19:04:30 +08:00
|
|
|
|
|
2021-06-30 13:51:47 +08:00
|
|
|
|
Util.AddOnceClick(self.bgObjlist[i],function ()
|
2023-05-27 19:04:30 +08:00
|
|
|
|
--心愿只能选一个神将
|
|
|
|
|
if i>1 then
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-06-30 13:51:47 +08:00
|
|
|
|
self.curSelect = RecruitManager.CheckIndex()
|
|
|
|
|
this:Refresh(true,false)
|
|
|
|
|
end)
|
|
|
|
|
end
|
2021-07-10 18:50:39 +08:00
|
|
|
|
|
|
|
|
|
Util.AddOnceClick(self.okBtn,function ()
|
2023-05-27 19:04:30 +08:00
|
|
|
|
LogError("点击确定按钮")
|
2021-07-10 18:50:39 +08:00
|
|
|
|
self.parent:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
--帮助按钮
|
|
|
|
|
Util.AddClick(self.helpBtn, function()
|
2023-05-27 19:04:30 +08:00
|
|
|
|
LogError("点击帮助按钮")
|
2021-07-10 18:50:39 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.WishCard,self.helpPosition.x,self.helpPosition.y)
|
|
|
|
|
end)
|
2021-06-29 11:30:26 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
|
2021-09-18 17:58:28 +08:00
|
|
|
|
function this:OnShow(_parent,_Data)
|
2021-06-29 15:25:05 +08:00
|
|
|
|
self.parent=_parent
|
|
|
|
|
self.sortingOrder = _parent.sortingOrder
|
2021-09-18 17:58:28 +08:00
|
|
|
|
local args = _Data
|
2023-06-06 15:57:53 +08:00
|
|
|
|
--NetManager.ChoiceWishHeroRequest(nil,function ()
|
2021-07-16 11:19:36 +08:00
|
|
|
|
if args[1] then
|
|
|
|
|
self.curSelect = args[1]
|
|
|
|
|
else
|
|
|
|
|
self.curSelect = RecruitManager.CheckIndex()
|
2022-01-17 14:26:17 +08:00
|
|
|
|
end
|
|
|
|
|
this:Refresh(true,false)
|
2023-06-06 15:57:53 +08:00
|
|
|
|
--end)
|
2021-06-29 11:30:26 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-06-29 15:25:05 +08:00
|
|
|
|
function this:Refresh(isTop,isAni)
|
2021-06-30 10:23:57 +08:00
|
|
|
|
local data = tonumber(specialConfig[119].Value)
|
2021-06-30 12:01:39 +08:00
|
|
|
|
if not RecruitManager.drawTimes[1] or RecruitManager.drawTimes[1] < data then
|
2021-06-30 10:23:57 +08:00
|
|
|
|
self.parent:ClosePanel()
|
|
|
|
|
end
|
2024-05-24 15:14:47 +08:00
|
|
|
|
|
2021-06-29 15:25:05 +08:00
|
|
|
|
self.selectBtn:GetComponent("RectTransform").localPosition = self.tabListObj[self.curSelect]:GetComponent("RectTransform").localPosition
|
2021-06-29 18:10:15 +08:00
|
|
|
|
this:SetHeroList(isTop,isAni)
|
|
|
|
|
this:SetUpHero()
|
2024-05-24 15:14:47 +08:00
|
|
|
|
local pro,pro1=RecruitManager.GetWishPro()
|
|
|
|
|
LogError("pro==============="..pro.." pro1=="..pro1)
|
|
|
|
|
local showPro=pro
|
|
|
|
|
if RecruitManager.WishCardData[1] then
|
|
|
|
|
|
|
|
|
|
local id=RecruitManager.WishCardData[1].heroTid
|
|
|
|
|
LogError("you yingxiong ======================================"..id)
|
|
|
|
|
if heroConfig[id] then
|
|
|
|
|
if heroConfig[id].Natural<=6 then
|
|
|
|
|
showPro=pro
|
|
|
|
|
elseif heroConfig[id].Natural==7 then
|
|
|
|
|
showPro=pro1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local aaa=string.format("抽到<size=35><color=#31FF00>5星</color></size>神将时,有<size=35><color=#31FF00>%s%s</color></size>几率转化为<size=35><color=#31FF00>心愿神将!</color></size>",showPro,"%")
|
|
|
|
|
self.infoTxt.text=aaa
|
2021-06-29 18:10:15 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:SetUpHero()
|
2023-05-27 19:04:30 +08:00
|
|
|
|
for i = 1, 1 do
|
2021-06-29 18:10:15 +08:00
|
|
|
|
local go = self.wishListObj[i]
|
2023-05-27 19:04:30 +08:00
|
|
|
|
|
2021-06-29 18:10:15 +08:00
|
|
|
|
local frame = Util.GetGameObject(go, "frame"):GetComponent("Image")
|
|
|
|
|
local icon = Util.GetGameObject(go, "icon"):GetComponent("Image")
|
|
|
|
|
local proIcon = Util.GetGameObject(go, "proIcon"):GetComponent("Image")
|
|
|
|
|
local starGrid = Util.GetGameObject(go, "star")
|
|
|
|
|
local choosed = Util.GetGameObject(go, "choosed")
|
|
|
|
|
local heroId = RecruitManager.WishCardData[i].heroTid
|
|
|
|
|
choosed:SetActive(false)
|
|
|
|
|
if heroId > 0 then
|
2021-06-30 13:51:47 +08:00
|
|
|
|
go:SetActive(true)
|
2021-06-29 18:10:15 +08:00
|
|
|
|
local heroData = heroConfig[heroId]
|
2022-01-14 18:40:00 +08:00
|
|
|
|
frame.sprite = self.spLoader:LoadSprite(GetBgByHeroNatural(heroData.Natural))
|
2021-06-29 18:10:15 +08:00
|
|
|
|
icon.sprite = self.spLoader:LoadSprite(GetResourcePath(heroData.Icon))
|
|
|
|
|
proIcon.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(heroData.PropertyName))
|
|
|
|
|
SetHeroStars(self.spLoader,starGrid, heroData.Star)
|
|
|
|
|
choosed:SetActive(RecruitManager.WishCardData[i].status == 1)
|
|
|
|
|
Util.AddOnceClick(go,function ()
|
|
|
|
|
if RecruitManager.WishCardData[i].status == 1 then
|
2023-12-07 00:09:44 +08:00
|
|
|
|
PopupTipPanel.ShowTip("同系英雄每日只可选择一位获取一次概率提升~")
|
2021-06-29 18:10:15 +08:00
|
|
|
|
elseif RecruitManager.WishCardData[i].status == 0 then
|
|
|
|
|
RecruitManager.ChangeHero(2,heroId,function ()
|
|
|
|
|
this:Refresh(false,false)
|
|
|
|
|
end)--英雄变更:1增加、2卸下
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
else
|
2021-06-30 13:51:47 +08:00
|
|
|
|
go:SetActive(false)
|
2021-06-29 18:10:15 +08:00
|
|
|
|
end
|
2023-08-29 17:58:24 +08:00
|
|
|
|
--LogError("i==================="..i)
|
2023-05-27 19:04:30 +08:00
|
|
|
|
if i>1 then
|
|
|
|
|
self.wishListObj[i]:SetActive(false)
|
|
|
|
|
LogError("false false")
|
|
|
|
|
end
|
2021-07-02 11:54:33 +08:00
|
|
|
|
Util.AddLongPressClick(go,function ()
|
|
|
|
|
UIManager.OpenPanel(UIName.RoleGetInfoPopup, false, heroId, 5)
|
|
|
|
|
end,0.5)
|
2021-06-29 18:10:15 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:SetHeroList(isTop,isAni)
|
|
|
|
|
local heroList = RecruitManager.GetCurHeroList(self.curSelect)
|
|
|
|
|
self.scrollView:SetData(heroList, function (index, item)
|
|
|
|
|
this:ShowSingleHero(item, heroList[index],index)
|
|
|
|
|
end,not isTop,not isAni)
|
2021-06-29 11:30:26 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-06-29 18:10:15 +08:00
|
|
|
|
function this:ShowSingleHero(go,data,index)
|
|
|
|
|
local heroData = heroConfig[data.Reward[1]]
|
|
|
|
|
self.itemList[self.curSelect][index] = go
|
2022-01-14 18:40:00 +08:00
|
|
|
|
Util.GetGameObject(go, "frame"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetBgByHeroNatural(heroData.Natural))
|
2021-06-29 18:10:15 +08:00
|
|
|
|
Util.GetGameObject(go, "icon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetResourcePath(heroData.Icon))
|
|
|
|
|
Util.GetGameObject(go, "proIcon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(heroData.PropertyName))
|
|
|
|
|
Util.GetGameObject(go, "name"):GetComponent("Text").text = heroData.ReadingName
|
|
|
|
|
local starGrid = Util.GetGameObject(go, "star")
|
|
|
|
|
SetHeroStars(self.spLoader,starGrid, heroData.Star)
|
|
|
|
|
self.maskList[self.curSelect][index] = Util.GetGameObject(go, "choosed")
|
|
|
|
|
self.maskList[self.curSelect][index]:SetActive(false)
|
|
|
|
|
Util.SetGray(self.itemList[self.curSelect][index],false)
|
|
|
|
|
|
|
|
|
|
local value = RecruitManager.CheckCurHeroState(data.Reward[1])
|
|
|
|
|
if value == 0 then--上方存在相同阵营
|
|
|
|
|
Util.SetGray(self.itemList[self.curSelect][index],true)
|
|
|
|
|
Util.AddOnceClick(go,function ()
|
2023-12-07 00:09:44 +08:00
|
|
|
|
PopupTipPanel.ShowTip("同系英雄只可选择一位~")
|
2021-06-29 18:10:15 +08:00
|
|
|
|
end)
|
|
|
|
|
elseif value == 2 then--上方选满
|
|
|
|
|
Util.SetGray(self.itemList[self.curSelect][index],true)
|
|
|
|
|
Util.AddOnceClick(go,function ()
|
2023-12-07 00:09:44 +08:00
|
|
|
|
PopupTipPanel.ShowTip("心愿英雄已满~")
|
2021-06-29 18:10:15 +08:00
|
|
|
|
end)
|
|
|
|
|
elseif value == 1 then--上方存在自己
|
|
|
|
|
self.maskList[self.curSelect][index]:SetActive(true)
|
|
|
|
|
Util.AddOnceClick(go,function ()
|
|
|
|
|
RecruitManager.ChangeHero(2,data.Reward[1],function ()
|
|
|
|
|
this:Refresh(false,false)
|
|
|
|
|
end)--英雄变更:1增加、2卸下
|
|
|
|
|
end)
|
2021-06-30 10:52:05 +08:00
|
|
|
|
elseif value == 4 then--上方存在自己,但已经出过该英雄了
|
|
|
|
|
self.maskList[self.curSelect][index]:SetActive(true)
|
|
|
|
|
Util.AddOnceClick(go,function ()
|
2023-12-07 00:09:44 +08:00
|
|
|
|
PopupTipPanel.ShowTip("同系英雄每日只可选择一位获取一次概率提升~")
|
2021-06-30 10:52:05 +08:00
|
|
|
|
end)
|
2021-06-29 18:10:15 +08:00
|
|
|
|
elseif value == 3 then--可选
|
|
|
|
|
Util.AddOnceClick(go,function ()
|
|
|
|
|
RecruitManager.ChangeHero(1,data.Reward[1],function ()
|
|
|
|
|
this:Refresh(false,false)
|
|
|
|
|
end)--英雄变更:1增加、2卸下
|
|
|
|
|
end)
|
|
|
|
|
end
|
2021-06-30 10:58:35 +08:00
|
|
|
|
Util.AddLongPressClick(go,function ()
|
|
|
|
|
UIManager.OpenPanel(UIName.RoleGetInfoPopup, false, data.Reward[1], 5)
|
|
|
|
|
end,0.5)
|
2021-06-29 15:25:05 +08:00
|
|
|
|
end
|
2021-06-29 11:30:26 +08:00
|
|
|
|
|
|
|
|
|
function this:OnClose()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnDestroy()
|
2021-06-29 20:29:22 +08:00
|
|
|
|
self.itemList = {}
|
|
|
|
|
self.maskList = {}
|
|
|
|
|
self.wishListObj = {}
|
2021-12-20 11:33:36 +08:00
|
|
|
|
self.tabListObj = {}
|
2021-06-29 11:30:26 +08:00
|
|
|
|
self.spLoader:Destroy()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return this
|