miduo_client/Assets/ManagedResources/~Lua/Modules/HelpFight/HelpFightListPanel.lua

182 lines
6.4 KiB
Lua

require("Base/BasePanel")
HelpFightListPanel = Inherit(BasePanel)
local this = HelpFightListPanel
local curSelectHeroList={}
local heroDataList={}
local curNeedRoleNum
local openThisPanel
local curHeroData = {}
local isChange=false
--初始化组件(用于子类重写)
function HelpFightListPanel:InitComponent()
this.spLoader = SpriteLoader.New()
this.BtnBack = Util.GetGameObject(self.gameObject, "btnBack")
this.title=Util.GetGameObject(self.gameObject, "bg/title"):GetComponent("Text")
this.mask = Util.GetGameObject(self.gameObject, "mask")
this.cardPre = Util.GetGameObject(self.gameObject, "item")
this.upHero=Util.GetGameObject(self.gameObject, "upObj/upHero")
local v = Util.GetGameObject(self.gameObject, "scroll"):GetComponent("RectTransform").rect
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, 2, Vector2.New(10,20))
this.ScrollView.moveTween.MomentumAmount = 1
this.ScrollView.moveTween.Strength = 1
this.NoneImage= Util.GetGameObject(self.gameObject, "NoneImage")
this.NoneImage.gameObject:SetActive(false)
end
--绑定事件(用于子类重写)
function HelpFightListPanel: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)
end
--添加事件监听(用于子类重写)
function HelpFightListPanel:AddListener()
end
--移除事件监听(用于子类重写)
function HelpFightListPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
local curPos=0
local limitQua=0
local limitPro=0
local openPanel=nil
function HelpFightListPanel:OnOpen(data,_openPanel)
openPanel=_openPanel
this.title.text=data.title
curPos=data.pos
limitQua=data.limitQua
limitPro=data.limitPro
this.RefreshWindow(data)
end
function HelpFightListPanel:OnShow()
isChange=false
end
local upHeroData=nil
function this.RefreshWindow(data)
local heroDataList=HeroManager.GetHeroDatasByNaturalAndProfession(limitQua,limitPro)
-- this.HeroSortData(heroDataList)
if not heroDataList or #heroDataList < 1 then
this.NoneImage.gameObject:SetActive(true)
else
this.NoneImage.gameObject:SetActive(false)
end
upHeroData=data.hero
this.upHero:SetActive(data.hero~=nil)
this.ScrollView:SetData(heroDataList, function (index, go)
this.OnShowSingleCardData(go, heroDataList[index],curPos,false)
end,false,false)
if data.hero then
this.OnShowSingleCardData(this.upHero,data.hero,data.pos,true)
end
end
function this.OnShowSingleCardData(go,heroData,index,isUp)--isSelect 1选择 2 没选择
Util.GetGameObject(go.transform, "posIcon"):SetActive(false)
local frame = Util.GetGameObject(go.transform, "frame"):GetComponent("Image")
local lvGo = Util.GetGameObject(go.transform, "lv")
local icon = Util.GetGameObject(go.transform, "icon"):GetComponent("Image")
local proIcon = Util.GetGameObject(go.transform, "proIcon")
local name = Util.GetGameObject(go.transform, "name"):GetComponent("Text")
local starGrid = Util.GetGameObject(go.transform, "star")
local cardBtn = Util.GetGameObject(go.transform, "icon")
local proTxt=Util.GetGameObject(go.transform, "proList/pro1"):GetComponent("Text")
frame.sprite = this.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Natural))
lvGo:SetActive(true)
Util.GetGameObject(lvGo.transform, "Text"):GetComponent("Text").text = heroData.lv
icon.sprite = this.spLoader:LoadSprite(heroData.icon)
proIcon:GetComponent("Image").sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.changeProId))
name.text = SubString2(GetLanguageStrById(heroData.heroConfig.ReadingName),8)
local star,starType = heroData.GetStar(1)
SetHeroStars(this.spLoader, starGrid, star,starType,nil,nil,Vector2.New(0,1))
LogError("hero star=="..star)
local config=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.AssistanceProperty,"Quality",heroData.heroConfig.Natural,"Star",heroData.star)
local str=""
if config then
for i = 1, #config.Property do
local k=config.Property[i][1]
local v=config.Property[i][2]
str=str..GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.PropertyConfig,i).Info).." +"..v.."\n"
end
proTxt.text=str
end
Util.SetParticleSortLayer(starGrid,this.sortingOrder + 1)
local btn_up=Util.GetGameObject(go.transform, "btn_up")
Util.GetGameObject(go.transform, "btn_up/Text"):GetComponent("Text").text="上阵"
local btn_down=Util.GetGameObject(go.transform, "btn_down")
Util.GetGameObject(go.transform, "btn_down/Text"):GetComponent("Text").text="下阵"
btn_up:SetActive(isUp==false and upHeroData==nil)
btn_down:SetActive(isUp)
Util.AddOnceClick(btn_up, function()
NetManager.AssistUpDownRequest(curPos,heroData.dynamicId,1,function ()
local data={}
data.hero=heroData
data.limitQua=limitQua
data.limitPro=limitPro
data.pos=curPos
this.RefreshWindow(data)
isChange=true
end)
end)
Util.AddOnceClick(btn_down, function()
LogError("heroData.dynamicId==="..heroData.dynamicId)
LogError("curpos==================="..curPos)
NetManager.AssistUpDownRequest(curPos,heroData.dynamicId,2,function()
local data={}
data.hero=nil
data.limitQua=limitQua
data.limitPro=limitPro
data.pos=curPos
this.RefreshWindow(data)
isChange=true
end)
end)
end
function this.HeroSortData(heroData)
end
--界面关闭时调用(用于子类重写)
function HelpFightListPanel:OnClose()
if isChange then
openPanel:OnShow()
end
end
--界面销毁时调用(用于子类重写)
function HelpFightListPanel:OnDestroy()
this.spLoader:Destroy()
this.ScrollView = nil
end
return HelpFightListPanel