2021-12-29 20:17:45 +08:00
|
|
|
|
----- --家园装备升级 -----
|
|
|
|
|
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)
|
2022-01-04 18:58:34 +08:00
|
|
|
|
local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
2021-12-29 20:17:45 +08:00
|
|
|
|
--传入父脚本模块
|
|
|
|
|
local parent
|
|
|
|
|
--传入特效层级
|
|
|
|
|
local sortingOrder=0
|
|
|
|
|
local data=nil
|
|
|
|
|
local TEXT = {
|
2022-01-06 11:45:28 +08:00
|
|
|
|
[1] = {"武器","r_Equip_GuardianWeapon_0004","攻击"},
|
|
|
|
|
[2] = {"战甲","r_Equip_Coat_0005","护甲"},
|
|
|
|
|
[3] = {"头饰","r_Equip_HeadAccessory_0005","魔抗"},
|
|
|
|
|
[4] = {"战靴","r_equip_Shoes_0005","生命"},
|
2021-12-29 20:17:45 +08:00
|
|
|
|
}
|
|
|
|
|
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")
|
2021-12-30 11:00:27 +08:00
|
|
|
|
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")
|
2021-12-29 20:17:45 +08:00
|
|
|
|
|
2022-01-05 18:04:57 +08:00
|
|
|
|
this.Cost = Util.GetGameObject(gameObject,"Cost")
|
|
|
|
|
this.Tips = Util.GetGameObject(gameObject,"Tips")
|
|
|
|
|
|
2021-12-29 20:17:45 +08:00
|
|
|
|
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
|
2022-01-04 18:58:34 +08:00
|
|
|
|
if BagManager.GetTotalItemNum(data.Cost[1][1]) < data.Cost[1][2] then
|
|
|
|
|
PopupTipPanel.ShowTip(string.format("%s不足!",ItemConfig[data.Cost[1][1]].Name))
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-12-29 20:17:45 +08:00
|
|
|
|
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()
|
2022-01-04 18:58:34 +08:00
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.SetData)
|
2021-12-29 20:17:45 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:RemoveListener()
|
2022-01-04 18:58:34 +08:00
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, this.SetData)
|
2021-12-29 20:17:45 +08:00
|
|
|
|
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
|
|
|
|
|
|
2021-12-30 11:00:27 +08:00
|
|
|
|
--显示加持属性
|
2021-12-29 20:17:45 +08:00
|
|
|
|
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
|
2022-01-06 11:45:28 +08:00
|
|
|
|
this.Desc.text = string.format("神将佩戴的%s%s属性增加%s",TEXT[curIndex][1],TEXT[curIndex][3],num1).."%"..string.format("<color=#00FF00>(%s",num2).."%)</color>"
|
2021-12-30 11:00:27 +08:00
|
|
|
|
|
|
|
|
|
--设置消耗
|
|
|
|
|
local limit = EquipStrengthen[HomeLandManager.EquipData[curIndex].Id].Limit
|
|
|
|
|
local cost = EquipStrengthen[HomeLandManager.EquipData[curIndex].Id].Cost
|
2022-01-05 18:04:57 +08:00
|
|
|
|
-- local color1 = HomeLandManager.BuildData[limit[1]].level >= limit[2] and "#FFEED6" or "red"
|
|
|
|
|
-- this.costCondition.text = string.format("<color=%s>%s到达%s级</color>",color1,HomeLand[limit[1]].Name,limit[2])
|
|
|
|
|
this.costCondition.text = HomeLandManager.BuildData[limit[1]].level >= limit[2] and "" or string.format("<color=red>%s到达%s级</color>",HomeLand[limit[1]].Name,limit[2])
|
2021-12-30 11:00:27 +08:00
|
|
|
|
this.costIcon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(cost[1][1]))
|
2022-01-05 18:04:57 +08:00
|
|
|
|
local color2 = BagManager.GetTotalItemNum(cost[1][1]) >= cost[1][2] and "#FFEED6" or "red"
|
2021-12-30 11:00:27 +08:00
|
|
|
|
this.costNum.text = string.format("<color=%s>%s</color>",color2,cost[1][2])
|
2022-01-05 18:04:57 +08:00
|
|
|
|
|
|
|
|
|
--按钮和tips显示
|
|
|
|
|
|
|
|
|
|
local bool = HomeLandManager.GetCurIndexBtnsShow()
|
|
|
|
|
-- LogBlue("bool:"..tostring(bool))
|
|
|
|
|
this.Btn1:SetActive(bool)
|
|
|
|
|
this.Btn2:SetActive(not bool)
|
|
|
|
|
--不同显示
|
|
|
|
|
this.Cost:SetActive(bool)
|
|
|
|
|
this.Tips:SetActive(not bool)
|
2022-01-06 11:53:37 +08:00
|
|
|
|
this.costCondition.gameObject:SetActive(true)
|
2022-01-05 18:16:10 +08:00
|
|
|
|
this.Tips:GetComponent("Text").text = string.format("全部加持到达%s级后方可进行突破",EquipStrengthen[HomeLandManager.EquipData[curIndex].Id].Level)
|
2022-01-05 18:04:57 +08:00
|
|
|
|
if not bool and HomeLandManager.GetAllCanUpgrade() then
|
2022-01-06 11:53:37 +08:00
|
|
|
|
this.Cost:SetActive(true)
|
2022-01-06 11:45:28 +08:00
|
|
|
|
this.Tips:SetActive(false)
|
2022-01-06 11:53:37 +08:00
|
|
|
|
this.costCondition.gameObject:SetActive(false)
|
2022-01-06 14:23:41 +08:00
|
|
|
|
--突破的消耗和升级不同
|
|
|
|
|
local cost = EquipRankUp[HomeLandManager.levelProId].Cost
|
|
|
|
|
local color2 = BagManager.GetTotalItemNum(cost[1]) >= cost[2] and "#FFEED6" or "red"
|
|
|
|
|
this.costNum.text = string.format("<color=%s>%s</color>",color2,cost[2])
|
2022-01-05 18:04:57 +08:00
|
|
|
|
end
|
2021-12-29 20:17:45 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnClose()
|
|
|
|
|
HomeLandManager.curEquip = 1
|
|
|
|
|
data=nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnDestroy()
|
|
|
|
|
this.SelectList = {}
|
|
|
|
|
this.spLoader:Destroy()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return this
|