2023-06-06 15:57:53 +08:00
|
|
|
|
----- 心愿抽卡弹窗 -----
|
|
|
|
|
local this = {}
|
|
|
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
|
|
|
|
local specialConfig = ConfigManager.GetConfig(ConfigName.SpecialConfig)
|
|
|
|
|
|
|
|
|
|
function this:InitComponent(gameObject)
|
|
|
|
|
self.spLoader = SpriteLoader.New()
|
|
|
|
|
self.okBtn = Util.GetGameObject(gameObject,"okBtn")
|
|
|
|
|
self.helpBtn = Util.GetGameObject(gameObject, "helpBtn")
|
|
|
|
|
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
|
|
|
|
|
self.infoTxt=Util.GetGameObject(gameObject,"Bg/tiao1/Text (1)"):GetComponent("Text")
|
|
|
|
|
self.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scroll.transform,
|
2023-08-29 17:58:24 +08:00
|
|
|
|
self.itemPre, nil, Vector2.New(width, rootHight), 1, 5, Vector2.New(20, 60))
|
2023-06-06 15:57:53 +08:00
|
|
|
|
self.scrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
self.scrollView.moveTween.Strength = 2
|
|
|
|
|
|
|
|
|
|
self.itemList = {}
|
|
|
|
|
self.maskList = {}
|
|
|
|
|
--wishList
|
|
|
|
|
self.wishListObj = {}
|
|
|
|
|
self.bgObjlist = {}
|
|
|
|
|
for i = 1, 3 do
|
|
|
|
|
self.wishListObj[i] = Util.GetGameObject(gameObject,"wishList/hero ("..i..")")
|
|
|
|
|
self.bgObjlist[i] = Util.GetGameObject(gameObject,"Bg/bglist/obj"..i)
|
|
|
|
|
Util.GetGameObject(self.bgObjlist[i], "frame"):GetComponent("Image").sprite = self.spLoader:LoadSprite("r_characterbg_goden")
|
|
|
|
|
--心愿神将现在只显示一个
|
|
|
|
|
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
|
|
|
|
|
end
|
|
|
|
|
--tabList
|
|
|
|
|
self.tabListObj = {}
|
|
|
|
|
self.selectBtn = Util.GetGameObject(gameObject,"Tabs/grid/selectBtn")
|
|
|
|
|
for j = 1, 4 do
|
|
|
|
|
self.maskList[j] = {}
|
|
|
|
|
self.itemList[j] = {}
|
|
|
|
|
self.tabListObj[j] = Util.GetGameObject(gameObject,"Tabs/grid/Btn"..j)
|
|
|
|
|
end
|
|
|
|
|
Util.GetGameObject(gameObject,"Tabs"):SetActive(false)
|
|
|
|
|
|
|
|
|
|
self.helpPosition = self.helpBtn:GetComponent("RectTransform").localPosition
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:BindEvent()
|
|
|
|
|
for i = 1, 4 do
|
|
|
|
|
Util.AddOnceClick(self.tabListObj[i],function ()
|
|
|
|
|
self.curSelect = i
|
|
|
|
|
this:Refresh(true,false)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
for i = 1, 3 do
|
|
|
|
|
|
|
|
|
|
Util.AddOnceClick(self.bgObjlist[i],function ()
|
|
|
|
|
--心愿只能选一个神将
|
|
|
|
|
if i>1 then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
self.curSelect = RecruitManager.CheckIndex()
|
|
|
|
|
this:Refresh(true,false)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Util.AddOnceClick(self.okBtn,function ()
|
|
|
|
|
LogError("点击确定按钮")
|
|
|
|
|
self.parent:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
--帮助按钮
|
|
|
|
|
Util.AddClick(self.helpBtn, function()
|
|
|
|
|
LogError("点击帮助按钮")
|
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.WishCard,self.helpPosition.x,self.helpPosition.y)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnShow(_parent,_Data)
|
|
|
|
|
self.parent=_parent
|
|
|
|
|
self.sortingOrder = _parent.sortingOrder
|
|
|
|
|
local args = _Data
|
|
|
|
|
--NetManager.ChoiceWishHeroRequest(nil,function ()
|
|
|
|
|
if args[1] then
|
|
|
|
|
self.curSelect = args[1]
|
|
|
|
|
else
|
2023-08-29 17:58:24 +08:00
|
|
|
|
self.curSelect = 1 -- RecruitManager.CheckIndex()
|
2023-06-06 15:57:53 +08:00
|
|
|
|
end
|
|
|
|
|
this:Refresh(true,false)
|
|
|
|
|
--end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:Refresh(isTop,isAni)
|
|
|
|
|
local data = tonumber(specialConfig[119].Value)
|
2023-08-29 17:58:24 +08:00
|
|
|
|
if not RecruitManager.drawTimes[4] or RecruitManager.drawTimes[4] < data then
|
2023-06-06 15:57:53 +08:00
|
|
|
|
self.parent:ClosePanel()
|
2023-08-29 17:58:24 +08:00
|
|
|
|
return
|
2023-06-06 15:57:53 +08:00
|
|
|
|
end
|
2023-12-08 21:57:53 +08:00
|
|
|
|
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>",RecruitManager.GetWishPro(),"%")
|
2023-06-06 15:57:53 +08:00
|
|
|
|
self.infoTxt.text=aaa
|
|
|
|
|
self.selectBtn:SetActive(false)
|
|
|
|
|
--self.selectBtn:GetComponent("RectTransform").localPosition = self.tabListObj[self.curSelect]:GetComponent("RectTransform").localPosition
|
|
|
|
|
this:SetHeroList(isTop,isAni)
|
|
|
|
|
this:SetUpHero()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:SetUpHero()
|
|
|
|
|
for i = 1, 1 do
|
|
|
|
|
local go = self.wishListObj[i]
|
|
|
|
|
|
|
|
|
|
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")
|
2023-08-29 17:58:24 +08:00
|
|
|
|
local heroId =0
|
|
|
|
|
if RecruitManager.WishEquipData[i] then
|
|
|
|
|
heroId=RecruitManager.WishEquipData[i].heroTid
|
|
|
|
|
end
|
2023-06-06 15:57:53 +08:00
|
|
|
|
choosed:SetActive(false)
|
|
|
|
|
if heroId > 0 then
|
|
|
|
|
go:SetActive(true)
|
|
|
|
|
local heroData = itemConfig[heroId]
|
|
|
|
|
frame.sprite = self.spLoader:LoadSprite(GetBgByHeroNatural(heroData.Quantity))
|
|
|
|
|
icon.sprite = self.spLoader:LoadSprite(GetResourcePath(heroData.ResourceID))
|
|
|
|
|
proIcon.gameObject:SetActive(false)
|
|
|
|
|
--proIcon.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(heroData.Name))
|
|
|
|
|
--SetHeroStars(self.spLoader,starGrid, heroData.Star)
|
2023-08-29 17:58:24 +08:00
|
|
|
|
choosed:SetActive(RecruitManager.WishEquipData[i].status == 1)
|
2023-06-06 15:57:53 +08:00
|
|
|
|
Util.AddOnceClick(go,function ()
|
2023-08-29 17:58:24 +08:00
|
|
|
|
if RecruitManager.WishEquipData[i].status == 1 then
|
2023-12-07 01:11:27 +08:00
|
|
|
|
PopupTipPanel.ShowTip("同系英雄每日只可选择一位获取一次概率提升~")
|
2023-08-29 17:58:24 +08:00
|
|
|
|
elseif RecruitManager.WishEquipData[i].status == 0 then
|
|
|
|
|
RecruitManager.ChangeEquip(2,heroId,function ()
|
2023-06-06 15:57:53 +08:00
|
|
|
|
this:Refresh(false,false)
|
|
|
|
|
end)--英雄变更:1增加、2卸下
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
go:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
LogError("i==================="..i)
|
|
|
|
|
if i>1 then
|
|
|
|
|
self.wishListObj[i]:SetActive(false)
|
|
|
|
|
LogError("false false")
|
|
|
|
|
end
|
|
|
|
|
Util.AddLongPressClick(go,function ()
|
|
|
|
|
UIManager.OpenPanel(UIName.RoleGetInfoPopup, false, heroId, 5)
|
|
|
|
|
end,0.5)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:SetHeroList(isTop,isAni)
|
2023-10-27 20:58:24 +08:00
|
|
|
|
local heroList =RecruitManager.allTailsMans --RecruitManager.GetCurHeroTalismanaList(0)
|
2023-06-06 15:57:53 +08:00
|
|
|
|
self.scrollView:SetData(heroList, function (index, item)
|
|
|
|
|
this:ShowSingleHero(item, heroList[index],index)
|
|
|
|
|
end,not isTop,not isAni)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:ShowSingleHero(go,data,index)
|
2023-10-27 20:58:24 +08:00
|
|
|
|
local equipId=data
|
2023-08-29 17:58:24 +08:00
|
|
|
|
local heroData = itemConfig[equipId]
|
2023-06-06 15:57:53 +08:00
|
|
|
|
self.itemList[self.curSelect][index] = go
|
|
|
|
|
Util.GetGameObject(go, "frame"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetBgByHeroNatural(heroData.Quantity))
|
|
|
|
|
Util.GetGameObject(go, "icon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetResourcePath(heroData.ResourceID))
|
|
|
|
|
--Util.GetGameObject(go, "proIcon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(heroData.PropertyName))
|
|
|
|
|
Util.GetGameObject(go, "proIcon"):SetActive(false)
|
|
|
|
|
Util.GetGameObject(go, "name"):GetComponent("Text").text = heroData.Name
|
2023-10-27 20:58:24 +08:00
|
|
|
|
Util.GetGameObject(go, "heroName"):GetComponent("Text").text= itemConfig[data].Name
|
2023-06-06 15:57:53 +08:00
|
|
|
|
local starGrid = Util.GetGameObject(go, "star")
|
2024-01-03 15:24:49 +08:00
|
|
|
|
Util.GetGameObject(go, "name").gameObject:SetActive(false)
|
2023-06-06 15:57:53 +08:00
|
|
|
|
-- 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)
|
|
|
|
|
|
2023-08-29 17:58:24 +08:00
|
|
|
|
local value = RecruitManager.CheckCurTalismanaState(equipId)
|
2023-10-27 20:58:24 +08:00
|
|
|
|
LogError("value==========================================="..value)
|
2023-06-06 15:57:53 +08:00
|
|
|
|
if value == 0 then--上方存在相同阵营
|
|
|
|
|
Util.SetGray(self.itemList[self.curSelect][index],true)
|
|
|
|
|
Util.AddOnceClick(go,function ()
|
2023-08-29 17:58:24 +08:00
|
|
|
|
--PopupTipPanel.ShowTip("同系法宝只可选择一位~")
|
2023-12-08 21:57:53 +08:00
|
|
|
|
PopupTipPanel.ShowTip("心愿生命卡已满~")
|
2023-06-06 15:57:53 +08:00
|
|
|
|
end)
|
|
|
|
|
elseif value == 2 then--上方选满
|
|
|
|
|
Util.SetGray(self.itemList[self.curSelect][index],true)
|
|
|
|
|
Util.AddOnceClick(go,function ()
|
2023-12-08 21:57:53 +08:00
|
|
|
|
PopupTipPanel.ShowTip("心愿生命卡已满~")
|
2023-06-06 15:57:53 +08:00
|
|
|
|
end)
|
|
|
|
|
elseif value == 1 then--上方存在自己
|
|
|
|
|
self.maskList[self.curSelect][index]:SetActive(true)
|
|
|
|
|
Util.AddOnceClick(go,function ()
|
2023-08-29 17:58:24 +08:00
|
|
|
|
RecruitManager.ChangeEquip(2,equipId,function ()
|
2023-06-06 15:57:53 +08:00
|
|
|
|
this:Refresh(false,false)
|
|
|
|
|
end)--英雄变更:1增加、2卸下
|
|
|
|
|
end)
|
|
|
|
|
elseif value == 4 then--上方存在自己,但已经出过该英雄了
|
|
|
|
|
self.maskList[self.curSelect][index]:SetActive(true)
|
|
|
|
|
Util.AddOnceClick(go,function ()
|
2023-12-07 01:11:27 +08:00
|
|
|
|
PopupTipPanel.ShowTip("同系英雄每日只可选择一位获取一次概率提升~")
|
2023-06-06 15:57:53 +08:00
|
|
|
|
end)
|
|
|
|
|
elseif value == 3 then--可选
|
|
|
|
|
Util.AddOnceClick(go,function ()
|
2023-08-29 17:58:24 +08:00
|
|
|
|
RecruitManager.ChangeEquip(1,equipId,function ()
|
2023-06-06 15:57:53 +08:00
|
|
|
|
this:Refresh(false,false)
|
|
|
|
|
end)--英雄变更:1增加、2卸下
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
Util.AddLongPressClick(go,function ()
|
2023-08-29 17:58:24 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, heroData.Id)
|
|
|
|
|
--UIManager.OpenPanel(UIName.RoleGetInfoPopup, false, data, 5)
|
2023-06-06 15:57:53 +08:00
|
|
|
|
end,0.5)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnClose()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnDestroy()
|
|
|
|
|
self.itemList = {}
|
|
|
|
|
self.maskList = {}
|
|
|
|
|
self.wishListObj = {}
|
|
|
|
|
self.tabListObj = {}
|
|
|
|
|
self.spLoader:Destroy()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return this
|