| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414 |
- local BattleStatisticsPart = class("BattleStatisticsPart")
- local DelayTime = 10
- function BattleStatisticsPart:ctor()
- end
- function BattleStatisticsPart:InitGo(host,uiGo)
- self.host = host
- self.viewLua = CommonUtil.BindGridViewItem2Lua(self.host, "BattleStatistics", uiGo)
- end
- function BattleStatisticsPart:InitPanel()
- self.viewLua.btnQuit:SetActive(false)
- --延迟显示
- local bIsReplay = LuaBattleBridge.CurrentBattleIsPlayRecord()
- if not bIsReplay then
- local enBattleMode = LuaBattleBridge.CurrentBattleMode()
- local enSubMode = LuaBattleBridge.CurrentBattleSubMode()
- if enBattleMode == BattleMode.Normal then --巡游BOOS
- DelayTime = self:GetQuitShowDelay(Enum.TaskType.Level_Battle_Count)
- elseif enSubMode == BattleSubMode.ClimbingTower then --爬塔
- DelayTime = self:GetQuitShowDelay(Enum.TaskType.Climbing_Tower_Level)
- end
- if nil ~= DelayTime then
- self:StartTimer(function() self:ShowQuitBtn() end,{duration = DelayTime})
- end
- end
- self:RefreshSpeedStatus(true)
- end
- function BattleStatisticsPart:Show(mode,battleSubMode)
- self:InitPanel()
- self.hidePnl = false
- self.statisticsActorNodes = {}
- self.statisticsActorNodes[#self.statisticsActorNodes+1] = self.viewLua.playerNode1
- self.statisticsActorNodes[#self.statisticsActorNodes+1] = self.viewLua.playerNode2
- self.statisticsActorNodes[#self.statisticsActorNodes+1] = self.viewLua.playerNode3
- self.statisticsActorNodes[#self.statisticsActorNodes+1] = self.viewLua.playerNode4
- for i = 1, #self.statisticsActorNodes do
- self.statisticsActorNodes[i]:SetActive(false)
- end
-
- self.data = LuaBattleBridge.GetBattleStatistics(mode,battleSubMode)
- self:OnRefreshStatistics()
- self.viewLua:SetActive(true)
- self:AddEventListener()
- end
- --退出按钮
- function BattleStatisticsPart:ShowQuitBtn()
- local bIsShow = false
- local enBattleMode = LuaBattleBridge.CurrentBattleMode()
- local enSubMode = LuaBattleBridge.CurrentBattleSubMode()
- if enBattleMode == BattleMode.Normal then --巡游BOOS
- local ConditionValue = self:GetQuitShowCondition(Enum.TaskType.Level_Battle_Count)
- local curMapId,curLevelId = ManagerContainer.LuaBattleMgr:GetCurMapAndLevel() --当前关卡
- local curUniqueId = curMapId * 10000 + curLevelId
- if ConditionValue ~= nil and curUniqueId >= ConditionValue then
- bIsShow = true
- end
- elseif enSubMode == BattleSubMode.ClimbingTower then --爬塔
- local TwerLevle = ManagerContainer.DataMgr.TowerDataMgr:GetCurChallengeLevel()
- local ConditionValue = self:GetQuitShowCondition(Enum.TaskType.Climbing_Tower_Level)
- if ConditionValue ~= nil and TwerLevle >= ConditionValue then
- bIsShow = true
- end
- end
- self.viewLua.btnQuit:SetActive(bIsShow)
- end
- --退出按钮延迟时间获取
- function BattleStatisticsPart:GetQuitShowDelay(TaskType)
- local val = GlobalConfig.Instance:GetConfigStrValue(264)
- return self:ParseData(val,TaskType)
- end
- --退出按鈕條件
- function BattleStatisticsPart:GetQuitShowCondition(TaskType)
- local val = GlobalConfig.Instance:GetConfigStrValue(263)
- return self:ParseData(val,TaskType)
- end
- --解析數據
- function BattleStatisticsPart:ParseData(val,TaskType)
- if val == "" or val == nil then
- return nil
- end
-
- local ShowCondition = CommonUtil.DeserializeGlobalStrToTable(val)
- if ShowCondition[1][1] == "" or ShowCondition[1][1] == nil then
- return nil
- end
- if tonumber(ShowCondition[1][1]) == TaskType then
- return tonumber(ShowCondition[1][2])
- end
- if ShowCondition[2][1] == "" or ShowCondition[2][1] == nil then
- return nil
- end
- if tonumber(ShowCondition[2][1]) == TaskType then
- return tonumber(ShowCondition[2][2])
- end
-
- return nil
- end
- function BattleStatisticsPart:Hide()
- self:ResetData()
- self:RemoveEventListener()
- self:Clear()
- self.viewLua:SetActive(false)
- ManagerContainer.LuaUIMgr:CloseMessageBox("QuitBattleTip")
- end
- function BattleStatisticsPart:SetCanvasOrder(order)
- self.viewLua.canvas.sortingOrder = order
- end
- function BattleStatisticsPart:StartTimer(func, data)
- self:StopTimer()
- if data.isFrame then
- self.timer = FrameTimer.New(func, data.duration)
- else
- self.timer = Timer.New(func, data.duration)
- end
- self.timer:Start()
- end
- function BattleStatisticsPart:StopTimer()
- if self.timer then
- self.timer:Stop()
- self.timer = nil
- end
- end
- function BattleStatisticsPart:AddEventListener()
- ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.EID_Refresh_BattleStatistics,self,self.OnRefreshStatistics);
- ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.EID_Battle_UI_VISIBLE,self,self.OnUIPartVisible);
- ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.VIP_LV_CHANGED, self, self.OnVipLvChanged)
- ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.RUNE_SHOP_DATA_CHANGED, self, self.OnRuneShopDataChanged)
- ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.BATTLE_ACC_TIME_CHANGED, self, self.OnBattleAccTimeChanged)
- end
- function BattleStatisticsPart:RemoveEventListener()
- ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.EID_Refresh_BattleStatistics,self,self.OnRefreshStatistics);
- ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.EID_Battle_UI_VISIBLE,self,self.OnUIPartVisible);
- ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.VIP_LV_CHANGED, self, self.OnVipLvChanged)
- ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.RUNE_SHOP_DATA_CHANGED, self, self.OnRuneShopDataChanged)
- ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.BATTLE_ACC_TIME_CHANGED, self, self.OnBattleAccTimeChanged)
- end
- function BattleStatisticsPart:AddUIEventListener()
- self.host.uiBase:AddButtonEventListener(self.viewLua.btnSpeed.button,self, self.OnClickBtnSpeed)
- self.host.uiBase:AddButtonEventListener(self.viewLua.viewDetailBtn.button,self, self.OnClickOpenStatisticPage)
- self.host.uiBase:AddButtonEventListener(self.viewLua.hideBtn.button,self, self.OnClickHide)
- self.host.uiBase:AddButtonEventListener(self.viewLua.btnQuit.button,self, self.OnClickQuit)
- end
- function BattleStatisticsPart:OnClickBtnSpeed()
- if not ManagerContainer.DataMgr.RuneShopDataMgr:CheckSpecialPrivilegeSpeed()
- and not self:CheckVipData()
- and not self.hasSpeedItem then
- ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("SpeedUpLock")
- ManagerContainer.LuaGameMgr:LuaSaveGameSpeed(1)
- return
- end
- if ManagerContainer.LuaGameMgr:GetGameSpeed() == 2 then
- ManagerContainer.LuaGameMgr:LuaSaveGameSpeed(1)
- self.viewLua.btnSpeed.speed2:SetActive(false)
- self.viewLua.btnSpeed.speed1:SetActive(true)
- if self.hasSpeedItem then
- self.viewLua.targetPoint:SetActive(true)
- end
- else
- ManagerContainer.LuaGameMgr:LuaSaveGameSpeed(ManagerContainer.LuaGameMgr:GetGameSpeed()+1)
- self.viewLua.btnSpeed.speed2:SetActive(true)
- self.viewLua.btnSpeed.speed1:SetActive(false)
- if self.hasSpeedItem then
- self.viewLua.targetPoint:SetActive(false)
- end
- end
- end
- function BattleStatisticsPart:OnClickOpenStatisticPage()
- ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBattleStatistics,{LuaBattleBridge.CurrentBattleMode(),LuaBattleBridge.CurrentBattleSubMode()})
- end
- function BattleStatisticsPart:OnClickHide()
- if self.hidePnl == false then
- self.viewLua.battleCountAnim.animator:Play("UIBattleCountOut")
- self.hidePnl = true
- else
- self.viewLua.battleCountAnim.animator:Play("UIBattleCountIn")
- self.hidePnl = false
- end
- end
- --二次确认框退出战斗
- function BattleStatisticsPart:OnClickQuit()
- ManagerContainer.LuaUIMgr:ShowMessageBox("QuitBattleTip",nil,nil,self,self.OnForceStopBattle,nil)
- end
- --强制退出战斗
- function BattleStatisticsPart:OnForceStopBattle()
- ManagerContainer.LuaGameMgr:ForceStopBattle()
- ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
- --ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_BATTLE_FAILED,true,false);
- end
- function BattleStatisticsPart:RefreshSpeedStatus(isFirst)
- if not self.viewLua then
- self:StopSpeedTimer()
- return
- end
- if not Constant.OpenPay then
- self.viewLua.btnSpeed:SetActive(false)
- self:StopSpeedTimer()
- return
- end
- self.viewLua.btnSpeed:SetActive(true)
- self.viewLua.btnSpeed.speed1:SetActive(true)
- self.viewLua.btnSpeed.speed2:SetActive(false)
- local vipState = self:CheckVipData()
- local monthState = ManagerContainer.DataMgr.RuneShopDataMgr:CheckSpecialPrivilegeSpeed()
- if vipState or monthState then
- if ManagerContainer.LuaGameMgr.GameSpeed ~= 1 then
- self.viewLua.btnSpeed.speed1:SetActive(false)
- self.viewLua.btnSpeed.speed2:SetActive(true)
- end
- self:StopSpeedTimer()
- self.viewLua.speedtime:SetActive(false)
- self.viewLua.targetPoint:SetActive(false)
- else
- local hasSpeedItem = self.hasSpeedItem
- if isFirst then
- local sec = ManagerContainer.DataMgr.BattleAccTimeManager:GetValidTime()
- hasSpeedItem = (sec and sec > 0 or false)
- self.hasSpeedItem = hasSpeedItem
- end
- self.viewLua.speedtime:SetActive(hasSpeedItem)
- self.viewLua.targetPoint:SetActive(hasSpeedItem and ManagerContainer.LuaGameMgr.GameSpeed == 1)
- if hasSpeedItem then
- if ManagerContainer.LuaGameMgr.GameSpeed ~= 1 then
- self.viewLua.btnSpeed.speed1:SetActive(false)
- self.viewLua.btnSpeed.speed2:SetActive(true)
- end
- self:RefreshSpeedTimer()
- else
- ManagerContainer.LuaGameMgr:LuaSaveGameSpeed(1)
- self:StopSpeedTimer()
- end
- end
- end
- function BattleStatisticsPart:RefreshSpeedTimer()
- local sec = ManagerContainer.DataMgr.BattleAccTimeManager:GetValidTime()
- if not sec or sec <= 0 then
- local timeStr = CommonUtil.FormatTimeDMS(-1)
- self.viewLua.speedtime.time.text.text = string.formatbykey('SpeedCardTime', timeStr)
- self:StopSpeedTimer()
- return
- end
- if self.viewLua then
- local timeStr = CommonUtil.FormatTimeDMS(sec)
- self.viewLua.speedtime.time.text.text = string.formatbykey('SpeedCardTime', timeStr)
- end
- local validTime
- if sec >= 86400 then
- validTime = sec % 3600
- if validTime == 0 then validTime = 3600 end
- elseif sec >= 3600 then
- validTime = sec % 60
- if validTime == 0 then validTime = 60 end
- else
- validTime = 1
- end
- if self.speedTimer then
- self.speedTimer.duration = validTime
- else
- self.speedTimer = Timer.New(slot(self.RefreshSpeedTimer, self), validTime, -1, true)
- end
- if not self.speedTimer.running then
- self.speedTimer:Start()
- end
- end
- function BattleStatisticsPart:StopSpeedTimer()
- if self.speedTimer then
- if self.speedTimer.running then
- self.speedTimer:Stop()
- end
- self.speedTimer = nil
- end
- end
- function BattleStatisticsPart:OnVipLvChanged()
- self:RefreshSpeedStatus()
- end
- function BattleStatisticsPart:OnRuneShopDataChanged(runeShopType, runeShopSubType)
- if runeShopType == Enum.RuneShopType.SpecialPrivilege then
- self:RefreshSpeedStatus()
- end
- end
- function BattleStatisticsPart:OnBattleAccTimeChanged()
- self:RefreshSpeedStatus()
- end
- function BattleStatisticsPart:CheckVipData()
- local vipLv = ManagerContainer.DataMgr.UserData:GetVipLv()
- if not vipLv then
- return false
- end
- local vipCfg = ManagerContainer.CfgMgr:GetVipCfgById(vipLv)
- if vipCfg then
- if vipCfg.QuickBattle then
- if vipCfg.QuickBattle >= 1 then
- return true
- end
- end
- end
- return false
- end
- function BattleStatisticsPart:OnUIPartVisible(vis)
- self.viewLua:SetActive(vis)
- end
- function BattleStatisticsPart:GetSlotSortActor(tbFriend)
- --伙伴界面排序
- local sortedPartnerDatas = ManagerContainer.DataMgr.PartnerData:SortPartnerData()
- --根据伙伴界面排序 排序
- local sortedData = {}
- for j =1, tbFriend.Count do--主角第一
- local actor = tbFriend[j-1]
- local UserId = 1
- if tostring(UserId)==tostring(actor.fighterId) then
- table.insert(sortedData,actor)
- end
- end
- for i=1, #sortedPartnerDatas do --伙伴排序
- local PartnerData = sortedPartnerDatas[i]
- for j =1, tbFriend.Count do
- local actor = tbFriend[j-1]
- if tostring(PartnerData.id)==tostring(actor.fighterId) then
- table.insert(sortedData,actor)
- end
- end
- end
- return sortedData
- end
- function BattleStatisticsPart:OnRefreshStatistics()
- if self.data == nil then
- return
- end
-
- if self.data.FriendStatistics == nil then
- return
- end
- local friendList = self:GetSlotSortActor(self.data.FriendStatistics)
- if friendList == nil then
- return
- end
- for i = 1, #friendList do
- self:ShowFighterStatistics(self.statisticsActorNodes[i],friendList[i])
- end
- end
- function BattleStatisticsPart:ShowFighterStatistics(node,data)
- CommonUtil.LoadIcon(self.host, data.jobIcon, function (sprite)
- node.jobIcon.image.sprite = sprite
- end)
- node.playerName.text.text = data.actorName
- node.totalProgress.image.fillAmount = data.damagePercent
- node.progress.image.fillAmount = data.heroDamagePercent
- node.percent.text.text = CommonUtil.GetPreciseDecimal(data.damagePercent*100,2) .. "%"
- node:SetActive(true)
- end
- function BattleStatisticsPart:ResetData()
- if self.statisticsActorNodes ~= nil then
- for i= 1, #self.statisticsActorNodes do
- local node = self.statisticsActorNodes[i]
- node.jobIcon.image.sprite = nil
- node.playerName.text.text = ""
- node.totalProgress.image.fillAmount = 0
- node.progress.image.fillAmount = 0
- node.percent.text.text = ""
- end
- end
- end
- function BattleStatisticsPart:Dispose()
- self:StopTimer()
- self:Clear()
- self.host = nil
- self.viewLua = nil
- end
- function BattleStatisticsPart:Clear()
- self:StopSpeedTimer()
- self.hasSpeedItem = nil
- self.statisticsActorNodes = nil
- self.data = nil
- end
- return BattleStatisticsPart
|