From e397fa88e770f3c9b564726337530d0d92734cb6 Mon Sep 17 00:00:00 2001 From: ZhangBiao Date: Thu, 13 Aug 2020 16:38:40 +0800 Subject: [PATCH] --- .../view/CompoundHero_Replace.lua | 46 +++++++++++++------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Modules/CompoundHero/view/CompoundHero_Replace.lua b/Assets/ManagedResources/~Lua/Modules/CompoundHero/view/CompoundHero_Replace.lua index 9f7af421c5..a02909b26d 100644 --- a/Assets/ManagedResources/~Lua/Modules/CompoundHero/view/CompoundHero_Replace.lua +++ b/Assets/ManagedResources/~Lua/Modules/CompoundHero/view/CompoundHero_Replace.lua @@ -58,6 +58,8 @@ function this:BindEvent() this.text:SetActive(false) this.cost:SetActive(false) + this.ShowCostInfo() + local value = this.RebuildData(msg.heroTempId,curSelectHero) this.SetHero(this.replaceHero,value) end) @@ -80,6 +82,8 @@ function this:BindEvent() this.text:SetActive(false) this.cost:SetActive(true) + this.ShowCostInfo() + end) end) --保存置换 @@ -93,6 +97,8 @@ function this:BindEvent() this.text:SetActive(true) this.cost:SetActive(false) + this.ShowCostInfo() + HeroManager.DeleteHeroDatas({curSelectHero.dynamicId}) for i = 1, #msg.drop.Hero do @@ -100,11 +106,13 @@ function this:BindEvent() end curSelectHero = HeroManager.GetSingleHeroData(msg.drop.Hero[1].id) this.ShowCurrPosHeroReplace(curIndex) - for i = 1, #heroDatas do - if heroSelectBtn[i] and heroDatas[i] then - heroSelectBtn[i]:SetActive(heroDatas[i].dynamicId == curSelectHero.dynamicId) - end - end + + -- for i = 1, #heroDatas do + -- if heroSelectBtn[i] and heroDatas[i] then + -- heroSelectBtn[i]:SetActive(heroDatas[i].dynamicId == curSelectHero.dynamicId) + -- end + -- end + end) end) @@ -168,7 +176,10 @@ function this.ShowCurrPosHeroReplace(_curIndex) this.needHero:SetActive(false) heroDatas = this.GetHeroDataByPosition(_curIndex) 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]) end) end @@ -185,7 +196,7 @@ function this.GetHeroDataByPosition(_position) end return heros end - +local oldChoose --数据显示 function this.SingleHeroDataShow(_go,_heroData) local go = _go @@ -215,7 +226,10 @@ function this.SingleHeroDataShow(_go,_heroData) local cardBtn = Util.GetGameObject(go.transform, "icon") local choosed = Util.GetGameObject(go.transform, "choosed") choosed:SetActive(false) - + if curSelectHero.dynamicId == heroData.dynamicId then + choosed:SetActive(true) + oldChoose = choosed + end this.replaceBtn:SetActive(true) this.cancelBtn:SetActive(false) this.saveBtn:SetActive(false) @@ -226,7 +240,6 @@ function this.SingleHeroDataShow(_go,_heroData) if curSelectHero.id then this.SetHero(this.needHero,curSelectHero) - choosed:SetActive(true) this.ShowCostInfo() this.needHero:SetActive(true) this.replaceHero:SetActive(false) @@ -239,6 +252,7 @@ function this.SingleHeroDataShow(_go,_heroData) Util.AddOnceClick(cardBtn, function() if heroData.dynamicId == curSelectHero.dynamicId then choosed:SetActive(false) + oldChoose = nil curSelectHero = {} this.needHero:SetActive(false) @@ -253,6 +267,10 @@ function this.SingleHeroDataShow(_go,_heroData) else choosed:SetActive(true) + if oldChoose then + oldChoose:SetActive(false) + end + oldChoose = choosed curSelectHero = heroData this.ShowCostInfo() this.needHero:SetActive(true) @@ -291,11 +309,11 @@ function this.SingleHeroDataShow(_go,_heroData) end end - for i = 1, #heroDatas do - if heroSelectBtn[i] and heroDatas[i] then - heroSelectBtn[i]:SetActive(heroDatas[i].dynamicId == curSelectHero.dynamicId) - end - end + -- for i = 1, #heroDatas do + -- if heroSelectBtn[i] and heroDatas[i] then + -- heroSelectBtn[i]:SetActive(heroDatas[i].dynamicId == curSelectHero.dynamicId) + -- end + -- end end)