319 lines
14 KiB
Lua
319 lines
14 KiB
Lua
require("Base/BasePanel")
|
||
JumpServerHightLadderPanel = Inherit(BasePanel)
|
||
local this = JumpServerHightLadderPanel
|
||
local datas = {}
|
||
local liveNodeList = {}
|
||
local goList = {}
|
||
local stage = 0
|
||
--初始化组件(用于子类重写)
|
||
function JumpServerHightLadderPanel:InitComponent()
|
||
this.timeText = Util.GetGameObject(self.gameObject, "titleObg/timeImage/Text")
|
||
this.helpBtn = Util.GetGameObject(self.gameObject,"titleObg/HelpBtn")
|
||
this.helpPos = this.helpBtn:GetComponent("RectTransform").localPosition
|
||
this.sortBtn = Util.GetGameObject(self.gameObject,"rightBtns/sortBtn")
|
||
this.rewardSortBtn = Util.GetGameObject(self.gameObject,"rightBtns/rewardSortBtn")
|
||
this.recordBtn = Util.GetGameObject(self.gameObject,"rightBtns/recordBtn")
|
||
this.shopBtn = Util.GetGameObject(self.gameObject,"rightBtns/shopBtn")
|
||
this.formationBtn = Util.GetGameObject(self.gameObject,"rightBtns/formationBtn")
|
||
this.backBtn = Util.GetGameObject(self.gameObject, "backBtn")
|
||
|
||
-- this.singlePre = Util.GetGameObject(self.gameObject, "middleObg/singlePre")
|
||
-- this.rect = Util.GetGameObject(self.gameObject, "middleObg/rect")
|
||
-- this.scrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.rect.transform,this.singlePre,
|
||
-- nil,Vector2.New(1079.9,1533.4),1,1,Vector2.New(0,0))
|
||
-- this.scrollView.moveTween.MomentumAmount = 1
|
||
-- this.scrollView.moveTween.Strength = 2
|
||
for i = 1, 4 do
|
||
goList[i] = Util.GetGameObject(self.gameObject, "middleObg/rect/singlePre (".. i ..")")
|
||
end
|
||
|
||
this.mySortText = Util.GetGameObject(self.gameObject, "endObg/mySortText")
|
||
this.sdBtn = Util.GetGameObject(self.gameObject,"endObg/sdBtn")
|
||
this.numInfo = Util.GetGameObject(self.gameObject, "endObg/numInfo")
|
||
Util.GetGameObject(self.gameObject,"endObg/sdBtn/Text"):GetComponent("Text").text = "扫 荡"
|
||
Util.GetGameObject(self.gameObject, "endObg/numInfo/mianfeiText"):GetComponent("Text").text = "免费次数:"
|
||
this.mianfeiText = Util.GetGameObject(self.gameObject, "endObg/numInfo/mianfeiText/Text"):GetComponent("Text")
|
||
Util.GetGameObject(self.gameObject, "endObg/numInfo/buyText"):GetComponent("Text").text = "购买次数:"
|
||
this.buyText = Util.GetGameObject(self.gameObject, "endObg/numInfo/buyText/Text"):GetComponent("Text")
|
||
this.addNumBtn = Util.GetGameObject(self.gameObject,"endObg/numInfo/addNumBtn/click")
|
||
this.canPlayerTipText = Util.GetGameObject(self.gameObject, "endObg/canPlayerTipText")
|
||
|
||
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform)
|
||
end
|
||
|
||
--绑定事件(用于子类重写)
|
||
function JumpServerHightLadderPanel:BindEvent()
|
||
Util.AddClick(this.backBtn,function()
|
||
self:ClosePanel()
|
||
end)
|
||
Util.AddClick(this.helpBtn,function()
|
||
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.JumpServerHeightLadder,this.helpPos.x,this.helpPos.y)
|
||
end)
|
||
Util.AddClick(this.sortBtn,function()
|
||
UIManager.OpenPanel(UIName.RankingSingleListPanel,rankKingList[15])
|
||
end)
|
||
Util.AddClick(this.rewardSortBtn,function()
|
||
UIManager.OpenPanel(UIName.JumpServerHightLadderRewardSortPanel,FUNCTION_OPEN_TYPE.JumpServer)
|
||
end)
|
||
Util.AddClick(this.recordBtn,function()
|
||
UIManager.OpenPanel(UIName.JumpServerHightLadderRecordPopup)
|
||
end)
|
||
Util.AddClick(this.shopBtn,function()
|
||
JumpManager.GoJump(20005)
|
||
end)
|
||
Util.AddClick(this.formationBtn,function()
|
||
-- if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.JumpServer) then
|
||
-- PopupTipPanel.ShowTip(Language[10082])
|
||
-- return
|
||
-- end
|
||
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.JUMPSERVER_HIGHTLADDER)
|
||
end)
|
||
|
||
Util.AddClick(this.sdBtn,function()
|
||
--条件判断
|
||
this.BuyVipFun(1,function()
|
||
--直接战斗
|
||
JumpServerManager.StarFightHightLadder(nil,1,function(msg)
|
||
this.RefreshBuyNum()
|
||
this.OnShowPanel()
|
||
end)
|
||
end)
|
||
|
||
end)
|
||
Util.AddClick(this.addNumBtn,function()
|
||
this.BuyVipFun(2,function()
|
||
this.RefreshBuyNum()
|
||
end)
|
||
end)
|
||
end
|
||
|
||
--添加事件监听(用于子类重写)
|
||
function JumpServerHightLadderPanel:AddListener()
|
||
Game.GlobalEvent:AddEvent(GameEvent.JumpServerHeightLadder.UpdateHeightLadderPanel, this.OnShowPanel)
|
||
end
|
||
|
||
--移除事件监听(用于子类重写)
|
||
function JumpServerHightLadderPanel:RemoveListener()
|
||
Game.GlobalEvent:RemoveEvent(GameEvent.JumpServerHeightLadder.UpdateHeightLadderPanel, this.OnShowPanel)
|
||
end
|
||
|
||
--跨服
|
||
function JumpServerHightLadderPanel:OnOpen()
|
||
this.UpView:OnOpen({showType = UpViewOpenType.ShowRight, panelType = PanelType.Main})
|
||
JumpServerManager.GetWorldArenaInfoRequest()
|
||
end
|
||
|
||
--界面打开时调用(用于子类重写)
|
||
function JumpServerHightLadderPanel:OnShow()
|
||
end
|
||
|
||
function this:OnSortingOrderChange()
|
||
-- Util.AddParticleSortLayer(this.effect, self.sortingOrder - orginLayer)
|
||
end
|
||
function this.OnShowPanel()
|
||
stage = JumpServerManager.GetHightLadderDatastage()
|
||
datas = JumpServerManager.GetHightLadderDataArenaInfo()
|
||
LogPink("datas.arenaEnemys "..#datas.arenaEnemys)
|
||
for i = 1, 4 do
|
||
this.ShowSingleData(goList[i],datas.arenaEnemys[i],i)
|
||
end
|
||
|
||
|
||
this.canPlayerTipText:SetActive(false)
|
||
this.mySortText:SetActive(false)
|
||
this.sdBtn:SetActive(false)
|
||
this.numInfo:SetActive(false)
|
||
local timeStr = ""
|
||
--1 未开始 2 战斗阶段 3 膜拜阶段
|
||
if stage == JumpServer_Stage.NoStar then
|
||
this.canPlayerTipText:SetActive(true)
|
||
this.canPlayerTipText:GetComponent("Text").text = "本服千战主胜台前100名可以参加"
|
||
timeStr = "后开始"
|
||
elseif stage == JumpServer_Stage.Attack then
|
||
this.mySortText:SetActive(true)
|
||
this.sdBtn:SetActive(true)
|
||
this.numInfo:SetActive(true)
|
||
local myRank = JumpServerManager.GetHightLadderDataMyRank() <= 1000 and JumpServerManager.GetHightLadderDataMyRank() or "1000+"
|
||
this.mySortText:GetComponent("Text").text = "我的排名:".. myRank
|
||
this.RefreshBuyNum()
|
||
timeStr = "后结束"
|
||
elseif stage == JumpServer_Stage.End then
|
||
local myRank = JumpServerManager.GetHightLadderDataMyRank() <= 1000 and JumpServerManager.GetHightLadderDataMyRank() or "1000+"
|
||
this.mySortText:GetComponent("Text").text = "我的排名:".. myRank
|
||
this.canPlayerTipText:GetComponent("Text").text = "已通过邮件发放排名奖励"
|
||
timeStr = "后开始"
|
||
end
|
||
this.RemainTimeDown(this.timeText,this.timeText:GetComponent("Text"),JumpServerManager.GetHightLadderDataEndTime(),timeStr)
|
||
end
|
||
function this.RefreshBuyNum()
|
||
this.mianfeiText.text = JumpServerManager.GetCanBattleCount()
|
||
this.buyText.text = JumpServerManager.GetCanBuyBattleCount()
|
||
end
|
||
function this.ShowSingleData(go,data,i)
|
||
--data.arenaEnemys.personInfo.name
|
||
LogPink("data "..data.personInfo.uid)
|
||
local playerInfo = Util.GetGameObject(go, "playerInfo")
|
||
local sdBtn = Util.GetGameObject(go, "sdBtn")
|
||
local sdBtnRedPoint = Util.GetGameObject(go, "sdBtn/redPoint")
|
||
local liveDef = Util.GetGameObject(go, "liveDef")
|
||
playerInfo:SetActive(false)
|
||
sdBtn:SetActive(false)
|
||
liveDef:SetActive(false)
|
||
sdBtnRedPoint:SetActive(false)
|
||
--1 未开始 2 战斗阶段 3 膜拜阶段
|
||
if stage == JumpServer_Stage.NoStar then
|
||
sdBtn:SetActive(true)
|
||
liveDef:SetActive(true)
|
||
Util.GetGameObject(go, "sdBtn/Text"):GetComponent("Text").text = "虚以待位"
|
||
local str = i % 2 > 0 and "s_sanjiechumo_ren_1" or "s_sanjiechumo_ren_2"
|
||
Util.GetGameObject(go, "liveDef"):GetComponent("Image").sprite = Util.LoadSprite(str)
|
||
Util.AddOnceClick(sdBtn,function()
|
||
|
||
end)
|
||
elseif stage == JumpServer_Stage.Attack and data then
|
||
playerInfo:SetActive(true)
|
||
sdBtn:SetActive(true)
|
||
Util.GetGameObject(go, "sdBtn/Text"):GetComponent("Text").text = "挑 战"
|
||
Util.GetGameObject(go, "playerInfo/name/nameText"):GetComponent("Text").text = data.personInfo.name
|
||
Util.GetGameObject(go, "playerInfo/warPower/powerBtn/value"):GetComponent("Text").text = data.personInfo.totalForce
|
||
Util.GetGameObject(go, "playerInfo/warPower/Text"):GetComponent("Text").text = "第".. data.personInfo.rank .."名"
|
||
local live = Util.GetGameObject(go, "playerInfo/live")
|
||
this.LocadPersonInfoLive(go,NameManager.roleSex,live.transform)
|
||
sdBtnRedPoint:SetActive(JumpServerManager.GetCanBattleCount() > 0)
|
||
LogPink("0000000000")
|
||
Util.AddOnceClick(sdBtn,function()
|
||
LogPink("111111111111111")
|
||
this.BuyVipFun(1,function()
|
||
--直接战斗
|
||
LogPink("22222222")
|
||
JumpServerManager.StarFightHightLadder(data.personInfo,0,function(msg)
|
||
this.RefreshBuyNum()
|
||
this.OnShowPanel()
|
||
end)
|
||
end)
|
||
end)
|
||
|
||
elseif stage == JumpServer_Stage.End and data then
|
||
playerInfo:SetActive(true)
|
||
sdBtn:SetActive(true)
|
||
Util.GetGameObject(go, "sdBtn/Text"):GetComponent("Text").text = data.personInfo.worshipTime < 0 and "膜 拜" or data.personInfo.worshipTime
|
||
Util.GetGameObject(go, "playerInfo/name/nameText"):GetComponent("Text").text = data.personInfo.name
|
||
Util.GetGameObject(go, "playerInfo/warPower/powerBtn/value"):GetComponent("Text").text = data.personInfo.totalForce
|
||
Util.GetGameObject(go, "playerInfo/warPower/Text"):GetComponent("Text").text = "第".. data.personInfo.rank .."名"
|
||
local live = Util.GetGameObject(go, "playerInfo/live")
|
||
this.LocadPersonInfoLive(go,NameManager.roleSex,live.transform)
|
||
sdBtnRedPoint:SetActive(data.personInfo.worshipTime < 0)
|
||
Util.AddOnceClick(sdBtn,function()
|
||
if data.personInfo.worshipTime < 0 then
|
||
JumpServerManager.GetWorldArenaProudRequest(data.personInfo,function(msg)
|
||
this.OnShowPanel()
|
||
end)
|
||
end
|
||
end)
|
||
|
||
end
|
||
end
|
||
function this.LocadPersonInfoLive(go,roleSex,live)
|
||
if liveNodeList[go] then
|
||
poolManager:UnLoadLive(liveNodeList[go].name, liveNodeList[go].go, PoolManager.AssetType.GameObject)
|
||
end
|
||
local npc = roleSex == ROLE_SEX.BOY and "live2d_npc_map" or "live2d_npc_map_nv"
|
||
local scale = roleSex == ROLE_SEX.BOY and Vector3.one * 0.26 or Vector3.one * 0.16
|
||
local live2d = poolManager:LoadLive(npc, live,scale, Vector3.zero)
|
||
local SkeletonGraphic = live2d:GetComponent("SkeletonGraphic")
|
||
if SkeletonGraphic then
|
||
SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true)
|
||
SkeletonGraphic.transform.localEulerAngles = Vector3.New(0, 0, 0)
|
||
end
|
||
liveNodeList[go] = {name=npc, go=live2d}
|
||
end
|
||
--刷新倒计时显示
|
||
function this.RemainTimeDown(_timeTextExpertgo,_timeTextExpert,timeDown,str)
|
||
if timeDown > 0 then
|
||
if _timeTextExpertgo then
|
||
_timeTextExpertgo:SetActive(true)
|
||
end
|
||
if _timeTextExpert then
|
||
_timeTextExpert.text = this.TimeStampToDateString(timeDown)..str
|
||
end
|
||
if this.timer then
|
||
this.timer:Stop()
|
||
this.timer = nil
|
||
end
|
||
this.timer = Timer.New(function()
|
||
if _timeTextExpert then
|
||
_timeTextExpert.text = this.TimeStampToDateString(timeDown)..str
|
||
end
|
||
if timeDown < 0 then
|
||
if _timeTextExpertgo then
|
||
_timeTextExpertgo:SetActive(false)
|
||
end
|
||
this.timer:Stop()
|
||
this.timer = nil
|
||
end
|
||
timeDown = timeDown - 1
|
||
end, 1, -1, true)
|
||
this.timer:Start()
|
||
else
|
||
if _timeTextExpertgo then
|
||
_timeTextExpertgo:SetActive(false)
|
||
end
|
||
end
|
||
end
|
||
|
||
function this.TimeStampToDateString(second)
|
||
local day = math.floor(second / (24 * 3600))
|
||
local minute = math.floor(second / 60) % 60
|
||
local sec = second % 60
|
||
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
|
||
return string.format(Language[10548],day, hour, minute, sec)
|
||
end
|
||
|
||
function this.BuyVipFun(type,fun)
|
||
if JumpServerManager.GetCanBattleCount() <= 0 then --今日已无剩余次数!
|
||
if JumpServerManager.GetCanBuyBattleCount() <= 0 then
|
||
PopupTipPanel.ShowTip(Language[12326])
|
||
else
|
||
--是否花费XX妖晶购买1次挑战次数并发起挑战?
|
||
if type == 1 then
|
||
local costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.FUNCTION_SHOP, JumpServerManager.shopGoodId, 1)
|
||
local itemName = ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name
|
||
if finalNum > BagManager.GetItemCountById(costId) then
|
||
PopupTipPanel.ShowTip(string.format(Language[11652],itemName))
|
||
return
|
||
end
|
||
MsgPanel.ShowTwo(string.format( Language[12327],finalNum,itemName), nil, function()
|
||
--买东西
|
||
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,JumpServerManager.shopGoodId,1,function()
|
||
PopupTipPanel.ShowTip(Language[12328])
|
||
PrivilegeManager.RefreshPrivilegeUsedTimes(PRIVILEGE_TYPE.JUMPSERVER_GIGHTLADDER_MIANFEINUM, 1)--更新特权
|
||
if fun then
|
||
fun ()
|
||
end
|
||
end)
|
||
end)
|
||
elseif type == 2 then
|
||
UIManager.OpenPanel(UIName.ShopBuyPopup, 7,10032)
|
||
end
|
||
end
|
||
else
|
||
if fun then
|
||
fun ()
|
||
end
|
||
end
|
||
|
||
end
|
||
|
||
--界面关闭时调用(用于子类重写)
|
||
function JumpServerHightLadderPanel:OnClose()
|
||
|
||
end
|
||
|
||
--界面销毁时调用(用于子类重写)
|
||
function JumpServerHightLadderPanel:OnDestroy()
|
||
for key, value in pairs(liveNodeList) do
|
||
poolManager:UnLoadLive(value.name, value.go, PoolManager.AssetType.GameObject)
|
||
end
|
||
end
|
||
|
||
return JumpServerHightLadderPanel |