miduo_client/Assets/ManagedResources/~Lua/Modules/Guild/DeathPos/DeathPosPanel.lua

215 lines
8.4 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
----- 公会十绝阵主面板 -----
2020-05-09 13:31:21 +08:00
require("Base/BasePanel")
local DeathPosPanel = Inherit(BasePanel)
local this = DeathPosPanel
local deathPathInfo=nil
2020-05-15 16:52:35 +08:00
local guildWarConfig=ConfigManager.GetConfig(ConfigName.GuildWarConfig)
2020-06-13 11:47:13 +08:00
local _image={"s_shijuezhen_zhanlingbiao","s_shijuezhen_zhanlingbiao_01"}--公会旗帜 1是别人公会 2自己公会
2020-08-06 15:14:47 +08:00
local orginLayer = 0
local orginLayer2 = 0
2020-06-13 11:47:13 +08:00
local d={ --各阵位置信息
[1]={pos={-33,645}},
[2]={pos={-364,525}},
[3]={pos={251,483}},
[4]={pos={-174,314}},
[5]={pos={344,188}},
[6]={pos={0,17}},
[7]={pos={355,-124}},
[8]={pos={-342,-231}},
[9]={pos={291,-576}},
[10]={pos={-355,-666}},
}
local preList={} --各阵预设列表
2020-05-09 13:31:21 +08:00
function DeathPosPanel:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
this.panel=Util.GetGameObject(this.gameObject,"Panel")
2020-06-13 11:47:13 +08:00
this.overTime=Util.GetGameObject(this.panel,"OverTime/Text"):GetComponent("Text")--挑战结束时间
2020-05-09 13:31:21 +08:00
this.battleTime=Util.GetGameObject(this.panel,"BattleTime"):GetComponent("Text")--挑战剩余次数
this.upBtns=Util.GetGameObject(this.panel,"UpBtns")
this.rewardBtn=Util.GetGameObject(this.upBtns,"RewardBtn")
2020-06-03 19:09:01 +08:00
this.rewardBtnRedPoint=Util.GetGameObject(this.rewardBtn,"redPoint")
2020-05-09 13:31:21 +08:00
this.rankBtn=Util.GetGameObject(this.upBtns,"RankBtn")
this.helpBtn=Util.GetGameObject(this.panel,"HelpBtn")
this.helpPosition=this.helpBtn:GetComponent("RectTransform").localPosition
this.backBtn=Util.GetGameObject(this.panel,"BackBtn")
2020-06-13 11:47:13 +08:00
this.content=Util.GetGameObject(this.panel,"Content")
this.pre=Util.GetGameObject(this.content,"Pre")
2020-05-09 13:31:21 +08:00
end
function DeathPosPanel:BindEvent()
Util.AddClick(this.backBtn,function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
Util.AddClick(this.helpBtn,function()
2020-05-15 16:52:35 +08:00
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.GuildTenPos,this.helpPosition.x,this.helpPosition.y)
2020-05-09 13:31:21 +08:00
end)
--奖励弹窗
Util.AddClick(this.rewardBtn,function()
UIManager.OpenPanel(UIName.DeathPosRewardPopup)
end)
--排行弹窗
Util.AddClick(this.rankBtn,function()
UIManager.OpenPanel(UIName.DeathPosRankPopup)
end)
2020-06-03 19:09:01 +08:00
if DeathPosManager.status== DeathPosStatus.Reward then
BindRedPointObject(RedPointType.Guild_DeathPos,this.rewardBtnRedPoint)
2020-06-08 13:57:30 +08:00
else
this.rewardBtnRedPoint.gameObject:SetActive(false)
2020-06-03 19:09:01 +08:00
end
2020-05-09 13:31:21 +08:00
end
function DeathPosPanel:AddListener()
2020-05-25 19:16:23 +08:00
Game.GlobalEvent:AddEvent(GameEvent.Guild.RefreshDeathPosStatus, this.RefreshPanel) --阶段切换
Game.GlobalEvent:AddEvent(GameEvent.Guild.RefreshFirstChangeData, this.RefreshGuildInfo)
2020-05-09 13:31:21 +08:00
end
function DeathPosPanel:RemoveListener()
2020-05-11 09:38:52 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.Guild.RefreshDeathPosStatus, this.RefreshPanel)
2020-05-25 19:16:23 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.Guild.RefreshFirstChangeData, this.RefreshGuildInfo)
2020-05-09 13:31:21 +08:00
end
function DeathPosPanel:OnOpen(...)
end
function DeathPosPanel:OnShow()
2020-06-03 19:09:01 +08:00
-- if DeathPosManager.status== DeathPosStatus.Reward then
2020-08-06 15:14:47 +08:00
CheckRedPointStatus(RedPointType.Guild_DeathPos)
2020-06-03 19:09:01 +08:00
-- end
2020-05-09 13:31:21 +08:00
this.RefreshPanel()
2020-07-30 16:37:58 +08:00
Util.SetParticleSortLayer(Util.GetGameObject(this.panel,"Effect_UI_changjing_ShijueZhen_(Zhong)"), self.sortingOrder)
2020-08-06 15:14:47 +08:00
end
function DeathPosPanel:OnSortingOrderChange()
2020-07-30 16:37:58 +08:00
Util.SetParticleSortLayer(Util.GetGameObject(this.panel,"Effect_UI_changjing_ShijueZhen_(Zhong)"), self.sortingOrder)
2020-05-09 13:31:21 +08:00
end
function DeathPosPanel:OnClose()
if this.timer then
this.timer:Stop()
this.timer=nil
end
end
function DeathPosPanel:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-06-03 19:09:01 +08:00
if DeathPosManager.status== DeathPosStatus.Reward then
ClearRedPointObject(RedPointType.Guild_DeathPos,this.rewardBtnRedPoint)
end
2020-06-13 11:47:13 +08:00
preList={}
2020-05-09 13:31:21 +08:00
end
--刷新面板
function this.RefreshPanel()
2020-05-11 09:38:52 +08:00
if DeathPosManager.status==DeathPosStatus.Close then
this:ClosePanel()
return
end
2020-05-15 16:52:35 +08:00
this.battleTime.gameObject:SetActive(DeathPosManager.status==DeathPosStatus.Fight)
2020-06-13 11:47:13 +08:00
for i = 1, 10 do
local o=preList[i]
if not o then
o=newObjToParent(this.pre,this.content.transform)
o.name="Pre"..i
preList[i]=o
end
2021-03-31 14:25:43 +08:00
local guildName=Util.GetGameObject(o,"Guild/mask/GuildName"):GetComponent("Text")
2020-06-13 11:47:13 +08:00
local posName=Util.GetGameObject(o,"Name/Text"):GetComponent("Image")
2021-03-31 14:25:43 +08:00
local serverName=Util.GetGameObject(o,"serverName/Text"):GetComponent("Text")
serverName.text=""
2020-06-13 11:47:13 +08:00
guildName.text=""
2021-04-21 13:12:04 +08:00
posName.sprite=this.spLoader:LoadSprite(guildWarConfig[i].Pic)--guildWarConfig[i].Name
2020-06-13 11:47:13 +08:00
preList[i].transform.localPosition=Vector2.New(d[i].pos[1],d[i].pos[2])
2021-08-12 14:40:12 +08:00
Util.GetGameObject(o,"Guild"):SetActive(false)
Util.GetGameObject(o,"serverName"):SetActive(false)
2020-06-13 11:47:13 +08:00
end
2021-08-12 10:55:05 +08:00
2021-03-31 14:25:43 +08:00
local colorValue = Color.New(1,1,1,0)
DoTween.To(
DG.Tweening.Core.DOGetter_float( function () return 0 end),
DG.Tweening.Core.DOSetter_float(function (progress)
Log(progress)
colorValue.a = progress
for i = 1, 10 do
Util.GetGameObject(preList[i],"Name/Text"):GetComponent("Image").color = colorValue
end
end),
1, 0.5):SetEase(Ease.Linear):OnComplete(function() end)
2020-05-09 13:31:21 +08:00
NetManager.GetDeathPathInfoResponse(function(msg)
2020-05-11 09:38:52 +08:00
if DeathPosManager.status==DeathPosStatus.Reward then
2021-04-09 12:26:35 +08:00
this.overTime.text=Language[11029]
2020-05-15 16:52:35 +08:00
elseif DeathPosManager.status==DeathPosStatus.Close then
2021-04-09 12:26:35 +08:00
this.overTime.text=Language[11030]
2020-05-11 09:38:52 +08:00
else
this.TimeCountDown(msg.overTime)
end
2021-04-09 12:26:35 +08:00
DeathPosManager.rewardTimeTip= Language[11031]..GetTimeMonthDayMinBySeconds(msg.overTime)..Language[11032]
--【线上问题】十绝阵挑战次数显示负数 < 0 and 0 or (DeathPosManager.maxBattleTime-msg.challengeCount)
DeathPosManager.battleTime = (DeathPosManager.maxBattleTime-msg.challengeCount) < 0 and 0 or (DeathPosManager.maxBattleTime-msg.challengeCount)
2021-04-09 12:26:35 +08:00
this.battleTime.text=Language[10520].. DeathPosManager.battleTime
2021-08-28 17:21:36 +08:00
for k,v in ipairs(msg.infos) do
LogGreen("v.pathId:"..v.pathId.." v.guildName:"..v.guildName)
end
2020-05-25 19:16:23 +08:00
DeathPosManager.SetGuildInfoData(msg.infos)
2020-05-09 13:31:21 +08:00
--设置公会上了哪个阵 显示公会名称
2020-05-25 19:16:23 +08:00
this.RefreshGuildInfo()
2020-05-09 13:31:21 +08:00
end)
--各阵型点击事件
2020-06-13 11:47:13 +08:00
for i = 1, #preList do
Util.AddOnceClick(preList[i],function()
2021-03-31 14:25:43 +08:00
local guildName=Util.GetGameObject(preList[i],"Guild/mask/GuildName"):GetComponent("Text")
2021-07-29 12:09:03 +08:00
local serverName=Util.GetGameObject(preList[i],"serverName/Text"):GetComponent("Text")
UIManager.OpenPanel(UIName.DeathPosInfoPanel,i,guildName.text,serverName.text)
2020-05-09 13:31:21 +08:00
end)
end
end
2020-05-25 19:16:23 +08:00
--倒计时
2020-05-09 13:31:21 +08:00
function this.TimeCountDown(timeDown)
if this.timer then
this.timer:Stop()
this.timer = nil
end
2021-04-09 12:26:35 +08:00
this.overTime.text = Language[10023]..TimeToHMS(timeDown-GetTimeStamp())
2020-05-09 13:31:21 +08:00
this.timer = Timer.New(function()
if timeDown < 1 then
this.timer:Stop()
this.timer = nil
--结束逻辑
2020-05-15 16:52:35 +08:00
this.RefreshPanel()
2020-05-09 13:31:21 +08:00
return
end
2021-04-09 12:26:35 +08:00
this.overTime.text = Language[10023]..TimeToHMS(timeDown-GetTimeStamp())
2020-05-09 13:31:21 +08:00
end, 1, -1, true)
this.timer:Start()
end
2020-05-25 19:16:23 +08:00
--刷新公会信息
function this.RefreshGuildInfo()
local data=DeathPosManager.GetGuildInfoData()
2020-06-13 11:47:13 +08:00
for i = 1, #preList do
2020-05-25 19:16:23 +08:00
for key, value in pairs(data) do
if i==value.pathId then
2020-06-13 11:47:13 +08:00
local guild=Util.GetGameObject(preList[i],"Guild")
2021-08-12 11:36:48 +08:00
local serverDi = Util.GetGameObject(preList[i],"serverName")
local serverName=Util.GetGameObject(serverDi,"Text"):GetComponent("Text")
2020-05-25 19:16:23 +08:00
local guildImage=guild:GetComponent("Image")
2021-03-31 14:25:43 +08:00
local guildName=Util.GetGameObject(preList[i],"Guild/mask/GuildName"):GetComponent("Text")
2020-05-25 19:16:23 +08:00
guild:SetActive(true)
2021-07-29 12:09:03 +08:00
if value.serverName and value.serverName ~= "" then
serverName.text = value.serverName
2021-08-12 11:36:48 +08:00
serverDi:SetActive(true)
2021-07-29 12:09:03 +08:00
else
2021-08-12 11:36:48 +08:00
serverDi:SetActive(false)
2021-07-29 12:09:03 +08:00
serverName.text = ""
end
2020-05-25 19:16:23 +08:00
guildName.text=value.guildName
--如果是自己的公会
2021-04-21 13:12:04 +08:00
guildImage.sprite= value.gid==PlayerManager.familyId and this.spLoader:LoadSprite(_image[2]) or this.spLoader:LoadSprite(_image[1])
2020-05-25 19:16:23 +08:00
end
end
end
end
2020-06-23 18:36:24 +08:00
return DeathPosPanel