miduo_client/Assets/ManagedResources/~Lua/Modules/RoleInfo/FaLingListPanel.lua

204 lines
7.7 KiB
Lua
Raw Normal View History

2025-03-14 11:58:20 +08:00
require("Base/BasePanel")
2023-11-28 18:44:36 +08:00
FaLingListPanel = Inherit(BasePanel)
local this = FaLingListPanel
2024-09-06 10:38:56 +08:00
local curSelectHeroList = {}
local heroDataList = {}
local curNeedRoleNum = 1
2023-11-28 18:44:36 +08:00
local openThisPanel
local curHeroData = {}
2024-09-06 10:38:56 +08:00
local openType = 0
2023-11-28 18:44:36 +08:00
--初始化组件(用于子类重写)
function FaLingListPanel:InitComponent()
this.spLoader = SpriteLoader.New()
this.BtnBack = Util.GetGameObject(self.gameObject, "btnBack")
this.mask = Util.GetGameObject(self.gameObject, "mask")
this.BtnSure = Util.GetGameObject(self.gameObject, "btnSure")
this.BtnSure:SetActive(false)
this.btnAutoSelect = Util.GetGameObject(self.gameObject, "btnAutoSelect")
this.cardPre = Util.GetGameObject(self.gameObject, "item")
--this.grid = Util.GetGameObject(self.gameObject, "scroll/grid")
local v = Util.GetGameObject(self.gameObject, "scroll"):GetComponent("RectTransform").rect
--LogGreen("v.width:".. v.width.." v.height:"..v.height)
2024-09-06 10:38:56 +08:00
this.Scrollbar = Util.GetGameObject(self.gameObject, "Scrollbar"):GetComponent("Scrollbar")
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,
Util.GetGameObject(self.gameObject, "scroll").transform,
this.cardPre, this.Scrollbar, Vector2.New(v.width, v.height), 1, 5, Vector2.New(19.32, 50))
2023-11-28 18:44:36 +08:00
this.ScrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(6.78, 27)
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.moveTween.MomentumAmount = 1
this.ScrollView.moveTween.Strength = 1
2024-09-06 10:38:56 +08:00
this.NoneImage = Util.GetGameObject(self.gameObject, "NoneImage")
2023-11-28 18:44:36 +08:00
this.NoneImage.gameObject:SetActive(false)
end
--绑定事件(用于子类重写)
function FaLingListPanel:BindEvent()
Util.AddClick(this.BtnBack, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
Util.AddClick(this.mask, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
Util.AddClick(this.BtnSure, function()
2024-09-06 10:38:56 +08:00
if #curSelectHeroList > 0 then
if openType == 1 then
NetManager.BaublesWearRequest(curHeroData.dynamicId, curSelectHeroList[1], nil, function()
2023-11-28 18:44:36 +08:00
self:ClosePanel()
end)
2024-09-06 10:38:56 +08:00
elseif openType == 2 then
NetManager.BaublesBlessRequest(curHeroData.baublesId, curSelectHeroList[1], function()
2023-11-28 18:44:36 +08:00
openThisPanel:OnShow()
self:ClosePanel()
end)
end
else
self:ClosePanel()
end
end)
Util.AddClick(this.btnAutoSelect, function()
self:AutoSelectHero()
end)
end
--添加事件监听(用于子类重写)
function FaLingListPanel:AddListener()
end
--移除事件监听(用于子类重写)
function FaLingListPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
2024-09-06 10:38:56 +08:00
function FaLingListPanel:OnOpen(heroData, _openThisPanel, _curSelectHeroList, _curHeroData, _openType)
openThisPanel = _openThisPanel
openType = _openType
curSelectHeroList = {}
2023-11-28 18:44:36 +08:00
print(#_curSelectHeroList)
for i = 1, #_curSelectHeroList do
-- curSelectHeroList[_curSelectHeroList[i]]=_curSelectHeroList[i]
2024-09-06 10:38:56 +08:00
table.insert(curSelectHeroList, _curSelectHeroList[i])
2023-11-28 18:44:36 +08:00
end
2024-09-06 10:38:56 +08:00
2023-11-28 18:44:36 +08:00
curHeroData = _curHeroData
heroDataList = heroData
--this.HeroSortData(heroDataList)
local text = ""
2024-09-06 10:38:56 +08:00
2023-11-28 18:44:36 +08:00
if not heroDataList or #heroDataList < 1 then
this.NoneImage.gameObject:SetActive(true)
else
this.NoneImage.gameObject:SetActive(false)
end
2024-09-06 10:38:56 +08:00
this.ScrollView:SetData(heroDataList, function(index, go)
2023-11-28 18:44:36 +08:00
this.OnShowSingleCardData(go, heroDataList[index])
2024-09-06 10:38:56 +08:00
end, false, false)
2023-11-28 18:44:36 +08:00
end
2024-09-06 10:38:56 +08:00
function this.OnClickEnterHero(go, heroData, type)
this.OnShowSingleCardData(go, heroData, type)
2023-11-28 18:44:36 +08:00
end
2024-09-06 10:38:56 +08:00
function this.OnShowSingleCardData(go, heroData) --isSelect 1选择 2 没选择
2023-11-28 18:44:36 +08:00
local choosed = Util.GetGameObject(go.transform, "choosed")
choosed:SetActive(false)
local frame = Util.GetGameObject(go.transform, "frame"):GetComponent("Image")
local lvGo = Util.GetGameObject(go.transform, "lv"):GetComponent("Text")
local icon = Util.GetGameObject(go.transform, "icon"):GetComponent("Image")
local name = Util.GetGameObject(go.transform, "name"):GetComponent("Text")
2024-09-06 10:38:56 +08:00
local belongName = Util.GetGameObject(go.transform, "belongName"):GetComponent("Text")
2023-11-28 18:44:36 +08:00
local formationMask = Util.GetGameObject(go.transform, "formationMask")
local formationImage = Util.GetGameObject(formationMask.transform, "formationImage")
local lockImage = Util.GetGameObject(formationMask.transform, "lockImage")
local noumenon = Util.GetGameObject(go, "noumenon")
local starGrid = Util.GetGameObject(go.transform, "star")
local cardBtn = Util.GetGameObject(go.transform, "icon")
2024-09-06 10:38:56 +08:00
local itemConfig = heroData.itemConfig
2023-11-28 18:44:36 +08:00
frame.sprite = this.spLoader:LoadSprite(heroData.frame)
2024-09-06 10:38:56 +08:00
if heroData.lv > 0 then
2023-11-28 18:44:36 +08:00
lvGo.gameObject:SetActive(true)
2024-09-06 10:38:56 +08:00
lvGo.text = heroData.lv
2023-11-28 18:44:36 +08:00
else
lvGo.gameObject:SetActive(false)
end
icon.sprite = this.spLoader:LoadSprite(heroData.icon)
formationMask:SetActive(false)
formationImage:SetActive(false)
lockImage:SetActive(false)
2024-09-06 10:38:56 +08:00
name.text = SubString2(GetLanguageStrById(itemConfig.Name), 8)
local talismana = ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana, "TalismanaId", heroData.staticId,
"Level", heroData.lv)
local heroId = talismana.HeroID
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, heroId)
2024-05-16 14:18:09 +08:00
if heroConfig then
2024-10-31 16:54:46 +08:00
belongName.text = SubString2(GetLanguageStrById(heroConfig.ReadingName) .. Language[12669], 8)
2024-05-16 14:18:09 +08:00
else
2024-09-06 10:38:56 +08:00
belongName.text = ""
2024-05-16 14:18:09 +08:00
end
2024-09-06 10:38:56 +08:00
local star = talismana.Star
if star > 0 then
2023-11-28 18:44:36 +08:00
starGrid:SetActive(true)
2024-09-06 10:38:56 +08:00
local starType = 1
local starSize = nil
starType = 3
star = star + 10
starSize = Vector2.New(0.8, -20)
2023-11-28 18:44:36 +08:00
local starScale = -20
2024-09-06 10:38:56 +08:00
SetHeroStars(this.spLoader, starGrid, star, starType, starSize, starScale)
2023-11-28 18:44:36 +08:00
Util.SetParticleSortLayer(starGrid, this.sortingOrder + 3)
else
starGrid:SetActive(false)
end
2024-09-06 10:38:56 +08:00
local isSelect = CheckListIsContainValue1(curSelectHeroList, heroData.did)
2023-11-28 18:44:36 +08:00
choosed:SetActive(isSelect)
2024-09-06 10:38:56 +08:00
Util.SetParticleSortLayer(starGrid, this.sortingOrder + 1)
2023-11-28 18:44:36 +08:00
Util.AddOnceClick(cardBtn, function()
-- if isSelect then
-- choosed:SetActive(false)
-- table.removebyvalue(curSelectHeroList,heroData.did)
-- isSelect=false
-- return
-- end
-- if LengthOfTable(curSelectHeroList)>=curNeedRoleNum then
2024-08-29 21:36:51 +08:00
-- PopupTipPanel.ShowTip("已达最大选择数量")
2023-11-28 18:44:36 +08:00
-- return
-- end
-- table.insert(curSelectHeroList,heroData.did)
-- isSelect=true
-- choosed:SetActive(true)
2024-09-06 10:38:56 +08:00
if openType == 1 then
UIManager.OpenPanel(UIName.FaLingSingleShowPopup, this, heroData, 3, false, false, curHeroData)
elseif openType == 2 then
NetManager.BaublesBlessRequest(curHeroData.baublesId, heroData.did, function()
2023-11-28 18:44:36 +08:00
openThisPanel:OnShow()
this:ClosePanel()
end)
end
end)
Util.AddLongPressClick(cardBtn, function()
--UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, heroData.id)
end, 0.5)
end
--界面关闭时调用(用于子类重写)
function FaLingListPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function FaLingListPanel:OnDestroy()
this.spLoader:Destroy()
this.ScrollView = nil
end
2024-09-06 10:38:56 +08:00
return FaLingListPanel