2024-08-29 21:36:51 +08:00
|
|
|
|
require("Base/BasePanel")
|
2022-09-01 17:30:15 +08:00
|
|
|
|
HomeLandEquipPopup = Inherit(BasePanel)
|
2021-12-29 20:17:45 +08:00
|
|
|
|
----- --家园装备升级 -----
|
2022-09-01 17:30:15 +08:00
|
|
|
|
local this = HomeLandEquipPopup
|
2021-12-29 20:17:45 +08:00
|
|
|
|
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
|
|
|
|
|
|
--传入特效层级
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local sortingOrder = 0
|
|
|
|
|
|
local data = nil
|
2021-12-29 20:17:45 +08:00
|
|
|
|
local TEXT = {
|
2024-09-06 10:38:56 +08:00
|
|
|
|
[1] = { Language[10456], "r_Equip_GuardianWeapon_0004", Language[10980] },
|
|
|
|
|
|
[2] = { Language[11583], "r_Equip_Coat_0005", Language[10982] },
|
|
|
|
|
|
[3] = { Language[10458], "r_Equip_HeadAccessory_0005", Language[10983] },
|
|
|
|
|
|
[4] = { Language[10459], "r_equip_Shoes_0005", Language[10981] },
|
2021-12-29 20:17:45 +08:00
|
|
|
|
}
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local curSelectHero = nil
|
2022-09-01 17:30:15 +08:00
|
|
|
|
function this:InitComponent()
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.closeBtn = Util.GetGameObject(self.gameObject, "BG/BackBtn")
|
|
|
|
|
|
local gameObject = Util.GetGameObject(self.transform, "GeneralPopup_HomeLandEquip")
|
2021-12-29 20:17:45 +08:00
|
|
|
|
this.spLoader = SpriteLoader.New()
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.titleText = Util.GetGameObject(gameObject, "TitleText"):GetComponent("Text")
|
|
|
|
|
|
this.titleText.text = Language[12132]
|
|
|
|
|
|
this.Btn1 = Util.GetGameObject(gameObject, "Btn1")
|
|
|
|
|
|
this.Btn1Text = Util.GetGameObject(gameObject, "Btn1/Text"):GetComponent("Text")
|
|
|
|
|
|
this.Btn2 = Util.GetGameObject(gameObject, "Btn2")
|
|
|
|
|
|
this.resetBtn = Util.GetGameObject(gameObject, "resetBtn")
|
|
|
|
|
|
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.costIcon2 = Util.GetGameObject(gameObject, "Cost/Icon2"):GetComponent("Image")
|
|
|
|
|
|
this.costNum2 = Util.GetGameObject(gameObject, "Cost/Num2"):GetComponent("Text")
|
|
|
|
|
|
this.Cost = Util.GetGameObject(gameObject, "Cost")
|
|
|
|
|
|
this.Tips = Util.GetGameObject(gameObject, "Tips")
|
2022-01-05 18:04:57 +08:00
|
|
|
|
|
2021-12-29 20:17:45 +08:00
|
|
|
|
this.objList = {}
|
|
|
|
|
|
for i = 1, 4 do
|
|
|
|
|
|
this.objList[i] = {}
|
2024-09-06 10:38:56 +08:00
|
|
|
|
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")
|
2021-12-29 20:17:45 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.Desc = Util.GetGameObject(gameObject, "Content/Desc"):GetComponent("Text")
|
2022-09-01 17:30:15 +08:00
|
|
|
|
|
|
|
|
|
|
this.heroPre = Util.GetGameObject(this.gameObject, "Scroll/HeroPre")
|
|
|
|
|
|
this.scroll = Util.GetGameObject(gameObject, "Scroll")
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scroll.transform,
|
|
|
|
|
|
this.heroPre, this.scrollBar, Vector2.New(1010, 490), 1, 5, Vector2.New(20, 20))
|
2022-09-01 17:30:15 +08:00
|
|
|
|
this.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(0, 0)
|
|
|
|
|
|
this.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
|
|
|
|
|
|
this.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
|
|
|
|
|
|
this.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
|
|
|
|
|
|
this.scrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
|
this.scrollView.moveTween.Strength = 2
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.heroSelect = Util.GetGameObject(this.scroll, "Select")
|
2021-12-29 20:17:45 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function this:BindEvent()
|
2024-09-06 10:38:56 +08:00
|
|
|
|
Util.AddClick(this.closeBtn, function()
|
2022-09-01 17:30:15 +08:00
|
|
|
|
self:ClosePanel()
|
|
|
|
|
|
end)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
Util.AddClick(this.Btn1, function()
|
|
|
|
|
|
local curLv = not curSelectHero.equipStrong[HomeLandManager.curEquip] and
|
|
|
|
|
|
curSelectHero.equipStrong[HomeLandManager.curEquip] or 0
|
|
|
|
|
|
local data = ConfigManager.GetConfigDataByKey(ConfigName.EquipStrengthen, "Level", curLv)
|
2021-12-29 20:17:45 +08:00
|
|
|
|
if HomeLandManager.BuildData[data.Limit[1]].level < data.Limit[2] then
|
2024-09-19 20:14:12 +08:00
|
|
|
|
PopupTipPanel.ShowTip(string.format(Language[11582],
|
|
|
|
|
|
GetLanguageStrById(HomeLandManager.BuildData[data.Limit[1]].dataMain.Name),
|
2024-09-06 10:38:56 +08:00
|
|
|
|
data.Limit[2]))
|
2021-12-29 20:17:45 +08:00
|
|
|
|
return
|
|
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
|
2022-08-08 16:13:14 +08:00
|
|
|
|
for i = 1, #data.Cost do
|
|
|
|
|
|
if BagManager.GetTotalItemNum(data.Cost[i][1]) < data.Cost[i][2] then
|
|
|
|
|
|
--PopupTipPanel.ShowTip(string.format("%s不足!",ItemConfig[data.Cost[i][1]].Name))
|
2024-08-29 21:36:51 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10524])
|
2022-08-08 16:13:14 +08:00
|
|
|
|
return
|
|
|
|
|
|
end
|
2022-01-04 18:58:34 +08:00
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
NetManager.EquipIntensifyRequset(curSelectHero.dynamicId, HomeLandManager.curEquip, function()
|
2021-12-29 20:17:45 +08:00
|
|
|
|
this:Refresh()
|
|
|
|
|
|
end)
|
|
|
|
|
|
end)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
Util.AddClick(this.Btn2, function()
|
2022-09-01 17:30:15 +08:00
|
|
|
|
if HomeLandManager.GetAllCanUpgradeWithPopup(curSelectHero) then
|
2021-12-29 20:17:45 +08:00
|
|
|
|
this:Refresh()
|
|
|
|
|
|
return
|
|
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
NetManager.EquipIntensifyRequset(curSelectHero.dynamicId, 0, function()
|
2021-12-29 20:17:45 +08:00
|
|
|
|
this:Refresh()
|
|
|
|
|
|
end)
|
|
|
|
|
|
end)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
Util.AddClick(this.resetBtn, function()
|
|
|
|
|
|
NetManager.ResetHeroEquipRequest(curSelectHero.dynamicId, function()
|
2022-09-02 13:15:24 +08:00
|
|
|
|
this:Refresh()
|
|
|
|
|
|
end)
|
|
|
|
|
|
end)
|
2021-12-29 20:17:45 +08:00
|
|
|
|
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
|
|
|
|
|
|
|
2022-09-01 17:30:15 +08:00
|
|
|
|
function this:OnOpen()
|
|
|
|
|
|
local _roleDatas = HeroManager.GetAllHeroDatas()
|
|
|
|
|
|
this.SetHeroList(_roleDatas)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
curSelectHero = _roleDatas[1]
|
2021-12-29 20:17:45 +08:00
|
|
|
|
this:Refresh()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function this:Refresh()
|
|
|
|
|
|
for i = 1, 4 do
|
|
|
|
|
|
local go = this.objList[i]
|
|
|
|
|
|
go.select:SetActive(i == HomeLandManager.curEquip)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
go.name.text = TEXT[i][1] .. Language[12133]
|
|
|
|
|
|
go.level.text = curSelectHero.equipStrong[i] ~= nil and curSelectHero.equipStrong[i] or 0
|
2021-12-29 20:17:45 +08:00
|
|
|
|
go.image.sprite = this.spLoader:LoadSprite(TEXT[i][2])
|
2024-09-06 10:38:56 +08:00
|
|
|
|
Util.AddOnceClick(go.mask, function()
|
2021-12-29 20:17:45 +08:00
|
|
|
|
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
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local curLv = 0
|
2022-09-01 17:30:15 +08:00
|
|
|
|
if curSelectHero.equipStrong[curIndex] then
|
2024-09-06 10:38:56 +08:00
|
|
|
|
curLv = curSelectHero.equipStrong[curIndex]
|
2022-09-01 17:30:15 +08:00
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local equipStrengthenConfig = ConfigManager.GetConfigDataByKey(ConfigName.EquipStrengthen, "Level", curLv)
|
|
|
|
|
|
local equipRankUpConfig = ConfigManager.GetConfigDataByKey(ConfigName.EquipRankUp, "Level",
|
|
|
|
|
|
curSelectHero.equipAdvanceLv)
|
2021-12-30 11:00:27 +08:00
|
|
|
|
--设置消耗
|
2022-09-01 17:30:15 +08:00
|
|
|
|
local limit = equipStrengthenConfig.Limit
|
|
|
|
|
|
local cost = equipStrengthenConfig.Cost
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local data = equipStrengthenConfig.Rate --当前装备加成
|
|
|
|
|
|
local proData = equipRankUpConfig.Rate --当前装备突破加成
|
2022-01-05 18:04:57 +08:00
|
|
|
|
|
2024-09-06 10:38:56 +08:00
|
|
|
|
if cost then --如果有下一级
|
|
|
|
|
|
local nextEquipStrengthenConfig = ConfigManager.GetConfigDataByKey(ConfigName.EquipStrengthen, "Level", curLv + 1)
|
|
|
|
|
|
local nextData = nextEquipStrengthenConfig.Rate --下一装备加成
|
|
|
|
|
|
local nextProData = EquipRankUp[equipRankUpConfig.id + 1].Rate --下一装备突破加成
|
2022-01-06 17:53:53 +08:00
|
|
|
|
|
|
|
|
|
|
local num1 = data + proData[curIndex]
|
|
|
|
|
|
local num2 = 0
|
2024-09-06 10:38:56 +08:00
|
|
|
|
if not equipStrengthenConfig.Limit2 == equipRankUpConfig.Level then --如果都到达了等级上限
|
2022-01-06 17:53:53 +08:00
|
|
|
|
num2 = data + nextProData[curIndex]
|
|
|
|
|
|
else
|
|
|
|
|
|
num2 = nextData + proData[curIndex]
|
|
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.Desc.text = string.format(Language[12134], TEXT[curIndex][1], TEXT[curIndex][3], num1 / 100) ..
|
|
|
|
|
|
"%" .. string.format("<color=#1CC853>(%s", num2 / 100) .. "%)</color>"
|
2022-01-06 17:53:53 +08:00
|
|
|
|
|
2024-08-29 21:36:51 +08:00
|
|
|
|
this.Btn1Text.text = Language[12135]
|
2024-09-06 10:38:56 +08:00
|
|
|
|
Util.SetGray(this.Btn1, false)
|
2022-01-06 17:53:53 +08:00
|
|
|
|
this.Btn1:GetComponent("Button").enabled = true
|
2024-09-06 10:38:56 +08:00
|
|
|
|
|
2022-01-06 17:53:53 +08:00
|
|
|
|
if HomeLandManager.BuildData[limit[1]].level >= limit[2] then
|
2024-08-29 21:36:51 +08:00
|
|
|
|
this.costCondition.text = Language[12136]
|
2022-01-06 17:53:53 +08:00
|
|
|
|
this.costIcon.gameObject:SetActive(true)
|
|
|
|
|
|
this.costNum.gameObject:SetActive(true)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
|
2022-08-08 16:13:14 +08:00
|
|
|
|
this.costIcon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(cost[1][1]))
|
2022-01-06 17:53:53 +08:00
|
|
|
|
local color2 = BagManager.GetTotalItemNum(cost[1][1]) >= cost[1][2] and "#FFEED6" or "red"
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.costNum.text = string.format("<color=%s>%s</color>", color2, cost[1][2])
|
|
|
|
|
|
LogError("cost len==" .. #cost)
|
|
|
|
|
|
if #cost > 1 then
|
2022-08-08 16:13:14 +08:00
|
|
|
|
this.costIcon2.gameObject:SetActive(true)
|
|
|
|
|
|
this.costNum2.gameObject:SetActive(true)
|
|
|
|
|
|
this.costIcon2.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(cost[2][1]))
|
|
|
|
|
|
local color3 = BagManager.GetTotalItemNum(cost[2][1]) >= cost[2][2] and "#FFEED6" or "red"
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.costNum2.text = string.format("<color=%s>%s</color>", color3, cost[2][2])
|
2022-08-09 13:42:59 +08:00
|
|
|
|
else
|
|
|
|
|
|
this.costIcon2.gameObject:SetActive(false)
|
|
|
|
|
|
this.costNum2.gameObject:SetActive(false)
|
2022-08-08 16:13:14 +08:00
|
|
|
|
end
|
2022-01-06 17:53:53 +08:00
|
|
|
|
else
|
|
|
|
|
|
this.costIcon.gameObject:SetActive(false)
|
|
|
|
|
|
this.costNum.gameObject:SetActive(false)
|
2022-08-08 16:13:14 +08:00
|
|
|
|
this.costIcon2.gameObject:SetActive(false)
|
|
|
|
|
|
this.costNum2.gameObject:SetActive(false)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.costCondition.text = string.format(Language[12137], HomeLand[limit[1]].Name, limit[2])
|
2022-01-06 17:53:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
--按钮和tips显示
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local bool = equipStrengthenConfig.Limit2 == equipRankUpConfig.Level
|
2022-01-06 17:53:53 +08:00
|
|
|
|
-- LogBlue("bool:"..tostring(bool))
|
|
|
|
|
|
this.Btn1:SetActive(bool)
|
|
|
|
|
|
this.Btn2:SetActive(not bool)
|
|
|
|
|
|
--不同显示
|
|
|
|
|
|
this.Cost:SetActive(bool)
|
|
|
|
|
|
this.Tips:SetActive(not bool)
|
|
|
|
|
|
this.costCondition.gameObject:SetActive(true)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.Tips:GetComponent("Text").text = string.format(Language[12138], equipStrengthenConfig.Level)
|
2022-09-01 17:30:15 +08:00
|
|
|
|
if not bool and HomeLandManager.GetAllCanUpgrade(curSelectHero) then
|
2022-01-06 17:53:53 +08:00
|
|
|
|
this.Cost:SetActive(true)
|
|
|
|
|
|
this.Tips:SetActive(false)
|
|
|
|
|
|
this.costIcon.gameObject:SetActive(true)
|
|
|
|
|
|
this.costNum.gameObject:SetActive(true)
|
2022-09-02 14:26:03 +08:00
|
|
|
|
-- this.costCondition.gameObject:SetActive(false)
|
2024-08-29 21:36:51 +08:00
|
|
|
|
this.costCondition.text = Language[12139]
|
2022-01-06 17:53:53 +08:00
|
|
|
|
--突破的消耗和升级不同
|
2022-09-01 17:30:15 +08:00
|
|
|
|
local cost = equipRankUpConfig.Cost
|
2022-08-09 13:42:59 +08:00
|
|
|
|
local color2 = BagManager.GetTotalItemNum(cost[1][1]) >= cost[1][2] and "#FFEED6" or "red"
|
|
|
|
|
|
this.costIcon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(cost[1][1]))
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.costNum.text = string.format("<color=%s>%s</color>", color2, cost[1][2])
|
2022-08-09 13:42:59 +08:00
|
|
|
|
if cost[2] then
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.costIcon2.gameObject:SetActive(true)
|
|
|
|
|
|
this.costNum2.gameObject:SetActive(true)
|
|
|
|
|
|
this.costIcon2.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(cost[2][1]))
|
2022-08-09 13:42:59 +08:00
|
|
|
|
local color3 = BagManager.GetTotalItemNum(cost[2][1]) >= cost[2][2] and "#FFEED6" or "red"
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.costNum2.text = string.format("<color=%s>%s</color>", color3, cost[2][2])
|
2022-08-09 13:42:59 +08:00
|
|
|
|
else
|
|
|
|
|
|
this.costIcon2.gameObject:SetActive(false)
|
|
|
|
|
|
this.costNum2.gameObject:SetActive(false)
|
|
|
|
|
|
end
|
2022-01-06 17:53:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
this.Btn1:SetActive(true)
|
|
|
|
|
|
this.Btn2:SetActive(false)
|
2024-08-29 21:36:51 +08:00
|
|
|
|
this.Btn1Text.text = Language[10209]
|
2024-09-06 10:38:56 +08:00
|
|
|
|
Util.SetGray(this.Btn1, true)
|
2022-01-06 17:53:53 +08:00
|
|
|
|
this.Btn1:GetComponent("Button").enabled = false
|
|
|
|
|
|
local num1 = data + proData[curIndex]
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.Desc.text = string.format(Language[12134], TEXT[curIndex][1], TEXT[curIndex][3], num1) .. "%"
|
2022-01-06 17:53:53 +08:00
|
|
|
|
this.Cost:SetActive(false)
|
2022-01-06 11:45:28 +08:00
|
|
|
|
this.Tips:SetActive(false)
|
2022-01-05 18:04:57 +08:00
|
|
|
|
end
|
2021-12-29 20:17:45 +08:00
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
|
2022-09-01 17:30:15 +08:00
|
|
|
|
---设置显示英雄列表
|
|
|
|
|
|
function this.SetHeroList(_roleDatas)
|
2022-09-01 17:52:21 +08:00
|
|
|
|
HeroManager.SortHeroDatas(_roleDatas)
|
2022-09-01 17:30:15 +08:00
|
|
|
|
this.scrollView:SetData(_roleDatas, function(index, go)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
if index == 1 then
|
2022-09-01 17:30:15 +08:00
|
|
|
|
this.SetHeroSelect(go)
|
|
|
|
|
|
end
|
|
|
|
|
|
-- 基础显示
|
|
|
|
|
|
this.SingleHeroDataShow(go, _roleDatas[index])
|
2024-09-06 10:38:56 +08:00
|
|
|
|
end, true, false)
|
2022-09-01 17:30:15 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2022-09-01 17:52:21 +08:00
|
|
|
|
--英雄排序
|
|
|
|
|
|
function this:SortHeroDatas(_heroDatas)
|
|
|
|
|
|
--上阵最优先,星级优先,同星级等级优先,同星级同等级按sortId排序。排序时降序排序。
|
|
|
|
|
|
table.sort(_heroDatas, function(a, b)
|
|
|
|
|
|
if a.star == b.star then
|
2024-09-06 10:38:56 +08:00
|
|
|
|
if a.heroConfig.Natural == b.heroConfig.Natural then
|
2022-09-01 17:52:21 +08:00
|
|
|
|
if a.lv == b.lv then
|
|
|
|
|
|
return a.heroConfig.Id < b.heroConfig.Id
|
|
|
|
|
|
else
|
|
|
|
|
|
return a.lv > b.lv
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
return a.heroConfig.Natural > b.heroConfig.Natural
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
return a.star > b.star
|
|
|
|
|
|
end
|
|
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2022-09-01 17:30:15 +08:00
|
|
|
|
--设置每条英雄数据
|
|
|
|
|
|
function this.SingleHeroDataShow(_go, _heroData)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local go = _go
|
|
|
|
|
|
local heroData = _heroData
|
|
|
|
|
|
local frame = Util.GetGameObject(go, "frame"):GetComponent("Image")
|
|
|
|
|
|
local icon = Util.GetGameObject(go, "icon"):GetComponent("Image")
|
|
|
|
|
|
local lv = Util.GetGameObject(go, "lv/Text"):GetComponent("Text")
|
|
|
|
|
|
local pro = Util.GetGameObject(go, "proIcon"):GetComponent("Image")
|
|
|
|
|
|
local pos = Util.GetGameObject(go, "posIcon"):GetComponent("Image")
|
|
|
|
|
|
local teamList = {}
|
2022-09-01 17:30:15 +08:00
|
|
|
|
for i = 1, 3 do
|
2024-09-06 10:38:56 +08:00
|
|
|
|
table.insert(teamList, Util.GetGameObject(go, "yxteamName/Image" .. i))
|
2022-09-01 17:30:15 +08:00
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local yxInfo = Util.GetGameObject(go, "yxteamName")
|
2022-09-01 17:30:15 +08:00
|
|
|
|
--local yxTeamName=Util.GetGameObject(go, "yxteamName/Text"):GetComponent("Text")
|
|
|
|
|
|
yxInfo:SetActive(false)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
Util.GetGameObject(go, "posIcon"):SetActive(this.curFormationIndex == FormationTypeDef.FIGHT_LEVEL or
|
|
|
|
|
|
this.curFormationIndex == FormationTypeDef.FIGHT_ASSISTANTLEVEL or
|
|
|
|
|
|
this.curFormationIndex == FormationTypeDef.FORMATION_QIJIESHILIAN)
|
2022-09-01 17:30:15 +08:00
|
|
|
|
local starGrid = Util.GetGameObject(go, "star")
|
|
|
|
|
|
local yuanImage = Util.GetGameObject(go, "yuanImage")
|
|
|
|
|
|
yuanImage.gameObject:SetActive(false)
|
|
|
|
|
|
local choosedObj = Util.GetGameObject(go, "choosed")
|
|
|
|
|
|
choosedObj.gameObject:SetActive(false)
|
|
|
|
|
|
local hpExp = Util.GetGameObject(go, "hpExp")
|
|
|
|
|
|
hpExp.gameObject:SetActive(false)
|
|
|
|
|
|
local redPot = Util.GetGameObject(go, "redpoint")
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local changeProBtn = Util.GetGameObject(go, "proMaskObj")
|
2022-09-01 17:30:15 +08:00
|
|
|
|
if heroData.isNew and heroData.isNew == 1 then
|
|
|
|
|
|
redPot.gameObject:SetActive(true)
|
|
|
|
|
|
else
|
|
|
|
|
|
redPot.gameObject:SetActive(false)
|
|
|
|
|
|
end
|
|
|
|
|
|
if _heroData.property then
|
2024-09-06 10:38:56 +08:00
|
|
|
|
changeProBtn:SetActive(_heroData.property >= 6)
|
|
|
|
|
|
pro.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.property))
|
2022-09-01 17:30:15 +08:00
|
|
|
|
else
|
|
|
|
|
|
changeProBtn:SetActive(false)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
pro.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName))
|
2022-09-01 17:30:15 +08:00
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
frame.sprite = this.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality, heroData.star))
|
|
|
|
|
|
icon.sprite = this.spLoader:LoadSprite(heroData.icon)
|
2022-09-01 17:30:15 +08:00
|
|
|
|
if HarmonyManager.IsChangeColor(heroData.dynamicId) then
|
|
|
|
|
|
-- body
|
2024-09-06 10:38:56 +08:00
|
|
|
|
lv.text = "<color=#0f0>" .. heroData.lv .. "</color>"
|
2022-09-01 17:30:15 +08:00
|
|
|
|
elseif HarmonyManager:IsEnvoy(heroData.dynamicId) and HarmonyManager:HongMengTowerUpLimit() >= HarmonyManager.TowerStartLimit then
|
|
|
|
|
|
-- bod
|
2024-09-06 10:38:56 +08:00
|
|
|
|
lv.text = "<color=#ffbe22>" .. heroData.lv .. "</color>"
|
2022-09-01 17:30:15 +08:00
|
|
|
|
else
|
2024-09-06 10:38:56 +08:00
|
|
|
|
lv.text = heroData.lv
|
2022-09-01 17:30:15 +08:00
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
2022-09-01 17:30:15 +08:00
|
|
|
|
pos.sprite = this.spLoader:LoadSprite(heroData.professionIcon)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local star, starType = heroData.GetStar(1)
|
|
|
|
|
|
local starSize = Vector2.New(30, 30)
|
2022-09-01 17:30:15 +08:00
|
|
|
|
local starScale = -8
|
|
|
|
|
|
if starType == 3 then
|
2024-09-06 10:38:56 +08:00
|
|
|
|
starSize = Vector2.New(1, -15.65)
|
2022-09-01 17:30:15 +08:00
|
|
|
|
starScale = -13
|
|
|
|
|
|
elseif starType == 2 then
|
2024-09-06 10:38:56 +08:00
|
|
|
|
starSize = Vector2.New(60, 57)
|
2022-09-01 17:30:15 +08:00
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
SetHeroStars(this.spLoader, starGrid, star, starType, starSize, starScale)
|
2022-09-01 17:30:15 +08:00
|
|
|
|
|
|
|
|
|
|
Util.AddOnceClick(go, function()
|
2024-09-06 10:38:56 +08:00
|
|
|
|
curSelectHero = _heroData
|
2022-09-01 17:52:21 +08:00
|
|
|
|
this:Refresh()
|
2022-09-01 17:30:15 +08:00
|
|
|
|
this.SetHeroSelect(go)
|
|
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function this.SetHeroSelect(_heroObj)
|
|
|
|
|
|
this.heroSelect.transform:SetParent(_heroObj.transform)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.heroSelect.transform.localPosition = Vector3.zero
|
2022-09-01 17:30:15 +08:00
|
|
|
|
end
|
2021-12-29 20:17:45 +08:00
|
|
|
|
|
|
|
|
|
|
function this:OnClose()
|
|
|
|
|
|
HomeLandManager.curEquip = 1
|
2024-09-06 10:38:56 +08:00
|
|
|
|
data = nil
|
2021-12-29 20:17:45 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function this:OnDestroy()
|
|
|
|
|
|
this.SelectList = {}
|
|
|
|
|
|
this.spLoader:Destroy()
|
2022-09-01 17:30:15 +08:00
|
|
|
|
this.scrollView = nil
|
2021-12-29 20:17:45 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2024-09-06 10:38:56 +08:00
|
|
|
|
return this
|