【命格】提交
parent
98308fe892
commit
bf46f1a6f6
|
@ -121,10 +121,10 @@ function BagPanel:BindEvent()
|
||||||
end)
|
end)
|
||||||
Util.AddClick(this.oneKey, function()
|
Util.AddClick(this.oneKey, function()
|
||||||
local list,num = GemManager.OneKeyConpound()
|
local list,num = GemManager.OneKeyConpound()
|
||||||
LogGreen("====================金币:"..tostring(num).."=============")
|
-- LogGreen("====================金币:"..tostring(num).."=============")
|
||||||
for key, value in pairs(list) do
|
-- for key, value in pairs(list) do
|
||||||
LogPink("key:"..tostring(key).." Value:"..tostring(value))
|
-- LogPink("key:"..tostring(key).." Value:"..tostring(value))
|
||||||
end
|
-- end
|
||||||
if num <= 0 then
|
if num <= 0 then
|
||||||
PopupTipPanel.ShowTip("无可合成的命石或金币不足!")
|
PopupTipPanel.ShowTip("无可合成的命石或金币不足!")
|
||||||
return
|
return
|
||||||
|
|
|
@ -116,15 +116,13 @@ function this.OneKeyConpound()
|
||||||
local totalMoney = 0
|
local totalMoney = 0
|
||||||
local finalList = {}
|
local finalList = {}
|
||||||
local configMap = this.GetMapOfBagData()
|
local configMap = this.GetMapOfBagData()
|
||||||
|
local curMoney = BagManager.GetTotalItemNum(14)--当前金币数量
|
||||||
--1-8的外部循环
|
--1-8的外部循环
|
||||||
for i = 1, #configMap do
|
for i = 1, #configMap do
|
||||||
local bool,money = this.DoCircle1(finalList,configMap[i])
|
local money = this.DoCircle1(finalList,configMap[i],curMoney)
|
||||||
totalMoney = totalMoney + money
|
totalMoney = totalMoney + money
|
||||||
|
curMoney = curMoney - totalMoney
|
||||||
-- LogGreen("money:"..tostring(totalMoney))
|
-- LogGreen("money:"..tostring(totalMoney))
|
||||||
if not bool then
|
|
||||||
-- LogError("合成结束")
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
local tempList = {}
|
local tempList = {}
|
||||||
for key, value in pairs(finalList) do--存在数据为0的情况,剔除
|
for key, value in pairs(finalList) do--存在数据为0的情况,剔除
|
||||||
|
@ -136,7 +134,7 @@ function this.OneKeyConpound()
|
||||||
end
|
end
|
||||||
|
|
||||||
--一键合成循环
|
--一键合成循环
|
||||||
function this.DoCircle1(finalList,data)
|
function this.DoCircle1(finalList,data,money)
|
||||||
local totalMoney = 0
|
local totalMoney = 0
|
||||||
local lastGNum = 0--上一次合成出来的数量
|
local lastGNum = 0--上一次合成出来的数量
|
||||||
for i = 1, #data do
|
for i = 1, #data do
|
||||||
|
@ -169,7 +167,7 @@ function this.DoCircle1(finalList,data)
|
||||||
end
|
end
|
||||||
if curGemNum > 0 then
|
if curGemNum > 0 then
|
||||||
local needMoneyNum = curGemNum/tempData.UpgradeNum * tempData.UpgradeCost[2]--按照命石可合成的数量,要花费的金币
|
local needMoneyNum = curGemNum/tempData.UpgradeNum * tempData.UpgradeCost[2]--按照命石可合成的数量,要花费的金币
|
||||||
local curMoneyNum = BagManager.GetTotalItemNum(tempData.UpgradeCost[1])--当前金币数量
|
local curMoneyNum = money--BagManager.GetTotalItemNum(tempData.UpgradeCost[1])--当前金币数量
|
||||||
-- LogYellow("needMoneyNum:"..tostring(needMoneyNum).." totalMoney:"..tostring(totalMoney))
|
-- LogYellow("needMoneyNum:"..tostring(needMoneyNum).." totalMoney:"..tostring(totalMoney))
|
||||||
if needMoneyNum + totalMoney > curMoneyNum then--如果当前金币不足要花费的数量,计算可以合成几个
|
if needMoneyNum + totalMoney > curMoneyNum then--如果当前金币不足要花费的数量,计算可以合成几个
|
||||||
local upNum = math.floor((curMoneyNum - totalMoney)/tempData.UpgradeCost[2])--实际真的合成了几个
|
local upNum = math.floor((curMoneyNum - totalMoney)/tempData.UpgradeCost[2])--实际真的合成了几个
|
||||||
|
@ -182,7 +180,7 @@ function this.DoCircle1(finalList,data)
|
||||||
finalList[tempData.NextGem] = upNum
|
finalList[tempData.NextGem] = upNum
|
||||||
-- LogPurple("3:ID:"..tostring(tempData.NextGem).." num:"..tostring(upNum))
|
-- LogPurple("3:ID:"..tostring(tempData.NextGem).." num:"..tostring(upNum))
|
||||||
-- LogRed("Bool:"..tostring(false).." totalMoney:"..tostring(totalMoney))
|
-- LogRed("Bool:"..tostring(false).." totalMoney:"..tostring(totalMoney))
|
||||||
return false,totalMoney
|
return totalMoney
|
||||||
else--如果金币足额
|
else--如果金币足额
|
||||||
totalMoney = totalMoney + needMoneyNum--金币计入总数
|
totalMoney = totalMoney + needMoneyNum--金币计入总数
|
||||||
if remainNum > 0 then
|
if remainNum > 0 then
|
||||||
|
@ -199,7 +197,7 @@ function this.DoCircle1(finalList,data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- LogRed("Bool:"..tostring(true).." totalMoney:"..tostring(totalMoney))
|
-- LogRed("Bool:"..tostring(true).." totalMoney:"..tostring(totalMoney))
|
||||||
return true,totalMoney
|
return totalMoney
|
||||||
end
|
end
|
||||||
|
|
||||||
--=========================快速合成================================
|
--=========================快速合成================================
|
||||||
|
|
Loading…
Reference in New Issue