234 lines
8.7 KiB
Lua
234 lines
8.7 KiB
Lua
require("Base/BasePanel")
|
|
RoleChooseListPanel = Inherit(BasePanel)
|
|
local this = RoleChooseListPanel
|
|
local curSelectHeroList={}
|
|
|
|
local curNeedRoleNum
|
|
local openThisPanel
|
|
local curHeroData = {}
|
|
local TempData = nil;
|
|
local SelectHero = nil
|
|
local selectIndex = 0
|
|
--初始化组件(用于子类重写)
|
|
function RoleChooseListPanel:InitComponent()
|
|
|
|
this.BtnBack = Util.GetGameObject(self.transform, "btnBack")
|
|
this.BtnSure = Util.GetGameObject(self.transform, "btnSure")
|
|
this.BtnSure:SetActive(false)
|
|
this.btnAutoSelect = Util.GetGameObject(self.transform, "btnAutoSelect")
|
|
this.btnAutoSelect:SetActive(false)
|
|
this.cardPre = Util.GetGameObject(self.gameObject, "item")
|
|
this.btnYes = Util.GetGameObject(self.gameObject,"btnYes")
|
|
this.btnYes:SetActive(true)
|
|
--this.grid = Util.GetGameObject(self.gameObject, "scroll/grid")
|
|
this.title_text = Util.GetGameObject(self.gameObject,"bg/Text"):GetComponent("Text")
|
|
|
|
this.desText = Util.GetGameObject(self.gameObject, "desText"):GetComponent("Text")
|
|
this.numText = Util.GetGameObject(self.gameObject, "numText"):GetComponent("Text")
|
|
this.Empty = Util.GetGameObject(self.gameObject, "bg/Empty")
|
|
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, 5, Vector2.New(19.32,15))
|
|
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:InitData()
|
|
end
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
function RoleChooseListPanel:BindEvent()
|
|
|
|
Util.AddClick(this.BtnBack, function()
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.btnYes, function()
|
|
if TempData ==nil then
|
|
-- body
|
|
PopupTipPanel.ShowTip(Language[12218])
|
|
return
|
|
end
|
|
|
|
|
|
HarmonyManager:SetChooseId(TempData.dynamicId)
|
|
HarmonyManager.SetOldPowerNum(TempData.dynamicId)
|
|
if self.flag then --判断是否是鸿蒙使者 如果是 那就不懈装备
|
|
-- body
|
|
local data = {}
|
|
data.gridId = HarmonyManager.GongMingBox
|
|
data.heroId = TempData.dynamicId
|
|
data.time = 0
|
|
NetManager.SendGongMingBox(TempData.dynamicId,HarmonyManager.GongMingBox,4,function (msg)
|
|
-- body
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.UpHongMengEnvoy,data)
|
|
--UIManager.OpenPanel(UIName.GongMingResultPanel,self.flag)
|
|
HarmonyManager.WarPowerChangeNotify(TempData.dynamicId)
|
|
end)
|
|
else
|
|
|
|
HarmonyManager:SetGongMingList(TempData.dynamicId)
|
|
if HarmonyManager.equipCount == 24 then
|
|
LogGreen("脱装备")
|
|
for i = 1, #TempData.equipIdList do
|
|
HeroManager.SetHeroEquipIdList(TempData.dynamicId, {})
|
|
EquipManager.DeleteSingleEquip(TempData.equipIdList[i],TempData.dynamicId)
|
|
end
|
|
end
|
|
NetManager.SendGongMingBox(TempData.dynamicId,HarmonyManager.GongMingBox,1,function (msg)
|
|
-- body
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.ChooseData,TempData)
|
|
UIManager.OpenPanel(UIName.GongMingResultPanel,self.flag)
|
|
HarmonyManager.WarPowerChangeNotify(TempData.dynamicId)
|
|
end)
|
|
end
|
|
|
|
|
|
|
|
self:ClosePanel()
|
|
--
|
|
|
|
end)
|
|
Util.AddClick(this.btnAutoSelect, function()
|
|
|
|
end)
|
|
end
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function RoleChooseListPanel:AddListener()
|
|
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function RoleChooseListPanel:RemoveListener()
|
|
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function RoleChooseListPanel:OnOpen(flag)
|
|
this.desText.text = ""
|
|
this.numText.text = ""
|
|
this.title_text.text =Language[12219]
|
|
self.flag = flag
|
|
TempData = nil
|
|
--SelectHero = nil
|
|
local list = HarmonyManager.ChooseDataList
|
|
|
|
if #list > 0 then
|
|
-- body
|
|
|
|
this.Empty:SetActive(false)
|
|
table.sort(list, function(a, b)
|
|
if a.star == b.star then
|
|
if a.heroConfig.Natural ==b.heroConfig.Natural then
|
|
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)
|
|
self.ScrollView.gameObject:SetActive(true)
|
|
self.ScrollView:SetData(list,function (index, go)
|
|
|
|
this.OnShowSingleCardData(go, list[index],index)--
|
|
end)
|
|
|
|
else
|
|
|
|
list={}
|
|
self.ScrollView.gameObject:SetActive(false)
|
|
this.Empty:SetActive(true)
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
function this.OnShowSingleCardData(go,heroData,index)--isSelect 1选择 2 没选择
|
|
local choosed = Util.GetGameObject(go.transform, "choosed")
|
|
if choosed then
|
|
-- body
|
|
choosed:SetActive(false)
|
|
end
|
|
|
|
|
|
if curSelectHeroList[heroData.dynamicId] then
|
|
curSelectHeroList[heroData.dynamicId]=heroData
|
|
choosed:SetActive(true)
|
|
end
|
|
Util.GetGameObject(go.transform, "frame"):GetComponent("Image").sprite = Util.LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality,heroData.star))
|
|
Util.GetGameObject(go.transform, "lv/Text"):GetComponent("Text").text = heroData.lv
|
|
Util.GetGameObject(go.transform, "icon"):GetComponent("Image").sprite = Util.LoadSprite(heroData.icon)
|
|
Util.GetGameObject(go.transform, "posIcon"):SetActive(false)--:GetComponent("Image").sprite = Util.LoadSprite(heroData.professionIcon)
|
|
Util.GetGameObject(go.transform, "proIcon"):GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName))
|
|
--Util.GetGameObject(go.transform, "heroStage"):GetComponent("Image").sprite = Util.LoadSprite(HeroStageSprite[heroData.heroConfig.HeroStage])
|
|
local formationMask = Util.GetGameObject(go.transform, "formationMask")
|
|
--LogError("heroData.isFormation "..heroData.isFormation)
|
|
--formationMask:SetActive((heroData.isFormation ~= "" and heroData.isFormation ~= "该神将在大闹天宫阵容中已上阵") or heroData.lockState == 1)
|
|
Util.GetGameObject(formationMask.transform, "formationImage"):SetActive(heroData.isFormation ~= "" )
|
|
Util.GetGameObject(formationMask.transform, "lockImage"):SetActive( heroData.lockState == 1)
|
|
Util.GetGameObject(go.transform, "noumenon"):SetActive( heroData.id == curHeroData.id )
|
|
local starGrid = Util.GetGameObject(go.transform, "star")
|
|
SetHeroStars(starGrid, heroData.star,1,nil,nil,Vector2.New(0,1))
|
|
local cardBtn = Util.GetGameObject(go.transform, "icon")
|
|
local GongMingMask = Util.GetGameObject(go.transform, "GongMingMask")
|
|
GongMingMask:SetActive(false)--最后检测是否共鸣
|
|
Util.AddOnceClick(cardBtn, function()
|
|
|
|
|
|
if SelectHero then
|
|
--if SelectHero.activeSelf then
|
|
-- body
|
|
SelectHero:SetActive(false)
|
|
--end
|
|
|
|
--SelectHero = nil
|
|
end
|
|
TempData = heroData
|
|
SelectHero = choosed
|
|
selectIndex = index
|
|
SelectHero:SetActive(true)
|
|
--this.numText.text=string.format("%s/%s",LengthOfTable(curSelectHeroList),curNeedRoleNum)
|
|
end)
|
|
|
|
Util.AddOnceClick(formationMask, function()
|
|
if heroData.isFormation ~= "" then
|
|
PopupTipPanel.ShowTip( heroData.isFormation)
|
|
return
|
|
end
|
|
if heroData.lockState == 1 then
|
|
PopupTipPanel.ShowTip(Language[10413])
|
|
return
|
|
end
|
|
end)
|
|
end
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function RoleChooseListPanel:OnClose()
|
|
--destroy(SelectHero)
|
|
SelectHero = nil
|
|
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function RoleChooseListPanel:OnDestroy()
|
|
|
|
this.ScrollView = nil
|
|
end
|
|
|
|
return RoleChooseListPanel |