miduo_client/Assets/ManagedResources/~Lua/Modules/ArenaTopMatch/DoGuessPopup.lua

107 lines
4.3 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
local DoGuessPopup = Inherit(BasePanel)
local this = DoGuessPopup
2020-07-10 13:38:50 +08:00
local GUESS_COIN = ArenaTopMatchManager.GetGuessCoinID()
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function DoGuessPopup:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
this.btnBack = Util.GetGameObject(this.transform, "tipImage/btnReturn")
this.btnConfirm = Util.GetGameObject(this.transform, "tipImage/btnConfirm")
this.itemBg = Util.GetGameObject(this.transform, "tipImage/item/bg"):GetComponent("Image")
this.itemIcon = Util.GetGameObject(this.transform, "tipImage/item/icon"):GetComponent("Image")
this.itemNum = Util.GetGameObject(this.transform, "tipImage/item/num"):GetComponent("Text")
this.itemName = Util.GetGameObject(this.transform, "tipImage/item/name"):GetComponent("Text")
this.slider = Util.GetGameObject(this.transform, "tipImage/Slider"):GetComponent("Slider")
this.sliderLeftBtn = Util.GetGameObject(this.transform, "tipImage/leftbtn")
this.sliderRightBtn = Util.GetGameObject(this.transform, "tipImage/rightbtn")
this.sliderCount = Util.GetGameObject(this.transform, "tipImage/count"):GetComponent("Text")
this.tips = Util.GetGameObject(this.transform, "tipImage/tips"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function DoGuessPopup:BindEvent()
Util.AddClick(this.btnBack, function()
this:ClosePanel()
end)
Util.AddClick(this.btnConfirm, function()
local betBattleInfo = ArenaTopMatchManager.GetBetBattleInfo()
local uid = this.panelType == 1 and betBattleInfo.myInfo.uid or betBattleInfo.enemyInfo.uid
local num = this.slider.value
ArenaTopMatchManager.RequestBet(uid, num, function()
2020-07-10 13:38:50 +08:00
ArenaTopMatchManager.SetcurIsShowDoGuessPopup(true)
2020-05-09 13:31:21 +08:00
this:ClosePanel()
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10108])
2020-07-22 19:40:23 +08:00
Log("<color=yellow>处于战斗时 存储的临时竞猜币数量 "..BagManager.GetItemCountById(GUESS_COIN).."</color>")
2020-07-10 13:38:50 +08:00
ArenaTopMatchManager.SetCoinNum(BagManager.GetItemCountById(GUESS_COIN))
2020-05-09 13:31:21 +08:00
end)
end)
Util.AddClick(this.sliderLeftBtn, function()
local curValue = this.slider.value
if curValue <= 0 then
return
end
this.slider.value = curValue - 1
end)
Util.AddClick(this.sliderRightBtn, function()
local curValue = this.slider.value
local guessCoinId = ArenaTopMatchManager.GetGuessCoinID()
local maxNum = BagManager.GetItemCountById(guessCoinId)
if curValue >= maxNum then
return
end
this.slider.value = curValue + 1
end)
end
--添加事件监听(用于子类重写)
function DoGuessPopup:AddListener()
end
--移除事件监听(用于子类重写)
function DoGuessPopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function DoGuessPopup:OnOpen(panelType)
this.panelType = panelType
local guessCoinId = ArenaTopMatchManager.GetGuessCoinID()
2021-04-21 13:12:04 +08:00
this.itemBg.sprite = SetFrame(this.spLoader, guessCoinId)
this.itemIcon.sprite = SetIcon(this.spLoader, guessCoinId)
2021-01-26 17:08:39 +08:00
this.itemName.text = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.ItemConfig, guessCoinId).Name)
2020-05-09 13:31:21 +08:00
local maxNum = BagManager.GetItemCountById(guessCoinId)
this.itemNum.text = maxNum
this.slider.minValue = 1
2020-05-09 13:31:21 +08:00
this.slider.maxValue = maxNum
this.slider.onValueChanged:AddListener(function()
this.sliderCount.text = this.slider.value
end)
this.slider.value = 0
this.sliderCount.text = 0
-- 赔率显示
2021-03-02 16:53:12 +08:00
local player = panelType == 1 and Language[10132] or Language[10133]
2020-05-09 13:31:21 +08:00
local betRateInfo = ArenaTopMatchManager.GetBetRateInfo()
local allCoin = betRateInfo.redCoins + betRateInfo.blueCoins
local redWinRate = allCoin/betRateInfo.redCoins
local blueWinRate = allCoin/betRateInfo.blueCoins
2020-07-03 16:09:15 +08:00
local rate = ArenaTopMatchManager.rate--panelType == 1 and blueWinRate or redWinRate
2021-03-02 16:53:12 +08:00
this.tips.text = string.format(Language[10134], player, rate)
2020-05-09 13:31:21 +08:00
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function DoGuessPopup:OnShow()
end
--界面关闭时调用(用于子类重写)
function DoGuessPopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function DoGuessPopup:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
end
2020-06-23 18:36:24 +08:00
return DoGuessPopup