miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/MapFormationInfoPopup.lua

102 lines
3.4 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
MapFormationInfoPopup = Inherit(BasePanel)
local this = MapFormationInfoPopup
local heroListGo={}
2020-07-28 15:06:47 +08:00
local orginLayer = 0
local orginLayer2 = 0
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function MapFormationInfoPopup:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
this.btnBack = Util.GetGameObject(self.gameObject, "bg/btnBack")
this.btnTeamRoot = Util.GetGameObject(self.gameObject, "bg/roleGrid")
this.combatNum = Util.GetGameObject(self.gameObject, "bg/Combat/powerNum"):GetComponent("Text")
for i = 1, 6 do
heroListGo[i] = SubUIManager.Open(SubUIConfig.RoleItemView, Util.GetGameObject(this.transform, "roleGrid").transform)
end
2020-07-28 15:06:47 +08:00
for i = 1,Util.GetGameObject(this.transform, "roleGrid").transform.childCount do
2020-07-28 15:16:04 +08:00
Util.AddParticleSortLayer(Util.GetGameObject(this.transform, "roleGrid").transform:GetChild(i - 1).gameObject, self.sortingOrder - orginLayer2)
2020-07-28 15:06:47 +08:00
end
orginLayer2 = self.sortingOrder
orginLayer = self.sortingOrder
2020-05-09 13:31:21 +08:00
end
2020-07-28 15:06:47 +08:00
function MapFormationInfoPopup:OnSortingOrderChange()
for i = 1,Util.GetGameObject(this.transform, "roleGrid").transform.childCount do
2020-07-28 15:16:04 +08:00
Util.AddParticleSortLayer(Util.GetGameObject(this.transform, "roleGrid").transform:GetChild(i - 1).gameObject, self.sortingOrder - orginLayer)
2020-07-28 15:06:47 +08:00
end
orginLayer = self.sortingOrder
end
2020-05-09 13:31:21 +08:00
--绑定事件(用于子类重写)
function MapFormationInfoPopup:BindEvent()
Util.AddClick(this.btnBack, function ()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function MapFormationInfoPopup:AddListener()
end
--移除事件监听(用于子类重写)
function MapFormationInfoPopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function MapFormationInfoPopup:OnOpen(...)
this.RefreshFormation()
end
local powerNum = 0
-- 刷新编队显示
function this.RefreshFormation()
local curFormation = MapManager.formationList
powerNum = 0
for i = 1, 6 do
local heroData
if curFormation[i] then
heroData = HeroManager.GetSingleHeroData(curFormation[i].heroId)
if not heroData then
Log("heroData is not exist! error Did:" .. curFormation[i].heroId)
return
end
heroListGo[i]:OnOpen(curFormation[i].heroId,true,true,curFormation[i].allProVal[2] / curFormation[i].allProVal[3])
local allPropValue = curFormation[i].allProVal
Log("英雄剩余血量 == " .. curFormation[i].allProVal[2])
2020-05-09 13:31:21 +08:00
heroListGo[i]:AddClick(function()
UIManager.OpenPanel(UIName.MapRoleInfoPopup, heroData, allPropValue)
end)
if curFormation[i].allProVal[2] > 0 then
this.CalculateAllHeroPower(heroData)
end
heroListGo[i].gameObject:SetActive(true)
heroListGo[i].transform.localScale=Vector3.one*0.75
else
heroListGo[i].gameObject:SetActive(false)
end
end
this.combatNum.text = powerNum
end
2020-05-09 13:31:21 +08:00
function this.CalculateAllHeroPower(curHeroData)
powerNum = powerNum + HeroPowerManager.GetHeroPower(curHeroData.dynamicId)
2020-05-09 13:31:21 +08:00
end
--界面关闭时调用(用于子类重写)
function MapFormationInfoPopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function MapFormationInfoPopup:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
end
2020-06-23 18:36:24 +08:00
return MapFormationInfoPopup