miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/View/GeneralPopup_HomeLandEquip.lua

144 lines
5.5 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.

----- --家园装备升级 -----
local this = {}
local HomeLand = ConfigManager.GetConfig(ConfigName.HomeLand)
local HomeLandLevel = ConfigManager.GetConfig(ConfigName.HomeLandLevel)
local HomeLandTask = ConfigManager.GetConfig(ConfigName.HomeLandTask)
local EquipStrengthen = ConfigManager.GetConfig(ConfigName.EquipStrengthen)
local EquipRankUp = ConfigManager.GetConfig(ConfigName.EquipRankUp)
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local data=nil
local TEXT = {
[1] = {"武器","r_Equip_GuardianWeapon_0004"},
[2] = {"战甲","r_Equip_Coat_0005"},
[3] = {"头饰","r_Equip_HeadAccessory_0005"},
[4] = {"战靴","r_equip_Shoes_0005"},
}
function this:InitComponent(gameObject)
this.spLoader = SpriteLoader.New()
this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
this.titleText.text="摘星阁"
this.Btn1 = Util.GetGameObject(gameObject,"Btn1")
this.Btn2 = Util.GetGameObject(gameObject,"Btn2")
this.costCondition = Util.GetGameObject(gameObject,"Cost/Condition"):GetComponent("Text")
this.costIcon = Util.GetGameObject(gameObject,"Cost/Icon"):GetComponent("Image")
this.costNum = Util.GetGameObject(gameObject,"Cost/Num"):GetComponent("Text")
this.objList = {}
for i = 1, 4 do
this.objList[i] = {}
this.objList[i].Obj = Util.GetGameObject(gameObject,"Content/Grid/Pre ("..i..")")
this.objList[i].name = Util.GetGameObject(this.objList[i].Obj,"Name"):GetComponent("Text")
this.objList[i].level = Util.GetGameObject(this.objList[i].Obj,"Num"):GetComponent("Text")
this.objList[i].image = Util.GetGameObject(this.objList[i].Obj,"Icon"):GetComponent("Image")
this.objList[i].mask = Util.GetGameObject(this.objList[i].Obj,"Mask")
this.objList[i].select = Util.GetGameObject(this.objList[i].Obj,"Select")
end
this.Desc = Util.GetGameObject(gameObject,"Content/Desc"):GetComponent("Text")
end
function this:BindEvent()
Util.AddClick(this.Btn1,function()
local data = HomeLandManager.EquipData[HomeLandManager.curEquip].configData
if HomeLandManager.BuildData[data.Limit[1]].level < data.Limit[2] then
PopupTipPanel.ShowTip(string.format("%s到达%s级可升级",HomeLandManager.BuildData[data.Limit[1]].dataMain.Name,data.Limit[2]))
return
end
NetManager.EquipIntensifyRequset(HomeLandManager.curEquip,function ()
this:Refresh()
end)
end)
Util.AddClick(this.Btn2,function()
if HomeLandManager.GetAllCanUpgradeWithPopup() then
this:Refresh()
return
end
NetManager.EquipIntensifyRequset(0,function ()
this:Refresh()
end)
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent,_args)
data = _args
parent=_parent
sortingOrder =_parent.sortingOrder
HomeLandManager.GetCurIndex()
this:Refresh()
end
function this:Refresh()
for i = 1, 4 do
local go = this.objList[i]
go.select:SetActive(i == HomeLandManager.curEquip)
go.name.text = TEXT[i][1].."加持"
go.level.text = HomeLandManager.EquipData[i].configData.Level
go.image.sprite = this.spLoader:LoadSprite(TEXT[i][2])
Util.AddOnceClick(go.mask,function ()
HomeLandManager.curEquip = i
this:Refresh()
end)
end
local bool = HomeLandManager.GetCurIndexBtnsShow()
-- LogBlue("bool:"..tostring(bool))
this.Btn1:SetActive(bool)
this.Btn2:SetActive(not bool)
--显示加持属性
this:SetData()
end
function this:SetData()
-- LogPink(HomeLandManager.EquipData[HomeLandManager.curEquip].Id)
local curIndex = HomeLandManager.curEquip
local data = EquipStrengthen[HomeLandManager.EquipData[curIndex].Id].Rate--当前装备加成
local proData = EquipRankUp[HomeLandManager.levelProId].Rate--当前装备突破加成
local nextData = EquipStrengthen[HomeLandManager.EquipData[curIndex].Id + 1].Rate--下一装备加成
local nextProData = EquipRankUp[HomeLandManager.levelProId + 1].Rate--下一装备突破加成
local num1 = data + proData[curIndex]
-- LogYellow(tostring(data).." @ "..tostring(proData[curIndex]))
local num2 = 0
if HomeLandManager.GetAllCanUpgrade() then--如果都到达了等级上限
num2 = data + nextProData[curIndex]
-- LogYellow(tostring(data).." $ "..tostring(nextProData[curIndex]))
else
num2 = nextData + proData[curIndex]
-- LogYellow(tostring(nextData).." # "..tostring(proData[curIndex]))
end
this.Desc.text = string.format("神将佩戴的%s基础属性增加%s",TEXT[curIndex][1],num1).."%"..string.format("<color=#00FF00>%s",num2).."%</color>"
--设置消耗
local limit = EquipStrengthen[HomeLandManager.EquipData[curIndex].Id].Limit
local cost = EquipStrengthen[HomeLandManager.EquipData[curIndex].Id].Cost
local color1 = HomeLandManager.BuildData[limit[1]].level >= limit[2] and "#FFFFFF" or "red"
this.costCondition.text = string.format("<color=%s>%s到达%s级</color>",color1,HomeLand[limit[1]].Name,limit[2])
this.costIcon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(cost[1][1]))
local color2 = BagManager.GetTotalItemNum(cost[1][1]) >= cost[1][2] and "#FFFFFF" or "red"
this.costNum.text = string.format("<color=%s>%s</color>",color2,cost[1][2])
end
function this:OnClose()
HomeLandManager.curEquip = 1
data=nil
end
function this:OnDestroy()
this.SelectList = {}
this.spLoader:Destroy()
end
return this