196 lines
5.7 KiB
Lua
196 lines
5.7 KiB
Lua
--- 血战地图面板的UI模块
|
|
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
|
--- Created by aaa.
|
|
--- DateTime: 2019/9/7 5:56
|
|
---
|
|
local this ={}
|
|
this.rankInfo = {}
|
|
this.lastRankInfo = {}
|
|
local mapFightPanel
|
|
|
|
|
|
function this.InitComponent(parent, mainPanel)
|
|
this.spLoader = SpriteLoader.New()
|
|
mapFightPanel = mainPanel
|
|
this.BtnBack = Util.GetGameObject(parent, "rightUpRoot/btnBack")
|
|
this.btnChat = Util.GetGameObject(parent, "leftDownRoot/btnChat")
|
|
this.emoList = Util.GetGameObject(parent, "leftDownRoot/emotionList")
|
|
-- 玩家排行版榜数据
|
|
this.rankComp = {}
|
|
for i = 1, 10 do
|
|
this.rankComp[i] = Util.GetGameObject(parent, "rankInfoRoot/root/rankInfo_" .. i)
|
|
end
|
|
|
|
-- 战斗时间
|
|
this.mapTime = Util.GetGameObject(parent, "leftDownRoot/Time"):GetComponent("Text")
|
|
|
|
-- 死亡复活倒计时
|
|
this.deadPopup = Util.GetGameObject(parent, "RevivePanel")
|
|
this.deadTime = Util.GetGameObject(parent, "RevivePanel/bg/Time"):GetComponent("Text")
|
|
|
|
this.btnChat:SetActive(false)
|
|
end
|
|
|
|
local state = true
|
|
function this.BindEvent()
|
|
Util.AddClick(this.BtnBack, function ()
|
|
Log("----GM请求退出血战-----")
|
|
NetManager.GMEvent("17#17#17", function ()
|
|
|
|
end)
|
|
end)
|
|
|
|
Util.AddClick(this.btnChat, function ()
|
|
state = not state
|
|
this.emoList:SetActive(state)
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
function this.AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.Room.GameStart, this.GameStart)
|
|
Game.GlobalEvent:AddEvent(GameEvent.MapFight.RankInfoChange, this.RefreshRankInfo)
|
|
Game.GlobalEvent:AddEvent(GameEvent.MapFight.GameEnd, this.OnGameEnd)
|
|
Game.GlobalEvent:AddEvent(GameEvent.MapFight.BuffAdd, this.BuffAdd)
|
|
Game.GlobalEvent:AddEvent(GameEvent.MapFight.BackMain, this.OnBackHome)
|
|
end
|
|
|
|
function this.RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Room.GameStart, this.GameStart)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.MapFight.RankInfoChange, this.RefreshRankInfo)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.MapFight.GameEnd, this.OnGameEnd)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.MapFight.BuffAdd, this.BuffAdd)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.MapFight.BackMain, this.OnBackHome)
|
|
end
|
|
|
|
function this.OnOpen()
|
|
this.RefreshRankInfo()
|
|
-- 启动临时定时器
|
|
this.StartConutTime()
|
|
end
|
|
|
|
function this.OnShow()
|
|
|
|
end
|
|
|
|
-- 开始游戏
|
|
function this.GameStart()
|
|
UIManager.OpenPanel(UIName.TrialBossTipPopup, 7)
|
|
end
|
|
|
|
--- ===========================================================================
|
|
-- 刷新排行榜数据
|
|
function this.RefreshRankInfo()
|
|
Log("更新排行信息")
|
|
local playerInfo = FightUIManager.ReStoreRankInfo()
|
|
|
|
local index = 1
|
|
-- 设置排行数据
|
|
for i, v in pairs(playerInfo) do
|
|
this.SetRankData(index, v)
|
|
index = index + 1
|
|
end
|
|
end
|
|
|
|
-- 设置组件数据
|
|
function this.SetRankData(index, info)
|
|
local name = info.name
|
|
local killNum = info.killNum
|
|
local nineNum = info.nineralNum
|
|
|
|
local killCol = info.id == PlayerManager.uid and "F87C31FF" or "EEDCABFF"
|
|
local color = info.id == PlayerManager.uid and "E2BA31FF" or "EEDCABFF"
|
|
|
|
Util.GetGameObject(this.rankComp[index], "name"):GetComponent("Text").text = string.format("<color=#%s>%s</color>", color, name)
|
|
Util.GetGameObject(this.rankComp[index], "killNum"):GetComponent("Text").text = string.format("<color=#%s>%s</color>", killCol, killNum)
|
|
Util.GetGameObject(this.rankComp[index], "resNum"):GetComponent("Text").text = string.format("<color=#%s>%s</color>", color, nineNum)
|
|
this.rankComp[index]:SetActive(true)
|
|
|
|
local mask = Util.GetGameObject(this.rankComp[index], "myInfoMask")
|
|
mask:SetActive(info.id == PlayerManager.uid)
|
|
end
|
|
|
|
function this.StartConutTime()
|
|
this.mapTime.text = ""
|
|
if not this.timer then
|
|
local index = FightUIManager.remainTime
|
|
this.timer = Timer.New(function()
|
|
index = index - 1
|
|
this.mapTime.text = SetTimeFormation(index)
|
|
if index == 0 then
|
|
this.timer:Stop()
|
|
end
|
|
end, 1, -1, true)
|
|
this.timer:Start()
|
|
end
|
|
end
|
|
|
|
-- 游戏结束显示结算
|
|
function this.OnGameEnd()
|
|
UIManager.OpenPanel(UIName.MapFightResultPopup)
|
|
end
|
|
|
|
-- 监听角色死亡
|
|
function this.BuffAdd(buff)
|
|
if buff.target ~= PlayerManager.uid then return end
|
|
if buff.type == 4 then
|
|
-- 终于等到你死了
|
|
this.OnPlayerDead(buff.endTime - buff.startTime)
|
|
end
|
|
end
|
|
|
|
function this.OnPlayerDead(deadTime)
|
|
this.deadPopup:SetActive(true)
|
|
local index = deadTime
|
|
|
|
local t
|
|
this.deadTime.text = deadTime
|
|
t = Timer.New(function ()
|
|
index = index - 1
|
|
local str = ""
|
|
if index > 3 then
|
|
str = string.format("<color=#FFD901FF>%s</color>", index)
|
|
elseif index > 0 and index <= 3 then
|
|
str = string.format("<color=#FD0000FF>%s</color>", index)
|
|
end
|
|
|
|
if index == 0 then
|
|
t:Stop()
|
|
this.deadPopup:SetActive(false)
|
|
end
|
|
|
|
this.deadTime.text = str
|
|
end, 1, deadTime, true)
|
|
t:Start()
|
|
end
|
|
|
|
|
|
--- =======================================================================================
|
|
|
|
-- 返回主界面
|
|
function this.OnBackHome()
|
|
local triggerCallBack
|
|
triggerCallBack = function (panelType, panel)
|
|
if panelType == UIName.MapFightPanel then
|
|
mapFightPanel.Dispose()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack)
|
|
end
|
|
end
|
|
Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, triggerCallBack)
|
|
SwitchPanel.OpenPanel(UIName.MainPanel)
|
|
end
|
|
|
|
|
|
function this.Dispose()
|
|
if this.timer then
|
|
this.timer:Stop()
|
|
this.timer = nil
|
|
end
|
|
|
|
FightUIManager.playerInfo = {}
|
|
|
|
end
|
|
|
|
|
|
return this |