This commit is contained in:
xiekaidong 2023-08-09 10:21:13 +08:00
parent ccb0f42081
commit 1eb1295c1c
2 changed files with 17 additions and 0 deletions

View File

@ -35,6 +35,12 @@ function GoldPigUI:onLoadRootComplete()
local nowGemImg = uiMap["gold_pig_ui.bg.slider.now_gem_bg.gem_img"]
GFunc.centerImgAndTx(nowGemImg, nowGemTx, 0, -4)
local currGold = DataManager.GoldPigData:getGoldCount()
local nowGoldTx = uiMap["gold_pig_ui.bg.now_gem_bg.gold_tx"]
nowGoldTx:setText(GFunc.intToString(currGold))
local nowGoldImg = uiMap["gold_pig_ui.bg.now_gem_bg.gold_img"]
GFunc.centerImgAndTx(nowGoldImg, nowGoldTx, 0, -4)
local sliderWidth = uiMap["gold_pig_ui.bg.slider"]:getRectWidth()
uiMap["gold_pig_ui.bg.slider.now_gem_bg"]:setAnchoredPositionX((percent - 0.5) * sliderWidth)

View File

@ -17,6 +17,8 @@ function GoldPigData:init(data, initOnLogin)
end
self.data.count = data.add_diamond or 0
self.lastCount = self.data.count
self.data.goldCount = data.add_gold or 0
self.lastGoldCount = self.data.goldCount
self.maxCount = self:getMaxCount()
self.data.fullTime = (data.full_at or 0) // 1000
self.data.buyTime = (data.buy_at or 0) // 1000
@ -113,10 +115,13 @@ function GoldPigData:addGoldPigCount()
end
if self.data.count >= info.max_diamond then -- 已经满了
self.lastCount = self.data.count
self.lastGoldCount = self.data.goldCount
return
end
self.lastCount = self.data.count
self.lastGoldCount = self.data.goldCount
self.data.count = self.data.count + info.battle_diamond
self.data.goldCount = self.data.goldCount + info.battle_gold
if self.data.count >= info.max_diamond then -- 满了
self.data.count = info.max_diamond
self.data.fullTime = Time:getServerTime()
@ -146,6 +151,10 @@ function GoldPigData:getCount()
return self.data.count
end
function GoldPigData:getGoldCount()
return self.data.goldCount
end
function GoldPigData:getIsFull()
return self.data.count >= self.maxCount
end
@ -220,7 +229,9 @@ function GoldPigData:levelDown()
local currLevelInfo = self:getCurrLevelInfo()
self.data.count = currLevelInfo.min_diamond
self.data.goldCount = currLevelInfo.min_gold
self.lastCount = self.data.count
self.lastGoldCount = self.data.goldCount
self.maxCount = self:getMaxCount()
self.popFlag = false
end