2021-04-21 13:12:04 +08:00
|
|
|
|
HarmonyView={}
|
2020-12-15 11:03:34 +08:00
|
|
|
|
-- 鸿蒙守卫脚本
|
|
|
|
|
function HarmonyView:New(gameObject)
|
|
|
|
|
local b = {}
|
|
|
|
|
b.gameObject = gameObject
|
|
|
|
|
b.transform = gameObject.transform
|
|
|
|
|
setmetatable(b, { __index = HarmonyView })
|
|
|
|
|
return b
|
|
|
|
|
end
|
|
|
|
|
HarmonyView.GongMingTable = {}
|
|
|
|
|
HarmonyView.HongMengData = {}
|
|
|
|
|
function HarmonyView:InitComponent()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
self.spLoader = SpriteLoader.New()
|
2020-12-15 11:03:34 +08:00
|
|
|
|
local num = self.gameObject.transform.childCount
|
2020-12-21 15:10:23 +08:00
|
|
|
|
-- for i = 0, num-1 do
|
|
|
|
|
-- self.GongMingTable[i] =self.gameObject.transform:GetChild(i).gameObject
|
|
|
|
|
-- end
|
|
|
|
|
for i = 1, 6 do
|
2021-11-05 10:18:10 +08:00
|
|
|
|
self.GongMingTable[i] = {}
|
|
|
|
|
self.GongMingTable[i].go = Util.GetGameObject(self.gameObject, "item (" .. i .. ")")
|
|
|
|
|
self.GongMingTable[i].infoGo = Util.GetGameObject(self.GongMingTable[i].go,"GameObject/infoGo")
|
|
|
|
|
self.GongMingTable[i].frame = Util.GetGameObject(self.GongMingTable[i].go, "GameObject/frame"):GetComponent("Image")
|
|
|
|
|
self.GongMingTable[i].lv = Util.GetGameObject( self.GongMingTable[i].infoGo,"lv/Text"):GetComponent("Text")
|
|
|
|
|
self.GongMingTable[i].icon = Util.GetGameObject(self.GongMingTable[i].go, "GameObject/icon"):GetComponent("Image")
|
|
|
|
|
self.GongMingTable[i].proIcon = Util.GetGameObject( self.GongMingTable[i].infoGo,"proIcon"):GetComponent("Image")
|
|
|
|
|
self.GongMingTable[i].starGrid = Util.GetGameObject( self.GongMingTable[i].infoGo,"star")
|
2020-12-15 11:03:34 +08:00
|
|
|
|
end
|
2020-11-27 17:59:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-12-15 11:03:34 +08:00
|
|
|
|
|
|
|
|
|
function HarmonyView:BindEvent()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function HarmonyView:AddListener()
|
2020-11-27 17:59:25 +08:00
|
|
|
|
|
2020-12-15 11:03:34 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function HarmonyView:RemoveListener()
|
|
|
|
|
|
|
|
|
|
end
|
2020-11-27 17:59:25 +08:00
|
|
|
|
|
2021-04-21 13:12:04 +08:00
|
|
|
|
function HarmonyView:OnClose()
|
|
|
|
|
self.spLoader:Destroy()
|
|
|
|
|
end
|
2020-12-15 11:03:34 +08:00
|
|
|
|
function HarmonyView:SetGreen(HongMengData)
|
2020-12-21 15:10:23 +08:00
|
|
|
|
|
2020-12-15 11:03:34 +08:00
|
|
|
|
local min = HongMengData[#self.GongMingTable].lv
|
|
|
|
|
for i = 0, #self.GongMingTable do
|
|
|
|
|
if HongMengData[i+1].lv == min then
|
|
|
|
|
self.count=self.count+1;
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
function HarmonyView:InitData(data)
|
|
|
|
|
table.sort(data, function(a,b)
|
|
|
|
|
if a.lv==b.lv then
|
|
|
|
|
return a.warPower > b.warPower
|
|
|
|
|
else
|
|
|
|
|
return a.lv > b.lv
|
|
|
|
|
end
|
|
|
|
|
end)
|
2020-12-21 15:10:23 +08:00
|
|
|
|
-- return data
|
2020-12-15 11:03:34 +08:00
|
|
|
|
end
|
2021-11-05 10:18:10 +08:00
|
|
|
|
function HarmonyView:OnOpen(sortingOrder)
|
|
|
|
|
self.sortingOrder = sortingOrder
|
2020-12-21 15:10:23 +08:00
|
|
|
|
local heroDataList = {}
|
|
|
|
|
if HarmonyManager.hongmengGuards and #HarmonyManager.hongmengGuards > 0 then
|
|
|
|
|
for i = 1, #HarmonyManager.hongmengGuards do
|
2020-12-24 16:16:53 +08:00
|
|
|
|
if HarmonyManager.hongmengGuards[i].heroId ~= "" then
|
|
|
|
|
-- body
|
2020-12-26 15:07:51 +08:00
|
|
|
|
|
2020-12-24 16:16:53 +08:00
|
|
|
|
table.insert(heroDataList,HeroManager.GetSingleHeroData(HarmonyManager.hongmengGuards[i].heroId))
|
2020-12-28 10:44:31 +08:00
|
|
|
|
--LogBlue("刷新IsHaveHero:"..HarmonyManager.hongmengGuards[i].heroId.." ::: "..tostring(HeroManager.IsHaveHero(HarmonyManager.hongmengGuards[i].heroId)))
|
2020-12-26 15:07:51 +08:00
|
|
|
|
if not HeroManager.IsHaveHero(HarmonyManager.hongmengGuards[i].heroId) then
|
|
|
|
|
for k = 1, #HarmonyManager.hongmengHeroInfos do
|
|
|
|
|
-- body
|
|
|
|
|
if HarmonyManager.hongmengGuards[i].heroId == HarmonyManager.hongmengHeroInfos[k].heroId then
|
|
|
|
|
-- body
|
|
|
|
|
LogPink(HeroManager.GetSingleHeroData(HarmonyManager.hongmengHeroInfos[k].heroId))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
-- body
|
|
|
|
|
end
|
2020-12-24 16:16:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-12-21 15:10:23 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2020-12-28 10:44:31 +08:00
|
|
|
|
--LogGreen("heroDataList长度:"..#heroDataList)
|
2020-12-23 17:41:31 +08:00
|
|
|
|
-- if #heroDataList > 0 then
|
|
|
|
|
-- table.sort(heroDataList, function(a,b)
|
|
|
|
|
-- if a.lv==b.lv then
|
|
|
|
|
-- return a.warPower > b.warPower
|
|
|
|
|
-- else
|
|
|
|
|
-- return a.lv > b.lv
|
|
|
|
|
-- end
|
|
|
|
|
-- end)
|
|
|
|
|
-- end
|
2020-12-24 16:16:53 +08:00
|
|
|
|
|
2020-12-21 15:10:23 +08:00
|
|
|
|
|
|
|
|
|
-- self.count = 1;
|
|
|
|
|
-- self:SetGreen(self.HongMengData)
|
2020-12-23 17:41:31 +08:00
|
|
|
|
--LogGreen(heroDataList[6].name)
|
|
|
|
|
|
2020-12-21 15:10:23 +08:00
|
|
|
|
for i = 1, 6 do
|
|
|
|
|
local singleHeroData = {}
|
|
|
|
|
if heroDataList[i] then
|
|
|
|
|
singleHeroData = heroDataList[i]
|
|
|
|
|
self.HongMengData[i] = singleHeroData
|
2020-12-24 16:16:53 +08:00
|
|
|
|
if heroDataList[i].lv== heroDataList[#heroDataList].lv then
|
2020-12-21 15:10:23 +08:00
|
|
|
|
-- body
|
2020-12-26 15:07:51 +08:00
|
|
|
|
|
2020-12-21 15:10:23 +08:00
|
|
|
|
self:SetItem(self.HongMengData[i],self.GongMingTable[i],1)
|
|
|
|
|
else
|
|
|
|
|
self:SetItem(self.HongMengData[i],self.GongMingTable[i],0)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2020-12-15 11:03:34 +08:00
|
|
|
|
else
|
2020-12-21 15:10:23 +08:00
|
|
|
|
self.HongMengData[i] = singleHeroData
|
|
|
|
|
self:SetItem(nil,self.GongMingTable[i],0)
|
2020-12-15 11:03:34 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2020-12-24 16:16:53 +08:00
|
|
|
|
|
2021-01-08 17:29:54 +08:00
|
|
|
|
HarmonyManager.equipCount = 0
|
2020-12-24 16:16:53 +08:00
|
|
|
|
for i = 1, #self.HongMengData do
|
|
|
|
|
if self.HongMengData[i] then
|
|
|
|
|
-- body
|
|
|
|
|
if self.HongMengData[i].equipIdList then
|
|
|
|
|
-- body
|
|
|
|
|
for i = 1, #self.HongMengData[i].equipIdList do
|
|
|
|
|
HarmonyManager.equipCount= HarmonyManager.equipCount+1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
2021-07-01 21:07:53 +08:00
|
|
|
|
-- print(Language[12229]..HarmonyManager.equipCount)
|
2020-12-21 15:10:23 +08:00
|
|
|
|
-- for i = 0, #self.GongMingTable do
|
|
|
|
|
-- if i == 5 then
|
|
|
|
|
-- self:SetItem(self.HongMengData[i+1],self.GongMingTable[i],1)
|
|
|
|
|
-- else
|
|
|
|
|
-- self:SetItem(self.HongMengData[i+1],self.GongMingTable[i],0)
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
HarmonyManager:SetGuardList(self.HongMengData,#heroDataList)
|
2020-12-15 11:03:34 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-11-05 10:18:10 +08:00
|
|
|
|
function HarmonyView:SetEffectLayer(sortingOrder)
|
|
|
|
|
for i = 1, 6 do
|
|
|
|
|
Util.SetParticleSortLayer(self.GongMingTable[i].starGrid,sortingOrder + 1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-12-15 11:03:34 +08:00
|
|
|
|
function HarmonyView:SetItem(data,go,flag)
|
2020-12-21 15:10:23 +08:00
|
|
|
|
if data then
|
2021-11-05 10:18:10 +08:00
|
|
|
|
go.infoGo:SetActive(true)
|
|
|
|
|
go.frame.sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(data.heroConfig.Quality,data.star))
|
2020-12-21 15:10:23 +08:00
|
|
|
|
if flag == 0 then
|
2021-11-05 10:18:10 +08:00
|
|
|
|
go.lv.text = data.lv
|
2020-12-21 15:10:23 +08:00
|
|
|
|
else
|
2021-11-05 10:18:10 +08:00
|
|
|
|
go.lv.text = string.format("<color=#0f0>%d</color>",data.lv)
|
2020-12-21 15:10:23 +08:00
|
|
|
|
end
|
2021-11-05 10:18:10 +08:00
|
|
|
|
go.icon.sprite = self.spLoader:LoadSprite(data.icon)
|
2022-03-28 18:18:19 +08:00
|
|
|
|
go.proIcon.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(data.changeProId))
|
2021-10-26 16:00:31 +08:00
|
|
|
|
local star,starType = data.GetStar(1)
|
2021-11-05 10:18:10 +08:00
|
|
|
|
SetHeroStars(self.spLoader, go.starGrid, star,starType,nil,nil,Vector2.New(0,1))
|
2022-01-15 12:26:12 +08:00
|
|
|
|
SetHeroFlyEffect(go.infoGo,self.spLoader,data.star,self.sortingOrder+1,1.2,0)
|
|
|
|
|
|
2021-11-05 10:18:10 +08:00
|
|
|
|
Util.SetParticleSortLayer(go.starGrid,self.sortingOrder + 1)
|
2020-12-15 11:03:34 +08:00
|
|
|
|
else
|
2021-11-05 10:18:10 +08:00
|
|
|
|
go.infoGo:SetActive(false)
|
2020-12-15 11:03:34 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-11-05 10:18:10 +08:00
|
|
|
|
|
2020-11-27 17:59:25 +08:00
|
|
|
|
return HarmonyView
|