84 lines
3.1 KiB
Lua
84 lines
3.1 KiB
Lua
require("Base/BasePanel")
|
|
SheShiUpLevel = Inherit(BasePanel)
|
|
local this = SheShiUpLevel
|
|
local BaseAttachmentConfig = ConfigManager.GetConfig(ConfigName.BaseAttachmentConfig)
|
|
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
|
local item = nil
|
|
local selectType
|
|
local selectLv
|
|
function SheShiUpLevel:InitComponent()
|
|
this.mask = Util.GetGameObject(this.gameObject, "mask")
|
|
this.btnBack = Util.GetGameObject(this.gameObject, "btnBack")
|
|
this.btnUpLv = Util.GetGameObject(this.gameObject, "btnUpLv")
|
|
this.items = Util.GetGameObject(this.gameObject, "items")
|
|
this.tip = Util.GetGameObject(this.gameObject, "tip"):GetComponent("Text")
|
|
end
|
|
function SheShiUpLevel:BindEvent()
|
|
Util.AddClick(this.mask, function()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.btnBack, function()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.btnUpLv, function()
|
|
local lv = EnergyBaseManager.GetBuildLv(selectType)
|
|
local cur, next = EnergyBaseManager.GetBuildInfo(selectType, lv)
|
|
local baseInfo = EnergyBaseManager.GetBaseInfo()
|
|
if baseInfo.baseLevel < cur.BaseLimit then
|
|
PopupTipPanel.ShowTip(GetLanguageStrById(50471))
|
|
return
|
|
end
|
|
if BagManager.GetItemCountById(cur.Cost[1]) < cur.Cost[2] then
|
|
PopupTipPanel.ShowTip(GetLanguageStrById(50472))
|
|
return
|
|
end
|
|
EnergyBaseManager.BaseLevelUp(selectType, function ()
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Energy.BaseOrFacilityUpLv)
|
|
lv = EnergyBaseManager.GetBuildLv(selectType)
|
|
cur, next = EnergyBaseManager.GetBuildInfo(selectType, lv)
|
|
if not next then
|
|
self:ClosePanel()
|
|
else
|
|
self:OnOpen(selectType)
|
|
end
|
|
end)
|
|
end)
|
|
end
|
|
|
|
function SheShiUpLevel:AddListener()
|
|
end
|
|
|
|
function SheShiUpLevel:RemoveListener()
|
|
end
|
|
|
|
function SheShiUpLevel:OnOpen(type)
|
|
selectType = type
|
|
local lv = EnergyBaseManager.GetBuildLv(type)
|
|
local cur, next = EnergyBaseManager.GetBuildInfo(type, lv)
|
|
-- local curConfig = BaseAttachmentConfig[cur.Id]
|
|
if not item then
|
|
item = SubUIManager.Open(SubUIConfig.ItemView, this.items.transform)
|
|
end
|
|
item:OnOpen(false, {cur.Cost[1], cur.Cost[2]}, 0.6)
|
|
item:CompareNum(BagManager.GetItemCountById(cur.Cost[1]), cur.Cost[2])
|
|
this.tip.text = GetLanguageStrById(50470)..cur.BaseLimit
|
|
for i = 1, 2 do
|
|
local data
|
|
if i == 1 then data = cur else data = next end
|
|
Util.GetGameObject(this.gameObject, "build"..i):GetComponent("Image").sprite = Util.LoadSprite(EnergyBaseManager.buildIcon[type])
|
|
Util.GetGameObject(this.gameObject, "build"..i.."/name"):GetComponent("Text").text = GetLanguageStrById(data.Name)
|
|
Util.GetGameObject(this.gameObject, "build"..i.."/value"):GetComponent("Text").text = GetLanguageStrById(propertyConfig[data.PropertyAdd[1][1]].Info).."+"..GetPropertyFormatStr(propertyConfig[data.PropertyAdd[1][1]].Style, data.PropertyAdd[1][2])
|
|
end
|
|
end
|
|
|
|
function SheShiUpLevel:OnShow()
|
|
end
|
|
|
|
function SheShiUpLevel:OnClose()
|
|
end
|
|
|
|
function SheShiUpLevel:OnDestroy()
|
|
item = nil
|
|
end
|
|
|
|
return this |