miduo_client/Assets/ManagedResources/~Lua/Modules/Incarnation/IncarnationForcePanel.lua

140 lines
5.5 KiB
Lua
Raw Normal View History

2024-08-29 21:36:51 +08:00
require("Base/BasePanel")
2022-04-22 18:24:33 +08:00
local IncarnationForcePanel = Inherit(BasePanel)
local this = IncarnationForcePanel
2022-04-22 18:24:33 +08:00
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
function IncarnationForcePanel:InitComponent()
self.spLoader = SpriteLoader.New()
self.mask = Util.GetGameObject(self.gameObject, "Mask")
self.backBtn = Util.GetGameObject(self.gameObject, "Frame/backBtn")
self.helpBtn = Util.GetGameObject(self.gameObject, "Frame/helpBtn")
self.grid = Util.GetGameObject(self.gameObject, "Frame/Grid")
self.textPre = Util.GetGameObject(self.grid, "TextPre")
2022-04-22 18:24:33 +08:00
self.textPre:SetActive(false)
self.Tips = Util.GetGameObject(self.gameObject, "Frame/Tips"):GetComponent("Text")
self.title = Util.GetGameObject(self.gameObject, "Frame/Bg/title/Text"):GetComponent("Text")
2022-04-22 18:24:33 +08:00
self.Slide = Util.GetGameObject(self.gameObject, "Frame/Slide")
self.level = Util.GetGameObject(self.Slide, "level"):GetComponent("Text")
self.power = Util.GetGameObject(self.Slide, "powerBtn/value"):GetComponent("Text")
self.value = Util.GetGameObject(self.Slide, "Text"):GetComponent("Text")
self.fill = Util.GetGameObject(self.Slide, "fill")
self.upGradeBtn = Util.GetGameObject(self.Slide, "Button")
self.btnText = Util.GetGameObject(self.upGradeBtn, "Text"):GetComponent("Text")
self.btnRed = Util.GetGameObject(self.upGradeBtn, "RedPoint")
2022-04-22 18:24:33 +08:00
self.textPreList = {}
end
function IncarnationForcePanel:BindEvent()
--帮助按钮
Util.AddOnceClick(self.helpBtn, function()
UIManager.OpenPanel(UIName.GeneralInfoPopup, GENERALINFO_TYPE.Cultivation)
end)
Util.AddOnceClick(self.mask, function()
self:ClosePanel()
end)
Util.AddOnceClick(self.backBtn, function()
self:ClosePanel()
end)
Util.AddOnceClick(self.upGradeBtn, function()
if this.configData.Level >= 50 then
2024-08-29 21:36:51 +08:00
PopupTipPanel.ShowTip(Language[11210])
2022-04-22 18:24:33 +08:00
return
end
local curHaveItemNum = BagManager.GetItemCountById(this.configData.ExpCost[1])
local curCostItemNum = this.configData.ExpCost[2]
if curHaveItemNum < curCostItemNum then
2024-08-29 21:36:51 +08:00
PopupTipPanel.ShowTip(Language[11614])
2022-04-22 18:24:33 +08:00
return
end
NetManager.SendTransformationForceUpRequest(IncarnationManager.incarnationForceLv, function()
2022-04-22 18:24:33 +08:00
self:OnShow()
2022-04-25 14:42:17 +08:00
CheckRedPointStatus(RedPointType.incarnation_force)
2022-04-22 18:24:33 +08:00
end)
end)
BindRedPointObject(RedPointType.Practice_Cultivation, self.btnRed)
2022-04-22 18:24:33 +08:00
end
function IncarnationForcePanel:AddListener()
end
function IncarnationForcePanel:RemoveListener()
end
function IncarnationForcePanel:OnSortingOrderChange()
end
function IncarnationForcePanel:OnOpen()
end
function IncarnationForcePanel:OnShow()
this.configData = ConfigManager.GetConfigData(ConfigName.ChangingForce, IncarnationManager.incarnationForceLv)
this.nextConfigData = nil
if this.configData.Level < 50 then
this.nextConfigData = ConfigManager.GetConfigData(ConfigName.ChangingForce,
IncarnationManager.incarnationForceLv + 1)
2022-04-24 16:50:24 +08:00
end
2022-04-22 18:24:33 +08:00
--设置四个属性
2022-04-24 16:50:24 +08:00
for i = 1, #this.configData.PropList do
2022-04-22 18:24:33 +08:00
local go = self.textPreList[i]
if not go then
go = newObjToParent(self.textPre, self.grid)
2022-04-22 18:24:33 +08:00
go:SetActive(true)
self.textPreList[i] = go
end
self:SetSingleData(go, this.configData.PropList[i], i)
2022-04-22 18:24:33 +08:00
end
--设置等级
self.level.text = string.format(Language[11615], this.configData.Level)
2022-04-24 16:50:24 +08:00
self.power.text = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
this.btnRed.gameObject:SetActive(false)
if this.configData.Level < 50 then
local curHaveItemNum = BagManager.GetItemCountById(this.configData.ExpCost[1])
local curCostItemNum = this.configData.ExpCost[2]
self.value.text = string.format("%s/%s", curHaveItemNum, curCostItemNum)
if curHaveItemNum > curCostItemNum then
self.fill:GetComponent("RectTransform").sizeDelta = Vector3.New(445, 26, 0)
2022-04-24 16:50:24 +08:00
this.btnRed.gameObject:SetActive(true)
2022-04-22 18:24:33 +08:00
else
local size = curHaveItemNum / curCostItemNum
self.fill:GetComponent("RectTransform").sizeDelta = Vector3.New(445 * size, 26, 0)
2022-04-22 18:24:33 +08:00
end
2024-08-29 21:36:51 +08:00
self.btnText.text = Language[11616]
2022-04-22 18:24:33 +08:00
else
self.value.text = string.format("")
self.fill:GetComponent("RectTransform").sizeDelta = Vector3.New(445, 26, 0)
2024-08-29 21:36:51 +08:00
self.btnText.text = Language[10209]
self.btnText.fontSize = 35
2022-04-22 18:24:33 +08:00
end
end
--设置单个数据
function IncarnationForcePanel:SetSingleData(_go, data, _index)
local proName = Util.GetGameObject(_go, "PropertyName"):GetComponent("Text")
local Calculate = Util.GetGameObject(_go, "Calculate"):GetComponent("Text")
2022-04-22 18:24:33 +08:00
2022-04-24 16:50:24 +08:00
if IncarnationManager.incarnationForceLv == 0 then
proName.text = string.format("%s+0%%", propertyConfig[data[1]].Info)
2022-04-22 18:24:33 +08:00
else
proName.text = string.format("%s+%s%%", propertyConfig[data[1]].Info, data[2] / 100)
2022-04-24 16:50:24 +08:00
end
if this.nextConfigData then
local addProp = this.nextConfigData.PropList[_index][2] - data[2]
Calculate.text = string.format("(+%s%%)", addProp / 100)
2022-04-24 16:50:24 +08:00
Calculate.gameObject:SetActive(true)
else
Calculate.gameObject:SetActive(false)
2022-04-22 18:24:33 +08:00
end
end
function IncarnationForcePanel:OnClose()
Game.GlobalEvent:DispatchEvent(GameEvent.CommonEvent.RefreshIncarnationPanelUp)
2022-04-22 18:24:33 +08:00
end
function IncarnationForcePanel:OnDestroy()
self.spLoader:Destroy()
self.textPreList = {}
end
return IncarnationForcePanel