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

247 lines
9.2 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
2020-12-17 10:41:00 +08:00
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()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-12-17 10:41:00 +08:00
this.BtnBack = Util.GetGameObject(self.transform, "btnBack")
this.BtnSure = Util.GetGameObject(self.transform, "btnSure")
2020-12-18 16:31:28 +08:00
this.BtnSure:SetActive(false)
2020-12-17 10:41:00 +08:00
this.btnAutoSelect = Util.GetGameObject(self.transform, "btnAutoSelect")
2020-12-18 16:31:28 +08:00
this.btnAutoSelect:SetActive(false)
2020-12-17 10:41:00 +08:00
this.cardPre = Util.GetGameObject(self.gameObject, "item")
2020-12-18 16:31:28 +08:00
this.btnYes = Util.GetGameObject(self.gameObject,"btnYes")
this.btnYes:SetActive(true)
2020-12-17 10:41:00 +08:00
--this.grid = Util.GetGameObject(self.gameObject, "scroll/grid")
2020-12-18 16:31:28 +08:00
this.title_text = Util.GetGameObject(self.gameObject,"bg/Text"):GetComponent("Text")
2020-12-17 10:41:00 +08:00
this.desText = Util.GetGameObject(self.gameObject, "desText"):GetComponent("Text")
this.numText = Util.GetGameObject(self.gameObject, "numText"):GetComponent("Text")
2021-01-11 21:04:12 +08:00
this.Empty = Util.GetGameObject(self.gameObject, "bg/Empty")
2020-12-17 10:41:00 +08:00
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,
2021-04-06 16:44:04 +08:00
this.cardPre, this.Scrollbar, Vector2.New(v.width, v.height), 1, 5, Vector2.New(20,50))
2020-12-17 10:41:00 +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
2021-01-11 21:04:12 +08:00
this.NoneImage= Util.GetGameObject(self.gameObject, "NoneImage")
this.NoneImage.gameObject:SetActive(false)
2021-01-14 21:11:53 +08:00
--this:InitData()
2020-12-17 10:41:00 +08:00
end
2021-01-14 21:11:53 +08:00
2020-12-17 10:41:00 +08:00
--绑定事件(用于子类重写)
function RoleChooseListPanel:BindEvent()
Util.AddClick(this.BtnBack, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
2020-12-18 16:31:28 +08:00
Util.AddClick(this.btnYes, function()
2020-12-17 10:41:00 +08:00
if TempData ==nil then
-- body
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[12218])
2020-12-17 10:41:00 +08:00
return
end
HarmonyManager:SetChooseId(TempData.dynamicId)
2020-12-18 18:25:38 +08:00
HarmonyManager.SetOldPowerNum(TempData.dynamicId)
2020-12-17 10:41:00 +08:00
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)
2021-01-08 17:29:54 +08:00
--UIManager.OpenPanel(UIName.GongMingResultPanel,self.flag)
2020-12-18 18:25:38 +08:00
HarmonyManager.WarPowerChangeNotify(TempData.dynamicId)
2020-12-17 10:41:00 +08:00
end)
else
HarmonyManager:SetGongMingList(TempData.dynamicId)
if HarmonyManager.equipCount == 24 then
--LogGreen("脱装备")
2020-12-17 10:41:00 +08:00
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)
2020-12-18 18:25:38 +08:00
HarmonyManager.WarPowerChangeNotify(TempData.dynamicId)
2020-12-17 10:41:00 +08:00
end)
end
self:ClosePanel()
--
end)
Util.AddClick(this.btnAutoSelect, function()
2021-01-14 21:11:53 +08:00
2020-12-17 10:41:00 +08:00
end)
end
--添加事件监听(用于子类重写)
function RoleChooseListPanel:AddListener()
end
--移除事件监听(用于子类重写)
function RoleChooseListPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function RoleChooseListPanel:OnOpen(flag)
2020-12-18 16:31:28 +08:00
this.desText.text = ""
this.numText.text = ""
2021-04-09 12:26:35 +08:00
this.title_text.text =Language[12219]
2020-12-17 10:41:00 +08:00
self.flag = flag
2021-01-14 21:11:53 +08:00
TempData = nil
--SelectHero = nil
2020-12-25 15:33:12 +08:00
local list = HarmonyManager.ChooseDataList
2021-01-20 10:37:02 +08:00
2021-01-11 21:04:12 +08:00
if #list > 0 then
-- body
2021-01-20 10:37:02 +08:00
2021-01-11 21:04:12 +08:00
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
2020-12-25 15:33:12 +08:00
else
2021-01-11 21:04:12 +08:00
return a.heroConfig.Natural > b.heroConfig.Natural
2020-12-25 15:33:12 +08:00
end
else
2021-01-11 21:04:12 +08:00
return a.star > b.star
2020-12-25 15:33:12 +08:00
end
2021-01-11 21:04:12 +08:00
end)
if not list or #list < 1 then
this.NoneImage.gameObject:SetActive(true)
else
this.NoneImage.gameObject:SetActive(false)
end
2021-01-14 21:11:53 +08:00
self.ScrollView.gameObject:SetActive(true)
2021-01-11 21:04:12 +08:00
self.ScrollView:SetData(list,function (index, go)
this.OnShowSingleCardData(go, list[index],index)--
end)
2020-12-17 10:41:00 +08:00
2021-01-11 21:04:12 +08:00
else
2021-01-14 21:11:53 +08:00
list={}
self.ScrollView.gameObject:SetActive(false)
2021-01-11 21:04:12 +08:00
this.Empty:SetActive(true)
end
2020-12-17 10:41:00 +08:00
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
2021-04-21 13:12:04 +08:00
Util.GetGameObject(go.transform, "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality,heroData.star))
2020-12-17 10:41:00 +08:00
Util.GetGameObject(go.transform, "lv/Text"):GetComponent("Text").text = heroData.lv
2021-04-21 13:12:04 +08:00
Util.GetGameObject(go.transform, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(heroData.icon)
Util.GetGameObject(go.transform, "posIcon"):SetActive(false)--:GetComponent("Image").sprite = this.spLoader:LoadSprite(heroData.professionIcon)
Util.GetGameObject(go.transform, "proIcon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName))
--Util.GetGameObject(go.transform, "heroStage"):GetComponent("Image").sprite = this.spLoader:LoadSprite(HeroStageSprite[heroData.heroConfig.HeroStage])
2020-12-17 10:41:00 +08:00
local formationMask = Util.GetGameObject(go.transform, "formationMask")
--LogError("heroData.isFormation "..heroData.isFormation)
2021-02-20 16:55:28 +08:00
--formationMask:SetActive((heroData.isFormation ~= "" and heroData.isFormation ~= "该神将在大闹天宫阵容中已上阵") or heroData.lockState == 1)
2020-12-17 10:41:00 +08:00
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 )
Util.GetGameObject(go.transform, "name"):GetComponent("Text").text = heroData.heroConfig.ReadingName
2020-12-17 10:41:00 +08:00
local starGrid = Util.GetGameObject(go.transform, "star")
2021-04-21 13:12:04 +08:00
SetHeroStars(this.spLoader, starGrid, heroData.star,1,nil,nil,Vector2.New(0,1))
2020-12-17 10:41:00 +08:00
local cardBtn = Util.GetGameObject(go.transform, "icon")
2020-12-18 16:37:56 +08:00
local GongMingMask = Util.GetGameObject(go.transform, "GongMingMask")
GongMingMask:SetActive(false)--最后检测是否共鸣
2020-12-17 10:41:00 +08:00
Util.AddOnceClick(cardBtn, function()
2021-01-20 10:37:02 +08:00
2020-12-17 10:41:00 +08:00
if SelectHero then
--if SelectHero.activeSelf then
-- body
SelectHero:SetActive(false)
--end
2020-12-25 15:33:12 +08:00
--SelectHero = nil
2020-12-17 10:41:00 +08:00
end
TempData = heroData
SelectHero = choosed
selectIndex = index
SelectHero:SetActive(true)
2020-12-18 16:31:28 +08:00
--this.numText.text=string.format("%s/%s",LengthOfTable(curSelectHeroList),curNeedRoleNum)
2020-12-17 10:41:00 +08:00
end)
Util.AddOnceClick(formationMask, function()
if heroData.isFormation ~= "" then
PopupTipPanel.ShowTip( heroData.isFormation)
return
end
if heroData.lockState == 1 then
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[10413])
2020-12-17 10:41:00 +08:00
return
end
end)
end
2021-01-14 21:11:53 +08:00
2020-12-17 10:41:00 +08:00
--界面关闭时调用(用于子类重写)
function RoleChooseListPanel:OnClose()
2020-12-25 15:33:12 +08:00
--destroy(SelectHero)
2020-12-17 10:41:00 +08:00
SelectHero = nil
2021-01-14 21:11:53 +08:00
2020-12-17 10:41:00 +08:00
end
--界面销毁时调用(用于子类重写)
function RoleChooseListPanel:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2021-01-14 21:11:53 +08:00
2020-12-17 10:41:00 +08:00
this.ScrollView = nil
end
2021-04-21 13:12:04 +08:00
return RoleChooseListPanel