miduo_client/Assets/ManagedResources/~Lua/Modules/BecomeAGod/BecomeAGodPropertyPanel.lua

239 lines
10 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 ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
BecomeAGodPropertyPanel = Inherit(BasePanel)
local this = BecomeAGodPropertyPanel
--初始化组件用于子类重写RoleEquipChangePopup
function BecomeAGodPropertyPanel:InitComponent()
this.secondScroll = Util.GetGameObject(self.transform, "secondScroll")
this.properItemPre = Util.GetGameObject(self.transform, "propertyPre")
this.propertyGrid = Util.GetGameObject(this.secondScroll, "grid")
this.properList = {}
this.properList[0] = {}
this.properList[0].go = this.properItemPre
this.properList[0].leftTxt = Util.GetGameObject(this.properItemPre, "leftTxt"):GetComponent("Text")
this.properList[0].rightTxt = Util.GetGameObject(this.properItemPre, "rightTxt"):GetComponent("Text")
this.spLoader = SpriteLoader.New()
this.bg2 = Util.GetGameObject(self.transform, "bg2")
screenAdapte(this.bg2)
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft })
this.btnBack = Util.GetGameObject(self.transform, "btnBack/btnBack")
this.titleTxt = Util.GetGameObject(self.gameObject, "titleBG/title"):GetComponent("Text")
this.needs = Util.GetGameObject(self.transform, "Needs")
this.needPre = Util.GetGameObject(self.needs, "pre")
this.btnLvup = Util.GetGameObject(self.transform, "btns/Lvup")
this.red = Util.GetGameObject(self.transform, "btns/Lvup/red")
this.force = Util.GetGameObject(self.transform, "powerBtn/value"):GetComponent("Text")
--this.btn_help = Util.GetGameObject(self.gameObject, "btn_help")
this.itemList = {}
this.isMax = false
this.LvText = Util.GetGameObject(self.gameObject, "Lv"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function BecomeAGodPropertyPanel:BindEvent()
--Util.AddClick(this.btn_help, function()
--UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.Mingge, 0, 0)
--end)
Util.AddClick(this.btnBack, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
Util.AddClick(this.btnLvup, function()
if this.levelUpData.LvupCost then
for i = 1, #this.levelUpData.LvupCost do
local data = this.levelUpData.LvupCost[i]
if BagManager.GetTotalItemNum(data[1]) < data[2] then
PopupTipPanel.ShowTip(string.format(Language[10320], GetLanguageStrById(ItemConfig[data[1]].Name)))
return true
end
end
LogError("升级类型:" .. this.index)
NetManager.PlayerMeridiansLevelUpRequest(this.index, function(msg)
PopupTipPanel.ShowTip(string.format("升级成功!"))
this.teamHero = FormationManager.GetAllMainFormationHeroId()
this.RefreshWindowData()
this.RefreshProperty()
end)
end
end)
end
function this.ChangePowerValue()
local WarPower = 0
for k, v in pairs(this.teamHero) do
WarPower = WarPower + HeroPowerManager.GetHeroPower(k, FormationTypeDef.FORMATION_NORMAL)
end
WarPower = WarPower + PracticeManager.GetPracticeAddPower()
this.force.text = WarPower
end
--添加事件监听(用于子类重写)
function BecomeAGodPropertyPanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.RefreshWindowData)
Game.GlobalEvent:AddEvent(GameEvent.Formation.OnFormationPowerChange, this.ChangePowerValue)
end
--移除事件监听(用于子类重写)
function BecomeAGodPropertyPanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, this.RefreshWindowData)
Game.GlobalEvent:RemoveEvent(GameEvent.Formation.OnFormationPowerChange, this.ChangePowerValue)
end
--界面打开时调用(用于子类重写)
function BecomeAGodPropertyPanel:OnOpen(...)
local data = { ... }
this.index = tonumber(data[1])
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.BecomeAGod })
end
function BecomeAGodPropertyPanel:OnShow()
this.teamHero = FormationManager.GetAllMainFormationHeroId()
this.RefreshWindowData()
this.RefreshProperty()
end
function this.RefreshProperty()
local level = BecomeAGodManager.GetPlayerMeridiansLevel(this.index)
local propertyShow, _isMax = BecomeAGodManager.GetPropText(level, this.index)
this.isMax = _isMax
this:SetPropertyShow(propertyShow)
if this.levelUpData.LvupCost then
local couldUplv = true
for i = 1, #this.levelUpData.LvupCost do
local data = this.levelUpData.LvupCost[i]
if BagManager.GetTotalItemNum(data[1]) < data[2] then
couldUplv = false
end
end
this.red.gameObject:SetActive(couldUplv)
end
end
--设置属性的显示
function BecomeAGodPropertyPanel:SetPropertyShow(_infos)
--local index = 1
this.properList[0].go.gameObject:SetActive(true)
for i = 1, #this.properList do
this.properList[i].go.gameObject:SetActive(false)
end
local floor = GodsWayTowerManager.GetTowerFloorByType(3)
for index = 1, #_infos do
--for key, value in pairs(_infos) do
if not this.properList[index] then
this.properList[index] = {}
this.properList[index].go = newObjToParent(this.properItemPre, this.propertyGrid)
this.properList[index].Lock = Util.GetGameObject(this.properList[index].go, "Lock")
this.properList[index].LockText = Util.GetGameObject(this.properList[index].go, "Lock/Text"):GetComponent(
"Text")
this.properList[index].leftTxt = Util.GetGameObject(this.properList[index].go, "leftTxt"):GetComponent(
"Text")
this.properList[index].rightTxt = Util.GetGameObject(this.properList[index].go, "rightTxt"):GetComponent(
"Text")
end
this.properList[index].go.gameObject:SetActive(true)
if _infos[index].propId == 10000 then
this.properList[index].leftTxt.text = string.format("%s+%s", "神兽属性",
(_infos[index]
.currValue / 100) .. "%")
this.properList[index].rightTxt.text = this.isMax and Language[10209] or (_infos[index].nextValue / 100) ..
"%"
elseif _infos[index].propId == 20000 then
this.properList[index].leftTxt.text = string.format("%s+%s", "身外化身属性",
(_infos[index]
.currValue / 100) .. "%")
this.properList[index].rightTxt.text = this.isMax and Language[10209] or (_infos[index].nextValue / 100) ..
"%"
elseif _infos[index].propId == 30000 then
this.properList[index].leftTxt.text = string.format("%s+%s", "神器属性",
(_infos[index]
.currValue / 100) .. "%")
this.properList[index].rightTxt.text = this.isMax and Language[10209] or (_infos[index].nextValue / 100) ..
"%"
else
local proper = ConfigManager.GetConfigData(ConfigName.PropertyConfig, _infos[index].propId)
if proper.Style == 1 then
this.properList[index].leftTxt.text = string.format("%s+%s", GetLanguageStrById(proper.Info),
_infos[index]
.currValue)
this.properList[index].rightTxt.text = this.isMax and Language[10209] or _infos[index].nextValue
else
this.properList[index].leftTxt.text = GetLanguageStrById(proper.Info) ..
"+" .. _infos[index].currValue / 100 .. "%"
this.properList[index].rightTxt.text = this.isMax and Language[10209] or
_infos[index].nextValue / 100 .. "%"
end
end
if floor >= _infos[index].floor then
this.properList[index].Lock:SetActive(false)
this.properList[index].leftTxt.color = UIColor.WRITE
this.properList[index].rightTxt.color = UIColor.GREEN
else
this.properList[index].Lock:SetActive(true)
this.properList[index].LockText.text = "(神塔" .. _infos[index].floor .. "层解锁)"
this.properList[index].leftTxt.color = Color.New(0.72, 0.72, 0.72, 1)
this.properList[index].rightTxt.color = Color.New(0.72, 0.72, 0.72, 1)
end
end
LayoutRebuilder.ForceRebuildLayoutImmediate(this.secondScroll.transform)
end
function this:OnSortingOrderChange()
end
--右切换按钮点击
function this:RightBtnOnClick()
end
--左切换按钮点击
function this:LeftBtnOnClick()
end
function this.RefreshWindowData()
this.ChangePowerValue()
local level = BecomeAGodManager.GetPlayerMeridiansLevel(this.index)
this.LvText.text = "等级" .. level
local setting = ConfigManager.TryGetConfigDataByKey(ConfigName.BecomeAGodSetting, "Type", this.index)
this.titleTxt.text = setting.Name
this.levelUpData = ConfigManager.TryGetConfigDataByKey(ConfigName.BecomeAGodMaterialGit, "Level", level)
LogError("类型:" .. this.index .. "等级:" .. level)
if not this.itemList then
this.itemList = {}
end
for k, v in ipairs(this.itemList) do
v.gameObject:SetActive(false)
end
for i = 1, # this.levelUpData.LvupCost do
local data = this.levelUpData.LvupCost[i]
if not this.itemList[i] then
this.itemList[i] = newObject(this.needPre)
this.itemList[i].transform:SetParent(this.needs.transform)
this.itemList[i].transform.localScale = Vector3.one
this.itemList[i].transform.localPosition = Vector3.zero
end
local icon = Util.GetGameObject(this.itemList[i], "icon"):GetComponent("Image")
local num = Util.GetGameObject(this.itemList[i], "num"):GetComponent("Text")
icon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(data[1]))
num.text = data[2]
if BagManager.GetTotalItemNum(data[1]) < data[2] then
num.text = string.format("<color=red>%s</color>", data[2])
end
this.itemList[i]:SetActive(true)
end
end
--界面关闭时调用(用于子类重写)
function BecomeAGodPropertyPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function BecomeAGodPropertyPanel:OnDestroy()
end
return BecomeAGodPropertyPanel