dev_chengFeng
ZhangBiao 2020-08-13 16:38:40 +08:00
parent fbf7c3b41d
commit e397fa88e7
1 changed files with 32 additions and 14 deletions

View File

@ -58,6 +58,8 @@ function this:BindEvent()
this.text:SetActive(false) this.text:SetActive(false)
this.cost:SetActive(false) this.cost:SetActive(false)
this.ShowCostInfo()
local value = this.RebuildData(msg.heroTempId,curSelectHero) local value = this.RebuildData(msg.heroTempId,curSelectHero)
this.SetHero(this.replaceHero,value) this.SetHero(this.replaceHero,value)
end) end)
@ -80,6 +82,8 @@ function this:BindEvent()
this.text:SetActive(false) this.text:SetActive(false)
this.cost:SetActive(true) this.cost:SetActive(true)
this.ShowCostInfo()
end) end)
end) end)
--保存置换 --保存置换
@ -93,6 +97,8 @@ function this:BindEvent()
this.text:SetActive(true) this.text:SetActive(true)
this.cost:SetActive(false) this.cost:SetActive(false)
this.ShowCostInfo()
HeroManager.DeleteHeroDatas({curSelectHero.dynamicId}) HeroManager.DeleteHeroDatas({curSelectHero.dynamicId})
for i = 1, #msg.drop.Hero do for i = 1, #msg.drop.Hero do
@ -100,11 +106,13 @@ function this:BindEvent()
end end
curSelectHero = HeroManager.GetSingleHeroData(msg.drop.Hero[1].id) curSelectHero = HeroManager.GetSingleHeroData(msg.drop.Hero[1].id)
this.ShowCurrPosHeroReplace(curIndex) this.ShowCurrPosHeroReplace(curIndex)
for i = 1, #heroDatas do
if heroSelectBtn[i] and heroDatas[i] then -- for i = 1, #heroDatas do
heroSelectBtn[i]:SetActive(heroDatas[i].dynamicId == curSelectHero.dynamicId) -- if heroSelectBtn[i] and heroDatas[i] then
end -- heroSelectBtn[i]:SetActive(heroDatas[i].dynamicId == curSelectHero.dynamicId)
end -- end
-- end
end) end)
end) end)
@ -168,7 +176,10 @@ function this.ShowCurrPosHeroReplace(_curIndex)
this.needHero:SetActive(false) this.needHero:SetActive(false)
heroDatas = this.GetHeroDataByPosition(_curIndex) heroDatas = this.GetHeroDataByPosition(_curIndex)
this.ScrollView:SetData(heroDatas, function (index, go) this.ScrollView:SetData(heroDatas, function (index, go)
heroSelectBtn[index] = Util.GetGameObject(go.transform, "choosed") -- heroSelectBtn[index] = Util.GetGameObject(go.transform, "choosed")
-- if not heroSelectBtn[heroDatas[index].dynamicId] then
-- heroSelectBtn[heroDatas[index].dynamicId] = Util.GetGameObject(go.transform, "choosed")
-- end
this.SingleHeroDataShow(go, heroDatas[index]) this.SingleHeroDataShow(go, heroDatas[index])
end) end)
end end
@ -185,7 +196,7 @@ function this.GetHeroDataByPosition(_position)
end end
return heros return heros
end end
local oldChoose
--数据显示 --数据显示
function this.SingleHeroDataShow(_go,_heroData) function this.SingleHeroDataShow(_go,_heroData)
local go = _go local go = _go
@ -215,7 +226,10 @@ function this.SingleHeroDataShow(_go,_heroData)
local cardBtn = Util.GetGameObject(go.transform, "icon") local cardBtn = Util.GetGameObject(go.transform, "icon")
local choosed = Util.GetGameObject(go.transform, "choosed") local choosed = Util.GetGameObject(go.transform, "choosed")
choosed:SetActive(false) choosed:SetActive(false)
if curSelectHero.dynamicId == heroData.dynamicId then
choosed:SetActive(true)
oldChoose = choosed
end
this.replaceBtn:SetActive(true) this.replaceBtn:SetActive(true)
this.cancelBtn:SetActive(false) this.cancelBtn:SetActive(false)
this.saveBtn:SetActive(false) this.saveBtn:SetActive(false)
@ -226,7 +240,6 @@ function this.SingleHeroDataShow(_go,_heroData)
if curSelectHero.id then if curSelectHero.id then
this.SetHero(this.needHero,curSelectHero) this.SetHero(this.needHero,curSelectHero)
choosed:SetActive(true)
this.ShowCostInfo() this.ShowCostInfo()
this.needHero:SetActive(true) this.needHero:SetActive(true)
this.replaceHero:SetActive(false) this.replaceHero:SetActive(false)
@ -239,6 +252,7 @@ function this.SingleHeroDataShow(_go,_heroData)
Util.AddOnceClick(cardBtn, function() Util.AddOnceClick(cardBtn, function()
if heroData.dynamicId == curSelectHero.dynamicId then if heroData.dynamicId == curSelectHero.dynamicId then
choosed:SetActive(false) choosed:SetActive(false)
oldChoose = nil
curSelectHero = {} curSelectHero = {}
this.needHero:SetActive(false) this.needHero:SetActive(false)
@ -253,6 +267,10 @@ function this.SingleHeroDataShow(_go,_heroData)
else else
choosed:SetActive(true) choosed:SetActive(true)
if oldChoose then
oldChoose:SetActive(false)
end
oldChoose = choosed
curSelectHero = heroData curSelectHero = heroData
this.ShowCostInfo() this.ShowCostInfo()
this.needHero:SetActive(true) this.needHero:SetActive(true)
@ -291,11 +309,11 @@ function this.SingleHeroDataShow(_go,_heroData)
end end
end end
for i = 1, #heroDatas do -- for i = 1, #heroDatas do
if heroSelectBtn[i] and heroDatas[i] then -- if heroSelectBtn[i] and heroDatas[i] then
heroSelectBtn[i]:SetActive(heroDatas[i].dynamicId == curSelectHero.dynamicId) -- heroSelectBtn[i]:SetActive(heroDatas[i].dynamicId == curSelectHero.dynamicId)
end -- end
end -- end
end) end)