diff --git a/Assets/ManagedResources/~Lua/Modules/Compound/view/CompoundPanel_Equip.lua b/Assets/ManagedResources/~Lua/Modules/Compound/view/CompoundPanel_Equip.lua index b1a992fa02..53e6acb241 100644 --- a/Assets/ManagedResources/~Lua/Modules/Compound/view/CompoundPanel_Equip.lua +++ b/Assets/ManagedResources/~Lua/Modules/Compound/view/CompoundPanel_Equip.lua @@ -23,7 +23,8 @@ local curNeedEquip = {} local curSelectEquip = {} local curSelectGO local materidaIsCan = false -local bagPosEquips = {} +local bagPosEquips = {} +local needGoldNum = 0 function this:InitComponent(gameObject) this.tabBox = Util.GetGameObject(gameObject, "CompoundPanel_Equip/TabBox") this.needGoldText = Util.GetGameObject(gameObject, "CompoundPanel_Equip/compoundBtn/needGoldText"):GetComponent("Text") @@ -66,14 +67,27 @@ function this:BindEvent() end function this:AddListener() + Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold,this.ShowGoldNum0) end function this:RemoveListener() + Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold,this.ShowGoldNum0) +end + +function this.ShowGoldNum0() + if needGoldNum > BagManager.GetItemCountById(14) then + materidaIsCan = false + this.needGoldText.text = string.format("%s", needGoldNum) + else + materidaIsCan = true + this.needGoldText.text =string.format("%s", needGoldNum) + end end function this:OnShow(...) curIndex = 1 sortingOrder =0 + needGoldNum=0 this.TabCtrl = TabBox.New() this.TabCtrl:SetTabAdapter(this.TabAdapter) this.TabCtrl:SetChangeTabCallBack(this.SwitchView) @@ -118,7 +132,7 @@ function this.ShowTitleData(curEquipStarsConfig) this.ShowGoldNum(equipStarsConfig[curSelectEquip.Star - 1],compoundNum) end function this.ShowGoldNum(upEquipStarsConfig,compoundNum) - local needGoldNum = compoundNum * upEquipStarsConfig.RankupResources[1][2] + needGoldNum = compoundNum * upEquipStarsConfig.RankupResources[1][2] if needGoldNum > BagManager.GetItemCountById(upEquipStarsConfig.RankupResources[1][1]) then materidaIsCan = false this.needGoldText.text = string.format("%s", needGoldNum) @@ -330,9 +344,11 @@ function this.SwitchView(index) end function this:OnClose() + needGoldNum=0 end function this:OnDestroy() + needGoldNum=0 end return this \ No newline at end of file