【心愿抽卡】代码基本完成
parent
cc16057438
commit
262b52c4aa
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,7 @@
|
||||||
----- 心愿抽卡弹窗 -----
|
----- 心愿抽卡弹窗 -----
|
||||||
local this = {}
|
local this = {}
|
||||||
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
||||||
|
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
||||||
|
|
||||||
function this:InitComponent(gameObject)
|
function this:InitComponent(gameObject)
|
||||||
self.spLoader = SpriteLoader.New()
|
self.spLoader = SpriteLoader.New()
|
||||||
|
@ -10,10 +12,12 @@ function this:InitComponent(gameObject)
|
||||||
local rootHight = self.scroll.transform.rect.height
|
local rootHight = self.scroll.transform.rect.height
|
||||||
local width = self.scroll.transform.rect.width
|
local width = self.scroll.transform.rect.width
|
||||||
self.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scroll.transform,
|
self.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scroll.transform,
|
||||||
self.itemPre, nil, Vector2.New(width, rootHight), 1, 5, Vector2.New(20, 35))
|
self.itemPre, nil, Vector2.New(width, rootHight), 1, 5, Vector2.New(20, 45))
|
||||||
self.scrollView.moveTween.MomentumAmount = 1
|
self.scrollView.moveTween.MomentumAmount = 1
|
||||||
self.scrollView.moveTween.Strength = 2
|
self.scrollView.moveTween.Strength = 2
|
||||||
|
|
||||||
|
self.itemList = {}
|
||||||
|
self.maskList = {}
|
||||||
--wishList
|
--wishList
|
||||||
self.wishListObj = {}
|
self.wishListObj = {}
|
||||||
for i = 1, 3 do
|
for i = 1, 3 do
|
||||||
|
@ -23,21 +27,18 @@ function this:InitComponent(gameObject)
|
||||||
self.tabListObj = {}
|
self.tabListObj = {}
|
||||||
self.selectBtn = Util.GetGameObject(gameObject,"Tabs/grid/selectBtn")
|
self.selectBtn = Util.GetGameObject(gameObject,"Tabs/grid/selectBtn")
|
||||||
for j = 1, 4 do
|
for j = 1, 4 do
|
||||||
|
self.maskList[j] = {}
|
||||||
|
self.itemList[j] = {}
|
||||||
self.tabListObj[j] = Util.GetGameObject(gameObject,"Tabs/grid/Btn"..j)
|
self.tabListObj[j] = Util.GetGameObject(gameObject,"Tabs/grid/Btn"..j)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
local data222 = {
|
end
|
||||||
[1] = {id = 1,heroTid = 10023},
|
|
||||||
[2] = {id=2,heroTid=10034}
|
|
||||||
}
|
|
||||||
|
|
||||||
function this:BindEvent()
|
function this:BindEvent()
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
Util.AddOnceClick(self.tabListObj[i],function ()
|
Util.AddOnceClick(self.tabListObj[i],function ()
|
||||||
self.curSelect = i
|
self.curSelect = i
|
||||||
this:Refresh(false,false)
|
this:Refresh(false,false)
|
||||||
NetManager.ChoiceWishHeroRequest(data222)
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -51,21 +52,103 @@ end
|
||||||
function this:OnShow(_parent,...)
|
function this:OnShow(_parent,...)
|
||||||
self.parent=_parent
|
self.parent=_parent
|
||||||
self.sortingOrder = _parent.sortingOrder
|
self.sortingOrder = _parent.sortingOrder
|
||||||
|
|
||||||
self.curSelect = 1
|
self.curSelect = 1
|
||||||
|
|
||||||
NetManager.ChoiceWishHeroRequest(nil)
|
NetManager.ChoiceWishHeroRequest(nil,function ()
|
||||||
this:Refresh(true,true)
|
this:Refresh(true,true)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function this:Refresh(isTop,isAni)
|
function this:Refresh(isTop,isAni)
|
||||||
self.selectBtn:GetComponent("RectTransform").localPosition = self.tabListObj[self.curSelect]:GetComponent("RectTransform").localPosition
|
self.selectBtn:GetComponent("RectTransform").localPosition = self.tabListObj[self.curSelect]:GetComponent("RectTransform").localPosition
|
||||||
this:SetHeroList()
|
this:SetHeroList(isTop,isAni)
|
||||||
|
this:SetUpHero()
|
||||||
end
|
end
|
||||||
|
|
||||||
function this:SetHeroList()
|
function this:SetUpHero()
|
||||||
local heroList = RecruitManager.GetRewardPreviewData(PRE_REWARD_POOL_TYPE.RECRUIT)
|
for i = 1, 3 do
|
||||||
-- body
|
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")
|
||||||
|
local heroId = RecruitManager.WishCardData[i].heroTid
|
||||||
|
frame.gameObject:SetActive(true)
|
||||||
|
proIcon.gameObject:SetActive(true)
|
||||||
|
starGrid:SetActive(true)
|
||||||
|
choosed:SetActive(false)
|
||||||
|
if heroId > 0 then
|
||||||
|
local heroData = heroConfig[heroId]
|
||||||
|
frame.sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.Quality,heroData.Star))
|
||||||
|
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
|
||||||
|
PopupTipPanel.ShowTip("同系神将每日只可选择一位获取一次概率提升~")
|
||||||
|
elseif RecruitManager.WishCardData[i].status == 0 then
|
||||||
|
RecruitManager.ChangeHero(2,heroId,function ()
|
||||||
|
this:Refresh(false,false)
|
||||||
|
end)--英雄变更:1增加、2卸下
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
frame.gameObject:SetActive(false)
|
||||||
|
proIcon.gameObject:SetActive(false)
|
||||||
|
starGrid:SetActive(false)
|
||||||
|
icon.sprite = self.spLoader:LoadSprite("lingshou_jiahao")
|
||||||
|
end
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
|
||||||
|
function this:ShowSingleHero(go,data,index)
|
||||||
|
local heroData = heroConfig[data.Reward[1]]
|
||||||
|
self.itemList[self.curSelect][index] = go
|
||||||
|
Util.GetGameObject(go, "frame"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.Quality,heroData.Star))
|
||||||
|
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 ()
|
||||||
|
PopupTipPanel.ShowTip("同系神将只可选择一位~")
|
||||||
|
end)
|
||||||
|
elseif value == 2 then--上方选满
|
||||||
|
Util.SetGray(self.itemList[self.curSelect][index],true)
|
||||||
|
Util.AddOnceClick(go,function ()
|
||||||
|
PopupTipPanel.ShowTip("心愿神将已满~")
|
||||||
|
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)
|
||||||
|
elseif value == 3 then--可选
|
||||||
|
Util.AddOnceClick(go,function ()
|
||||||
|
RecruitManager.ChangeHero(1,data.Reward[1],function ()
|
||||||
|
this:Refresh(false,false)
|
||||||
|
end)--英雄变更:1增加、2卸下
|
||||||
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function this:OnClose()
|
function this:OnClose()
|
||||||
|
|
|
@ -4,6 +4,7 @@ local this = RecruitManager
|
||||||
local lotterySetting = ConfigManager.GetConfig(ConfigName.LotterySetting)
|
local lotterySetting = ConfigManager.GetConfig(ConfigName.LotterySetting)
|
||||||
local lotteryRewardConfig = ConfigManager.GetConfig(ConfigName.LotteryRewardConfig)
|
local lotteryRewardConfig = ConfigManager.GetConfig(ConfigName.LotteryRewardConfig)
|
||||||
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
||||||
|
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
||||||
local dailyRewardConfig = ConfigManager.GetConfig(ConfigName.DialRewardConfig)
|
local dailyRewardConfig = ConfigManager.GetConfig(ConfigName.DialRewardConfig)
|
||||||
|
|
||||||
--活动抽卡类型(动态的数据)
|
--活动抽卡类型(动态的数据)
|
||||||
|
@ -27,6 +28,7 @@ function this.Initialize()
|
||||||
this.boxReward = {}
|
this.boxReward = {}
|
||||||
this.recruitFreeUseTime = 0 --现在只剩下秘盒招募在用了
|
this.recruitFreeUseTime = 0 --现在只剩下秘盒招募在用了
|
||||||
this.isTenRecruit = 0 --首次十连
|
this.isTenRecruit = 0 --首次十连
|
||||||
|
this.WishCardData = {}
|
||||||
|
|
||||||
this.isFirstEnterElementScroll=true
|
this.isFirstEnterElementScroll=true
|
||||||
this.isFirstEnterHeroScroll=true
|
this.isFirstEnterHeroScroll=true
|
||||||
|
@ -423,10 +425,74 @@ end
|
||||||
|
|
||||||
--===================心愿抽卡界面逻辑===================
|
--===================心愿抽卡界面逻辑===================
|
||||||
function this.GetWishCardData(infoList)
|
function this.GetWishCardData(infoList)
|
||||||
LogYellow("infoList:"..tostring(#infoList))
|
|
||||||
for i = 1, #infoList do
|
for i = 1, #infoList do
|
||||||
LogPink("Id:"..tostring(infoList[i].id).." heroIid:"..tostring(infoList[i].heroTid).." status:"..tostring(infoList[i].status))
|
LogPink("Id:"..tostring(infoList[i].id).." heroIid:"..tostring(infoList[i].heroTid).." status:"..tostring(infoList[i].status))
|
||||||
end
|
end
|
||||||
|
this.WishCardData = infoList
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.GetCurHeroList(curIndex)
|
||||||
|
local heroList = {}
|
||||||
|
for index, v in ipairs(RecruitManager.GetRewardPreviewData(PRE_REWARD_POOL_TYPE.RECRUIT)) do
|
||||||
|
if heroConfig[v.Reward[1]].Star == 5 and heroConfig[v.Reward[1]].PropertyName == curIndex then
|
||||||
|
table.insert(heroList,v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return heroList
|
||||||
|
end
|
||||||
|
|
||||||
|
--检测当前英雄状态
|
||||||
|
function this.CheckCurHeroState(_heroTid)
|
||||||
|
for i = 1, #this.WishCardData do
|
||||||
|
if this.WishCardData[i].heroTid == _heroTid then
|
||||||
|
--如果上方存在自己就✔
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i = 1, #this.WishCardData do
|
||||||
|
if this.WishCardData[i].heroTid > 0 and heroConfig[this.WishCardData[i].heroTid].PropertyName == heroConfig[_heroTid].PropertyName then
|
||||||
|
--如果上方存在和当前英雄相同阵营的就置灰
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local num = 0
|
||||||
|
for i = 1, #this.WishCardData do
|
||||||
|
if this.WishCardData[i].heroTid > 0 then
|
||||||
|
num = num + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if num == 3 then
|
||||||
|
--如果上方神将满则其他全部置灰
|
||||||
|
return 2
|
||||||
|
end
|
||||||
|
--都没有就亮着
|
||||||
|
return 3
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.ChangeHero(type,_heroTid,func)
|
||||||
|
if type == 1 then --增加神将
|
||||||
|
for i = 1, #this.WishCardData do
|
||||||
|
if this.WishCardData[i].heroTid == 0 then
|
||||||
|
this.WishCardData[i].heroTid = _heroTid
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif type == 2 then --卸下神将
|
||||||
|
for i = 1, #this.WishCardData do
|
||||||
|
if this.WishCardData[i].heroTid == _heroTid then
|
||||||
|
this.WishCardData[i].heroTid = 0
|
||||||
|
break
|
||||||
|
else
|
||||||
|
Log("未找到需要卸下的神将")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
NetManager.ChoiceWishHeroRequest(this.WishCardData,function ()
|
||||||
|
if func then
|
||||||
|
func()
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return this
|
return this
|
Loading…
Reference in New Issue