miduo_client/Assets/ManagedResources/~Lua/Modules/Battle/View/BattleEndPanel.lua

141 lines
4.7 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
BattleEndPanel = Inherit(BasePanel)
local this = BattleEndPanel
local BattlePanel
local callBack
2020-07-28 15:06:47 +08:00
local selfsortingOrder = 0
local orginLayer2 = 0
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function BattleEndPanel:InitComponent()
this.bg = Util.GetGameObject(self.gameObject, "btnBack")
this.roleGrid = Util.GetGameObject(self.gameObject, "roleGrid")
this.roleGrid:SetActive(false)
2020-05-09 13:31:21 +08:00
this.awardGrid = Util.GetGameObject(self.gameObject, "Bg/ItemRoot/grid")
this.btnResult = Util.GetGameObject(self.gameObject, "btnResult")
end
--绑定事件(用于子类重写)
function BattleEndPanel:BindEvent()
Util.AddClick(this.bg, function ()
self:ClosePanel()
-- if BattlePanel then
-- BattlePanel:ClosePanel()
-- end
2020-05-09 13:31:21 +08:00
end)
Util.AddClick(this.btnResult, function()
UIManager.OpenPanel(UIName.DamageResultPanel, 1)
end)
end
--添加事件监听(用于子类重写)
function BattleEndPanel:AddListener()
end
--移除事件监听(用于子类重写)
function BattleEndPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function BattleEndPanel:OnOpen(battlePanel, hpList, drop, func, isShowResult)
2020-07-28 15:06:47 +08:00
selfsortingOrder = self.sortingOrder
2020-05-09 13:31:21 +08:00
if battlePanel then
BattlePanel = battlePanel
end
callBack = nil
if func then
callBack = func
end
this.RefreshTeamInfo(hpList)
this.SetItemShow(drop)
-- 判断是否显示战斗统计
if isShowResult == nil then isShowResult = false end
local haveRecord = BattleRecordManager.isHaveRecord()
isShowResult = isShowResult and haveRecord
this.btnResult:SetActive(isShowResult)
end
-- 显示队伍信息
function this.RefreshTeamInfo(hpList,self)
2020-05-09 13:31:21 +08:00
local curFormation = MapManager.formationList
ClearChild(this.roleGrid.transform)
for i = 1, 5 do
local heroData
local go = SubUIManager.Open(SubUIConfig.RoleItemView, this.roleGrid.transform)
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
local curHeroHp = hpList[i]
2020-06-23 18:36:24 +08:00
Log(Language[10254] .. curHeroHp)
2020-05-09 13:31:21 +08:00
go:OnOpen(curFormation[i].heroId, true, true, curHeroHp / curFormation[i].allProVal[3])
local allPropValue = curFormation[i].allProVal
go:AddClick(function()
UIManager.OpenPanel(UIName.MapRoleInfoPopup, heroData, allPropValue)
end)
Util.SetGray(go.gameObject, curHeroHp <= 0 )
go.gameObject:SetActive(true)
else
go.gameObject:SetActive(false)
end
end
-- for i = 1, this.roleGrid.transform.childCount do
-- Util.AddParticleSortLayer(this.roleGrid.transform:GetChild(i - 1).gameObject, self.sortingOrder - orginLayer2)
-- end
-- orginLayer2 = selfsortingOrder
-- selfsortingOrder = self.sortingOrder
2020-05-09 13:31:21 +08:00
end
function this.OnSortingOrderChange(self)
for i = 1, this.roleGrid.transform.childCount do
2020-07-28 15:06:47 +08:00
Util.AddParticleSortLayer(this.roleGrid.transform:GetChild(i - 1).gameObject, self.sortingOrder - selfsortingOrder)
end
selfsortingOrder = self.sortingOrder
end
2020-05-09 13:31:21 +08:00
-- 根据物品列表数据显示物品
function this.SetItemShow(drop)
if drop==nil then return end
local itemDataList = BagManager.GetItemListFromTempBag(drop)
Util.ClearChild(this.awardGrid.transform)
for i = 1, #itemDataList do
local go = SubUIManager.Open(SubUIConfig.ItemView, this.awardGrid.transform)
local item = itemDataList[i]
go:OnOpen(true, item, 1, true, true,false,this.selfsortingOrder)
if itemDataList[i].itemType==1 then
Util.AddOnceClick(itemIcon, function()
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,itemDataList[i].backData.itemId)
end)
elseif itemDataList[i].itemType==2 then
Util.AddOnceClick(itemIcon, function()
Log("itemDataList[i].backData "..itemDataList[i].backData.equipId)
UIManager.OpenPanel(UIName.RewardEquipSingleShowPopup,itemDataList[i].backData)
end)
elseif itemDataList[i].itemType==3 then
Util.AddOnceClick(itemIcon, function()
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,itemDataList[i].backData)
end)
end
end
end
--界面关闭时调用(用于子类重写)
function BattleEndPanel:OnClose()
if callBack then callBack() end
end
--界面销毁时调用(用于子类重写)
function BattleEndPanel:OnDestroy()
end
2020-06-23 18:36:24 +08:00
return BattleEndPanel