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

139 lines
5.4 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 IncarnationForcePanel = Inherit(BasePanel)
local this=IncarnationForcePanel
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")
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")
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")
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
PopupTipPanel.ShowTip("等级已达上限")
return
end
local curHaveItemNum=BagManager.GetItemCountById(this.configData.ExpCost[1])
local curCostItemNum=this.configData.ExpCost[2]
if curHaveItemNum <curCostItemNum then
PopupTipPanel.ShowTip("化身之力不足,无法升级")
return
end
NetManager.SendTransformationForceUpRequest(IncarnationManager.incarnationForceLv,function ()
self:OnShow()
CheckRedPointStatus(RedPointType.incarnation_force)
end)
end)
BindRedPointObject(RedPointType.Practice_Cultivation,self.btnRed)
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)
end
--设置四个属性
for i = 1, #this.configData.PropList do
local go = self.textPreList[i]
if not go then
go = newObjToParent(self.textPre,self.grid)
go:SetActive(true)
self.textPreList[i] = go
end
self:SetSingleData(go,this.configData.PropList[i],i)
end
--设置等级
self.level.text = string.format("化身等级:%s级",this.configData.Level)
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)
this.btnRed.gameObject:SetActive(true)
else
local size = curHaveItemNum/curCostItemNum
self.fill:GetComponent("RectTransform").sizeDelta = Vector3.New(445*size,26,0)
end
self.btnText.text = "升 级"
else
self.value.text = string.format("")
self.fill:GetComponent("RectTransform").sizeDelta = Vector3.New(445,26,0)
self.btnText.text = "已达上限"
self.btnText.fontSize=35
end
end
--设置单个数据
function IncarnationForcePanel:SetSingleData(_go,data,_index)
local proName = Util.GetGameObject(_go,"PropertyName"):GetComponent("Text")
local Calculate = Util.GetGameObject(_go,"Calculate"):GetComponent("Text")
if IncarnationManager.incarnationForceLv == 0 then
proName.text = string.format("%s+0%%",propertyConfig[data[1]].Info)
else
proName.text = string.format("%s+%s%%",propertyConfig[data[1]].Info,data[2]/100)
end
if this.nextConfigData then
local addProp=this.nextConfigData.PropList[_index][2]-data[2]
Calculate.text=string.format("(+%s%%)",addProp/100)
Calculate.gameObject:SetActive(true)
else
Calculate.gameObject:SetActive(false)
end
end
function IncarnationForcePanel:OnClose()
Game.GlobalEvent:DispatchEvent(GameEvent.CommonEvent.RefreshIncarnationPanelUp)
end
function IncarnationForcePanel:OnDestroy()
self.spLoader:Destroy()
self.textPreList = {}
end
return IncarnationForcePanel