miduo_client/Assets/ManagedResources/~Lua/Modules/Map/BuffOptionPanel.lua

136 lines
5.2 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require("Base/BasePanel")
local BuffOptionPanel = Inherit(BasePanel)
local this = BuffOptionPanel
local _BuffItemList = {}
local _TargetStr = {
[1] = Language[10536],
[2] = Language[11216],
[3] = Language[10372],
}
--初始化组件(用于子类重写)
function BuffOptionPanel:InitComponent()
this.spLoader = SpriteLoader.New()
this.levelPanel = Util.GetGameObject(self.gameObject, "level")
this.buffPanel = Util.GetGameObject(self.gameObject, "buff")
this.buffGrid = Util.GetGameObject(self.gameObject, "buff/grid")
this.buffItem = Util.GetGameObject(self.gameObject, "buff/btnBuffInfo")
this.buffCancel = Util.GetGameObject(self.gameObject, "buff/Cancel")
this.buffCancelText = Util.GetGameObject(self.gameObject, "buff/Cancel/Text")
this.buffCancelTip = Util.GetGameObject(self.gameObject, "buff/Cancel/tip")
-- 上部货币显示
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.transform, { showType = UpViewOpenType.ShowLeft})
end
--绑定事件(用于子类重写)
function BuffOptionPanel:BindEvent()
-- 执行最后一个option策划配置最后一个事件点为保存buff
Util.AddClick(this.buffCancel, function()
local optionList = ConfigManager.GetConfigData(ConfigName.EventPointConfig, this.eventId).Option
OptionBehaviourManager.JumpEventPoint(this.eventId, optionList[#optionList], this)
this:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function BuffOptionPanel:AddListener()
end
--移除事件监听(用于子类重写)
function BuffOptionPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function BuffOptionPanel:OnOpen(eventId)
this.eventId = eventId
this.levelPanel:SetActive(false)
this.buffPanel:SetActive(true)
this.buffCancelTip:SetActive(true)
this.buffCancelText:GetComponent("Text").text = Language[11223]
-- 货币界面
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.TrialCoin})
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function BuffOptionPanel:OnShow()
this.ShowBuffPanel()
end
-- 显示buff选择
function this.ShowBuffPanel()
this.levelPanel:SetActive(false)
this.buffPanel:SetActive(true)
-- 遍历关闭显示
for _, item in ipairs(_BuffItemList) do
item:SetActive(false)
end
-- 判断是否有保存的补给点
local optionList = ConfigManager.GetConfigData(ConfigName.EventPointConfig, this.eventId).Option
for index = 1, #optionList - 1 do
local optionId = optionList[index]
-- 最后一个不显示
if index ~= #optionList then
if not _BuffItemList[index] then
_BuffItemList[index] = newObjToParent(this.buffItem, this.buffGrid)
end
this.BuffItemAdapter(_BuffItemList[index], optionId)
_BuffItemList[index]:SetActive(true)
end
end
end
--- buff节点数据匹配
function this.BuffItemAdapter(node, optionId)
local icon = Util.GetGameObject(node, "icon"):GetComponent("Image")
local content = Util.GetGameObject(node, "context"):GetComponent("Text")
local target = Util.GetGameObject(node, "target"):GetComponent("Text")
local step = Util.GetGameObject(node, "step"):GetComponent("Text")
local itemIcon = Util.GetGameObject(node, "itemIcon"):GetComponent("Image")
local itemNum = Util.GetGameObject(node, "itemNum"):GetComponent("Text")
local optionData = ConfigManager.GetConfigData(ConfigName.OptionConfig, optionId)
if not optionData.AddConditionID or optionData.AddConditionID == 0 then Log(Language[11219]) return end
local optionAddData = ConfigManager.GetConfigData(ConfigName.OptionAddCondition, optionData.AddConditionID)
local buffData = ConfigManager.GetConfigData(ConfigName.FoodsConfig, tonumber(optionAddData.Info))
icon.sprite = this.spLoader:LoadSprite(buffData.EffectShowIcon)
content.text =GetLanguageStrById(optionData.Info)
target.text = _TargetStr[buffData.Target]
step.text = buffData.Contiue == 0 and Language[11220] or buffData.Contiue
local costId, costNum = optionAddData.Values[1][1], optionAddData.Values[1][2]
itemIcon.sprite = SetIcon(this.spLoader, costId)
itemNum.text = costNum
Util.AddOnceClick(node, function() local itemConfigData=ConfigManager.GetConfigData(ConfigName.ItemConfig, costId)
local tipStr = string.format(Language[11221], costNum, GetStringByEquipQua(itemConfigData.Quantity, GetLanguageStrById(itemConfigData.Name)), GetLanguageStrById(optionData.Info))
MsgPanel.ShowTwo(tipStr, nil, function()
-- 判断消耗
if not MapManager.ItemNumJudge(optionId) then
PopupTipPanel.ShowTip(Language[11222])
return
end
OptionBehaviourManager.JumpEventPoint(this.eventId, optionId, this)
this:ClosePanel()
end)
end)
end
--界面关闭时调用(用于子类重写)
function BuffOptionPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function BuffOptionPanel:OnDestroy()
this.spLoader:Destroy()
_BuffItemList = {}
SubUIManager.Close(this.UpView)
end
return BuffOptionPanel