189 lines
9.1 KiB
Lua
189 lines
9.1 KiB
Lua
require("Base/BasePanel")
|
||
GuildCarDelayLootPopup = Inherit(BasePanel)
|
||
local this = GuildCarDelayLootPopup
|
||
local CarChallenegList--抢夺后端信息
|
||
local origilayer = 0
|
||
--初始化组件(用于子类重写)
|
||
function GuildCarDelayLootPopup:InitComponent()
|
||
this.spLoader = SpriteLoader.New()
|
||
this.ItemPre = Util.GetGameObject(self.gameObject, "ItemPre")
|
||
local v2 = Util.GetGameObject(self.gameObject, "ScrollParentView"):GetComponent("RectTransform").rect
|
||
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.gameObject, "ScrollParentView").transform,
|
||
this.ItemPre, nil, Vector2.New(-v2.x*2, -v2.y*2), 1, 1, Vector2.New(50,-3))
|
||
this.ScrollView.moveTween.MomentumAmount = 1
|
||
this.ScrollView.moveTween.Strength = 1
|
||
this.BackBtn = Util.GetGameObject(self.gameObject, "bg/btnBack")
|
||
this.myScore = Util.GetGameObject(self.gameObject, "Record/Rank1"):GetComponent("Text")
|
||
this.myGuildName = Util.GetGameObject(self.gameObject, "Record/Rank0"):GetComponent("Text")
|
||
this.titleText = Util.GetGameObject(self.gameObject, "bg/titleText"):GetComponent("Text")
|
||
this.mySortNum = Util.GetGameObject(self.gameObject, "Record/SortNum")
|
||
this.Record = Util.GetGameObject(self.gameObject, "Record")
|
||
this.emptyObj = Util.GetGameObject(self.gameObject, "emptyObj")
|
||
end
|
||
|
||
--绑定事件(用于子类重写)
|
||
function GuildCarDelayLootPopup:BindEvent()
|
||
Util.AddClick(this.BackBtn, function()
|
||
self:ClosePanel()
|
||
end)
|
||
end
|
||
|
||
--添加事件监听(用于子类重写)
|
||
function GuildCarDelayLootPopup:AddListener()
|
||
end
|
||
|
||
--移除事件监听(用于子类重写)
|
||
function GuildCarDelayLootPopup:RemoveListener()
|
||
end
|
||
|
||
--界面打开时调用(用于子类重写)
|
||
function GuildCarDelayLootPopup:OnOpen(_msg)
|
||
--CarChallenegList = _msg
|
||
end
|
||
|
||
function GuildCarDelayLootPopup:OnSortingOrderChange()
|
||
for i = 1, this.ScrollView.transform.childCount do
|
||
Util.AddParticleSortLayer(this.ScrollView.transform:GetChild(i - 1).gameObject, self.sortingOrder - origilayer)
|
||
end
|
||
origilayer = self.sortingOrder
|
||
end
|
||
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
||
function GuildCarDelayLootPopup:OnShow()
|
||
NetManager.GetCarChallenegListResponse(function (msg)
|
||
--for i = 1, #msg.carChallengeItem do
|
||
-- LogError("uid "..msg.carChallengeItem[i].uid)
|
||
--end
|
||
for i = 1, #msg.carChallengeItem do
|
||
msg.carChallengeItem[i].userName = PracticeManager.SetNameColor(msg.carChallengeItem[i].userName,msg.carChallengeItem[i].practiceLevel)
|
||
end
|
||
CarChallenegList = msg
|
||
this.titleText.text = Language[11002]..ConfigManager.GetConfigData(ConfigName.WorldBossSetting,1).GrabPercent/100 ..Language[11003]
|
||
if CarChallenegList then
|
||
if CarChallenegList.myRank and CarChallenegList.myRank > 0 then
|
||
this.mySortNum:SetActive(true)
|
||
local sortNumTabs = {}
|
||
for i = 1, 4 do
|
||
sortNumTabs[i] = Util.GetGameObject(this.mySortNum, "SortNum ("..i..")")
|
||
sortNumTabs[i]:SetActive(false)
|
||
end
|
||
if CarChallenegList.myRank < 4 then
|
||
sortNumTabs[CarChallenegList.myRank]:SetActive(true)
|
||
else
|
||
sortNumTabs[4]:SetActive(true)
|
||
Util.GetGameObject(sortNumTabs[4], "TitleText"):GetComponent("Text").text = CarChallenegList.myRank
|
||
end
|
||
else
|
||
this.mySortNum:SetActive(false)
|
||
end
|
||
this.myGuildName.text = PlayerManager.nickName --MyGuildManager.MyGuildInfo.name
|
||
this.myScore.text = CarChallenegList.myScore > 0 and PrintWanNum3(CarChallenegList.myScore) or Language[10141]
|
||
end
|
||
this.emptyObj:SetActive(not CarChallenegList.carChallengeItem or #CarChallenegList.carChallengeItem <= 0)
|
||
local carChallengeItem = {}
|
||
if CarChallenegList.carChallengeItem and #CarChallenegList.carChallengeItem > 0 then
|
||
for i = 1, #CarChallenegList.carChallengeItem do
|
||
table.insert(carChallengeItem,CarChallenegList.carChallengeItem[i])
|
||
end
|
||
table.sort(carChallengeItem, function(a,b) return a.rank < b.rank end)
|
||
end
|
||
this.ScrollView:SetData(carChallengeItem, function (index, go)
|
||
this.SingleInfoDataShow(go, carChallengeItem[index])
|
||
end)
|
||
end)
|
||
end
|
||
--optional int32 uid = 1;
|
||
--optional string userName =2;
|
||
--optional int32 force =3;
|
||
--optional string guildName = 4;
|
||
--optional int32 score = 5;
|
||
--optional int32 hadChallenge =6; // 是否已挑战过,1:表示挑战过,2:未挑战过。
|
||
--optional int32 rank = 7;
|
||
--optional TeamOneInfo teamInfo = 8;
|
||
function this.SingleInfoDataShow(go,data)
|
||
local sortNumTabs = {}
|
||
for i = 1, 4 do
|
||
sortNumTabs[i] = Util.GetGameObject(go, "SortNum/SortNum ("..i..")")
|
||
sortNumTabs[i]:SetActive(false)
|
||
end
|
||
LogRed("data.rank:"..data.rank)
|
||
if data.rank < 4 then
|
||
sortNumTabs[data.rank]:SetActive(true)
|
||
else
|
||
sortNumTabs[4]:SetActive(true)
|
||
Util.GetGameObject(sortNumTabs[4], "TitleText"):GetComponent("Text").text = data.rank
|
||
end
|
||
Util.GetGameObject(go, "infoText/playerName"):GetComponent("Text").text = data.userName
|
||
Util.GetGameObject(go, "infoText/warPower"):GetComponent("Text").text = data.force
|
||
local guildName = data.guildName
|
||
if data.serverName and data.serverName ~= "" then
|
||
guildName = data.serverName.." "..guildName
|
||
end
|
||
Util.GetGameObject(go, "infoText/guildName"):GetComponent("Text").text = guildName
|
||
Util.GetGameObject(go, "infoText/soreText"):GetComponent("Text").text = PrintWanNum3(data.score)
|
||
--LogError("#data.teamInfo "..#data.teamInfo)
|
||
--hadChallenge =6; // 是否已挑战过,1:表示挑战过,2:未挑战过。
|
||
local curHeroGoList = {}
|
||
for i = 1,6 do
|
||
curHeroGoList[i] = Util.GetGameObject(go, "Demons/heroPro ("..i..")")
|
||
Util.GetGameObject(curHeroGoList[i], "hero"):SetActive(false)
|
||
Util.GetGameObject(curHeroGoList[i], "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite("r_characterbg_gray")
|
||
end
|
||
-- --LogGreen(" #data.teamInfo ".. #data.teamInfo)
|
||
for i = 1, #data.teamInfo do
|
||
local heroGo = Util.GetGameObject(curHeroGoList[data.teamInfo[i].position], "hero")
|
||
heroGo:SetActive(true)
|
||
local curHeroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig,data.teamInfo[i].heroTid)
|
||
Util.GetGameObject(heroGo, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(curHeroConfig.Icon))
|
||
Util.GetGameObject(heroGo, "proIcon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(curHeroConfig.PropertyName))
|
||
Util.GetGameObject(curHeroGoList[data.teamInfo[i].position], "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetHeroQuantityImageByquality(nil,data.teamInfo[i].star))
|
||
local star,starType = GetStarOrGodSoulLv(1,data.teamInfo[i])
|
||
local starSize = Vector2.New(35,35)
|
||
local starScale = -17.78
|
||
if starType == 3 then
|
||
starSize = Vector2.New(0.8,-15)
|
||
starScale = -13.56
|
||
elseif starType == 2 then
|
||
starSize = Vector2.New(60,60)
|
||
end
|
||
SetHeroStars(this.spLoader, Util.GetGameObject(heroGo, "starGrid"), star,starType,starSize,starScale)
|
||
Util.SetParticleSortLayer(Util.GetGameObject(heroGo, "starGrid"),origilayer + 1)
|
||
Util.GetGameObject(heroGo, "lvbg/levelText"):GetComponent("Text").text=data.teamInfo[i].level
|
||
local heroData = {}
|
||
Util.AddOnceClick(Util.GetGameObject(Util.GetGameObject(curHeroGoList[data.teamInfo[i].position], "frame"), "frame"), function()
|
||
NetManager.ViewHeroInfoRequest(data.uid,data.teamInfo[i].heroid,nil,FormationTypeDef.FORMATION_NORMAL,function(msg)
|
||
heroData= GoodFriendManager.GetHeroDatas(msg.hero,msg.force,msg.SpecialEffects)
|
||
GoodFriendManager.InitEquipData(msg.equip,heroData)
|
||
UIManager.OpenPanel(UIName.RoleInfoPopup, heroData,true)
|
||
end)
|
||
end)
|
||
end
|
||
--抢夺点击事件
|
||
Util.AddOnceClick(Util.GetGameObject(go, "lootBtn"), function()
|
||
GuildCarDelayManager.SetheroDid(data)
|
||
local formationTeamHeros = FormationManager.GetWuJinFormationHeroIds(FormationTypeDef.GUILD_CAR_DELEAY)
|
||
if LengthOfTable(formationTeamHeros) <= 0 then
|
||
FormationManager.GetFormationByID(FormationTypeDef.GUILD_CAR_DELEAY)
|
||
end
|
||
if data.teamInfo and #data.teamInfo > 0 then
|
||
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.GUILD_CAR_DELEAY)
|
||
this:ClosePanel()
|
||
else
|
||
GuildCarDelayManager.FightBattle(function()
|
||
this:ClosePanel()
|
||
UIManager.OpenPanel(UIName.GuildCarDelayMainPanel)
|
||
end)
|
||
end
|
||
end)
|
||
end
|
||
--界面关闭时调用(用于子类重写)
|
||
function GuildCarDelayLootPopup:OnClose()
|
||
end
|
||
|
||
--界面销毁时调用(用于子类重写)
|
||
function GuildCarDelayLootPopup:OnDestroy()
|
||
this.spLoader:Destroy()
|
||
end
|
||
|
||
return GuildCarDelayLootPopup
|
||
|