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

199 lines
7.7 KiB
Lua

require("Base/BasePanel")
FaLingUpStarListPanel = Inherit(BasePanel)
local this = FaLingUpStarListPanel
local curSelectHeroList={}
local heroDataList={}
local curNeedRoleNum=0
local openThisPanel
local curHeroData = {}
--初始化组件(用于子类重写)
function FaLingUpStarListPanel: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.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)
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,40))
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
this.NoneImage= Util.GetGameObject(self.gameObject, "NoneImage")
this.NoneImage.gameObject:SetActive(false)
this.infoTxt=Util.GetGameObject(self.gameObject, "infoTxt"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function FaLingUpStarListPanel: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()
LogError("curSelectHeroList len======"..#curSelectHeroList)
openThisPanel:ChangeSelectMat(curSelectHeroList)
openThisPanel:ShowCostInfo()
self:ClosePanel()
end)
Util.AddClick(this.btnAutoSelect, function()
self:AutoSelectHero()
end)
end
--添加事件监听(用于子类重写)
function FaLingUpStarListPanel:AddListener()
end
--移除事件监听(用于子类重写)
function FaLingUpStarListPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function FaLingUpStarListPanel:OnOpen(heroData,_openThisPanel,_curSelectHeroList,_curHeroData,_maxNum)
openThisPanel= _openThisPanel
curNeedRoleNum=_maxNum
curSelectHeroList={}
print(#_curSelectHeroList)
for i = 1, #_curSelectHeroList do
-- curSelectHeroList[_curSelectHeroList[i]]=_curSelectHeroList[i]
table.insert(curSelectHeroList,_curSelectHeroList[i])
end
curHeroData = _curHeroData
heroDataList = heroData
--this.HeroSortData(heroDataList)
local text = ""
if not heroDataList or #heroDataList < 1 then
this.NoneImage.gameObject:SetActive(true)
else
this.NoneImage.gameObject:SetActive(false)
end
this.ScrollView:SetData(heroDataList, function (index, go)
this.OnShowSingleCardData(go, heroDataList[index])
end,false,false)
this.infoTxt.text=string.format("强化所要生命卡 %s/%s",#curSelectHeroList,curNeedRoleNum)
end
function this.OnClickEnterHero(go,heroData,type)
this.OnShowSingleCardData(go,heroData,type)
end
function this.OnShowSingleCardData(go,heroData)--isSelect 1选择 2 没选择
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")
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")
local itemConfig=heroData.itemConfig
frame.sprite = this.spLoader:LoadSprite(heroData.frame)
if heroData.lv>0 then
lvGo.gameObject:SetActive(true)
lvGo.text=heroData.lv
else
lvGo.gameObject:SetActive(false)
end
icon.sprite = this.spLoader:LoadSprite(heroData.icon)
formationMask:SetActive(false)
formationImage:SetActive(false)
lockImage:SetActive(false)
noumenon:SetActive(false)
name.text = SubString2(GetLanguageStrById(itemConfig.Name),8)
local talismana=ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",heroData.staticId,"Level",heroData.lv)
local star=talismana.Star
if star>0 then
starGrid:SetActive(true)
local starType=1
local starSize=nil
starType=3
star=star+10
starSize = Vector2.New(0.8,-20)
local starScale = -20
SetHeroStars(this.spLoader,starGrid, star,starType,starSize,starScale)
Util.SetParticleSortLayer(starGrid, this.sortingOrder + 3)
else
starGrid:SetActive(false)
end
local isSelect = CheckListIsContainValue1(curSelectHeroList,heroData.did)
choosed:SetActive(isSelect)
Util.SetParticleSortLayer(starGrid,this.sortingOrder + 1)
Util.AddOnceClick(cardBtn, function()
if isSelect then
--table.removebyvalue(curSelectHeroList,heroData.did)
table_removebyvalue(curSelectHeroList,heroData.did)
isSelect=false
choosed:SetActive(false)
this.infoTxt.text=string.format("强化所要生命卡 %s/%s",#curSelectHeroList,curNeedRoleNum)
return
end
if LengthOfTable(curSelectHeroList)>=curNeedRoleNum then
PopupTipPanel.ShowTip(Language[10403])
return
end
if heroData.lv>0 then
local sureFunc=function()
table.insert(curSelectHeroList,heroData.did)
isSelect=true
choosed:SetActive(true)
this.infoTxt.text=string.format("强化所要生命卡 %s/%s",#curSelectHeroList,curNeedRoleNum)
end
local args={}
args[1]="生命卡已经升级、升星,作为其他生命卡的材料将不会返还升级、升星材料"
args[2]="确定"
args[3]="取消"
args[4]=sureFunc
UIManager.OpenPanel(UIName.GMCommonConfirmPanel,args)
else
table.insert(curSelectHeroList,heroData.did)
isSelect=true
choosed:SetActive(true)
this.infoTxt.text=string.format("强化所要生命卡 %s/%s",#curSelectHeroList,curNeedRoleNum)
end
end)
Util.AddLongPressClick(cardBtn, function()
--UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, heroData.id)
end, 0.5)
end
--界面关闭时调用(用于子类重写)
function FaLingUpStarListPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function FaLingUpStarListPanel:OnDestroy()
this.spLoader:Destroy()
this.ScrollView = nil
end
return FaLingUpStarListPanel