miduo_client/Assets/ManagedResources/~Lua/Modules/Guild/CarDelay/GuildCarDelayLootPopup.lua

185 lines
9.0 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
GuildCarDelayLootPopup = Inherit(BasePanel)
local this = GuildCarDelayLootPopup
local CarChallenegList--抢夺后端信息
2020-07-28 16:54:38 +08:00
local origilayer = 0
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function GuildCarDelayLootPopup:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
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,
2020-05-15 16:52:35 +08:00
this.ItemPre, nil, Vector2.New(-v2.x*2, -v2.y*2), 1, 1, Vector2.New(50,-3))
2020-05-09 13:31:21 +08:00
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")
2020-05-11 09:38:52 +08:00
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")
2020-05-09 13:31:21 +08:00
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)
2020-05-15 16:52:35 +08:00
--CarChallenegList = _msg
2020-05-09 13:31:21 +08:00
end
2020-07-28 16:54:38 +08:00
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
2020-05-09 13:31:21 +08:00
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function GuildCarDelayLootPopup:OnShow()
2020-05-15 16:52:35 +08:00
NetManager.GetCarChallenegListResponse(function (msg)
--for i = 1, #msg.carChallengeItem do
-- LogError("uid "..msg.carChallengeItem[i].uid)
--end
2021-05-31 15:00:28 +08:00
for i = 1, #msg.carChallengeItem do
msg.carChallengeItem[i].userName = PracticeManager.SetNameColor(msg.carChallengeItem[i].userName,msg.carChallengeItem[i].practiceLevel)
end
2020-05-15 16:52:35 +08:00
CarChallenegList = msg
2021-03-02 16:53:12 +08:00
this.titleText.text = Language[11002]..ConfigManager.GetConfigData(ConfigName.WorldBossSetting,1).GrabPercent/100 ..Language[11003]
2020-05-15 16:52:35 +08:00
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
2020-05-11 09:38:52 +08:00
else
2020-05-15 16:52:35 +08:00
this.mySortNum:SetActive(false)
2020-05-11 09:38:52 +08:00
end
this.myGuildName.text = PlayerManager.nickName --MyGuildManager.MyGuildInfo.name
2021-03-02 16:53:12 +08:00
this.myScore.text = CarChallenegList.myScore > 0 and CarChallenegList.myScore or Language[10141]
2020-05-11 09:38:52 +08:00
end
2020-05-15 16:52:35 +08:00
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])
2020-05-15 16:52:35 +08:00
end)
2020-05-09 13:31:21 +08:00
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)
2020-05-09 13:31:21 +08:00
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
Util.GetGameObject(go, "infoText/guildName"):GetComponent("Text").text = data.guildName
Util.GetGameObject(go, "infoText/soreText"):GetComponent("Text").text = data.score
--LogError("#data.teamInfo "..#data.teamInfo)
--hadChallenge =6; // 是否已挑战过1表示挑战过2未挑战过。
2020-05-11 09:38:52 +08:00
local curHeroGoList = {}
2020-05-09 13:31:21 +08:00
for i = 1,6 do
2020-05-11 09:38:52 +08:00
curHeroGoList[i] = Util.GetGameObject(go, "Demons/heroPro ("..i..")")
Util.GetGameObject(curHeroGoList[i], "hero"):SetActive(false)
2021-04-21 13:12:04 +08:00
Util.GetGameObject(curHeroGoList[i], "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite("r_characterbg_gray")
2020-05-11 09:38:52 +08:00
end
-- --LogGreen(" #data.teamInfo ".. #data.teamInfo)
2020-05-11 09:38:52 +08:00
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)
2021-04-21 13:12:04 +08:00
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))
2021-10-26 16:00:31 +08:00
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)
2021-11-05 13:18:55 +08:00
Util.SetParticleSortLayer(Util.GetGameObject(heroGo, "starGrid"),origilayer + 1)
2020-05-11 09:38:52 +08:00
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()
2021-07-30 11:59:39 +08:00
NetManager.ViewHeroInfoRequest(data.uid,data.teamInfo[i].heroid,nil,FormationTypeDef.FORMATION_NORMAL,function(msg)
2020-05-11 09:38:52 +08:00
heroData= GoodFriendManager.GetHeroDatas(msg.hero,msg.force,msg.SpecialEffects)
GoodFriendManager.InitEquipData(msg.equip,heroData)
UIManager.OpenPanel(UIName.RoleInfoPopup, heroData,true)
end)
end)
2020-05-09 13:31:21 +08:00
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
2020-05-09 13:31:21 +08:00
end)
end
--界面关闭时调用(用于子类重写)
function GuildCarDelayLootPopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function GuildCarDelayLootPopup:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
end
2021-04-21 13:12:04 +08:00
return GuildCarDelayLootPopup