156 lines
6.0 KiB
Lua
156 lines
6.0 KiB
Lua
require("Base/BasePanel")
|
|
HegemonyChallengePopup = Inherit(BasePanel)
|
|
local this = HegemonyChallengePopup
|
|
local heros = {}
|
|
local HeroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
|
local FormationConfig = ConfigManager.GetConfig(ConfigName.FormationConfig)
|
|
|
|
function this:InitComponent()
|
|
this.scrollShow = Util.GetGameObject(self.gameObject, "ScrollShow")
|
|
this.itemPre = Util.GetGameObject(self.gameObject, "itemPre")
|
|
this.item = Util.GetGameObject(self.gameObject,"item")
|
|
this.backBtn = Util.GetGameObject(self.gameObject, "backBtn")
|
|
|
|
local rect = this.scrollShow.transform.rect
|
|
this.ScrollView1 = SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scrollShow.transform,
|
|
this.itemPre, nil, Vector2.New(rect.width, rect.height), 1, 1, Vector2.New(0, 5))
|
|
this.ScrollView1.moveTween.MomentumAmount = 1
|
|
this.ScrollView1.moveTween.Strength = 1
|
|
end
|
|
|
|
function this:BindEvent()
|
|
Util.AddClick(this.backBtn,function()
|
|
self:ClosePanel()
|
|
end)
|
|
end
|
|
|
|
function this:AddListener()
|
|
end
|
|
|
|
function this:RemoveListener()
|
|
|
|
end
|
|
|
|
function this:OnSortingOrderChange()
|
|
this.sortingOrder = self.sortingOrder
|
|
end
|
|
|
|
function this:OnOpen(...)
|
|
local arg = {...}
|
|
local msg = arg[1]
|
|
this.rank = arg[2]
|
|
this.pos = arg[3]
|
|
this.fightId = arg[4]
|
|
this.dataInfo = msg.personInfo
|
|
|
|
this.ScrollView1:SetData(this.dataInfo, function (index, go)
|
|
this.SetItemPreData(go, this.dataInfo[index])
|
|
end)
|
|
end
|
|
|
|
function this:OnShow()
|
|
end
|
|
|
|
function this:OnClose()
|
|
end
|
|
|
|
function this:OnDestroy()
|
|
heros = {}
|
|
end
|
|
|
|
function this.SetItemPreData(go, data)
|
|
local challengeName = Util.GetGameObject(go, "ChallengeName/Text")
|
|
local challengeTime = Util.GetGameObject(go, "ChallengeTime")
|
|
local battle = Util.GetGameObject(go, "InfoShow/battle/Text")
|
|
local formationName = Util.GetGameObject(go, "InfoShow/formationName/Text")
|
|
local challengeResNum = Util.GetGameObject(go, "InfoShow/challengeRes/Text")
|
|
local scroll = Util.GetGameObject(go, "Scroll/mask")
|
|
local playbackBtn = Util.GetGameObject(go, "playbackBtn")
|
|
|
|
challengeName:GetComponent("Text").text = data.name
|
|
challengeTime:GetComponent("Text").text = GetTimeStrBySeconds(data.time)
|
|
battle:GetComponent("Text").text = data.allHeroForce
|
|
formationName:GetComponent("Text").text = GetLanguageStrById(FormationConfig[data.formationId].name)
|
|
|
|
local challengeRes = Util.GetGameObject(go, "InfoShow/challengeRes")
|
|
if data.resultCode == 1 then
|
|
challengeRes:GetComponent("Text").text = GetLanguageStrById(12613)
|
|
challengeResNum:GetComponent("Text").text = data.level
|
|
else
|
|
challengeRes:GetComponent("Text").text = GetLanguageStrById(12614)
|
|
challengeResNum:GetComponent("Text").text = data.level
|
|
end
|
|
-- local heroInfos = data.heros
|
|
-- local rect = this.scroll.transform.rect
|
|
-- if ScrollView2[gameObject] == nil then
|
|
-- ScrollView2[gameObject] = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scroll.transform, this.item, nil, Vector2.New(rect.width, rect.height), 2, 1, Vector2.New(0,0))
|
|
-- ScrollView2[gameObject].moveTween.MomentumAmount = 1
|
|
-- ScrollView2[gameObject].moveTween.Strength = 1
|
|
-- end
|
|
-- ScrollView2[gameObject]:SetData(heroInfos, function (index, go)
|
|
-- this:ShowItemData(go, heroInfos[index])
|
|
-- end)
|
|
if not heros[go] then
|
|
heros[go] = {}
|
|
end
|
|
for i = 1, #heros[go] do
|
|
heros[go][i]:SetActive(false)
|
|
end
|
|
for i = 1, #data.heros do
|
|
if not heros[go][i] then
|
|
heros[go][i] = newObjToParent(this.item, scroll)
|
|
end
|
|
this.ShowItemData(heros[go][i], data.heros[i])
|
|
heros[go][i]:SetActive(true)
|
|
end
|
|
|
|
Util.AddClick(playbackBtn, function()
|
|
BattleManager.GotoFight(function()
|
|
local structA = {
|
|
head = data.head,
|
|
headFrame = data.headFrame,
|
|
name = data.name,
|
|
formationId = data.formationId,
|
|
investigateLevel = data.investigateLevel
|
|
}
|
|
local _monsterGroupId = G_SupremacyConfig[this.fightId].Monster
|
|
local monsterShowId = GetMonsterGroupFirstEnemy(_monsterGroupId)
|
|
local heroid = G_MonsterConfig[monsterShowId].MonsterId
|
|
local image = GetResourcePath(G_HeroConfig[heroid].Icon)
|
|
local structB = {
|
|
head = tostring(image),
|
|
headFrame = nil,
|
|
name = nil,
|
|
formationId = G_MonsterGroup[_monsterGroupId].Formation,
|
|
investigateLevel = 1
|
|
}
|
|
BattleManager.SetAgainstInfoData(BATTLE_TYPE.BACK, structA, structB)
|
|
|
|
HegemonyManager.RequestRecordFightData(data.resultCode, data.time, this.rank, this.pos, nameStr, function()
|
|
end)
|
|
end)
|
|
end)
|
|
end
|
|
|
|
function this.ShowItemData(go, data)
|
|
local heroConfigData = HeroConfig[data.heroId]
|
|
local frame = Util.GetGameObject(go, "frame"):GetComponent("Image")
|
|
local icon = Util.GetGameObject(go, "icon"):GetComponent("Image")
|
|
local proIconBg = Util.GetGameObject(go, "proIconBg"):GetComponent("Image")
|
|
local proIcon = Util.GetGameObject(go, "proIconBg/proIcon"):GetComponent("Image")
|
|
-- local name = Util.GetGameObject(go, "name"):GetComponent("Text")
|
|
local lvBg = Util.GetGameObject(go, "lv"):GetComponent("Image")
|
|
local lv = Util.GetGameObject(go, "lv/Text"):GetComponent("Text")
|
|
local star = Util.GetGameObject(go, "star")
|
|
|
|
frame.sprite = Util.LoadSprite(GetHeroQuantityImageByquality(heroConfigData.Quality, data.star))
|
|
icon.sprite = Util.LoadSprite(GetResourcePath(heroConfigData.Icon))
|
|
proIcon.sprite = Util.LoadSprite(GetProStrImageByProNum(heroConfigData.PropertyName))
|
|
-- name.text = GetLanguageStrById(heroConfigData.ReadingName)
|
|
lv.text = data.level
|
|
SetHeroStars(star, data.star)
|
|
proIconBg.sprite = Util.LoadSprite(GetQuantityProBgImageByquality(heroConfigData.Quality, data.star))
|
|
lvBg.sprite = Util.LoadSprite(GetQuantityImageByqualityHexagon(heroConfigData.Quality, data.star))
|
|
end
|
|
|
|
return HegemonyChallengePopup |