local UISwitchHeroReviveView = UIViewClass() local normalAutoBattleTime = DataSheetManager.ConstData:GetDataByID("NormalAutoBattleTime").IntValue function UISwitchHeroReviveView:OnOpened(context) self:RegistSystemEvent(EventID.UI_SelectOneReviveOver, self.TryCloseView) local playerId = context.heroIDs local reviveTime = context.time self.heroInfo = {} self.curUpdateValue = 0 if BattleDataGetter.IsShowAutoReviveLevel() then self.toggle_Revive.isOn = BattleDataGetter.GetIsAutoRevive(BattleDataGetter.GetCurLevelType()) if self.toggle_Revive.isOn then self:StartRepeatFunc(self.OnAutoBattleTimeEnd, normalAutoBattleTime, 1) end else if self.state_Revive then --该界面被继承,子界面不一定有该节点,加个判空 self.state_Revive:SetState(0) end end if context.punishTime then -- 有强制等待时长 local punishTime = context.punishTime UIUtils.SetActive(self.group_CountDown, true) UIUtils.SetActive(self.btn_Fight, false) if BattleDataGetter.IsShowAutoReviveLevel() then self.state_Revive:SetState(2) end UIUtils.SetLabelText(self.lab_Notice, Const_IDS.IDS_GuildWar_ReBornTip) if not BattleDataGetter.IsPayToReviveAtCurrentPlaceLevel() then self.txt_Second:ResetAndBeginCustomTimer(false, punishTime, 0, UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_Countdown), 1) end self:SetUpdateValue(punishTime) self.selectHeroTime = punishTime + UTL.Time.GetServerTimestamp() if self.lab_Nearby then self.lab_Nearby.text = UIUtils.GetLocalizedTxt(Const_IDS["IDS_DragonArtey_Reborn3"]) UIUtils.SetActive(self.lab_Nearby, false) self.btn_Nearby:SetGray(true) end UIUtils.SetActive(self.txt_Tip,true) UIUtils.SetActive(self.img_TextBg,true) else UIUtils.SetActive(self.group_CountDown, false) UIUtils.SetActive(self.btn_Fight, true) if BattleDataGetter.IsShowAutoReviveLevel() then self.state_Revive:SetState(1) end UIUtils.SetActive(self.txt_Tip,false) UIUtils.SetActive(self.img_TextBg,false) end local selectIndex = nil for i, v in ipairs(playerId) do if v > 0 then UTL.Item.SetHeroIconByHeroId(self.group_Hero[i].img_Player, v, BattleDataGetter.GetHeroIsAwaken(BattleDataGetter.GetCurPlayerID(), v)) self.heroInfo[i] = self.heroInfo[i] or {} self.heroInfo[i].heroId = v local secTime = (reviveTime[i] - LogicUpdateManager._clientHandleFrame) * LuaConst.TimeSpan if reviveTime[i] > 0 and secTime > 0 then UIUtils.SetActive(self.group_Hero[i].group_Mask, true) self.group_Hero[i].txt_Second:ResetAndBeginTimer(false, math.ceil(secTime)) self.heroInfo[i].reviveFrame = reviveTime[i] self.heroInfo[i].cdEnd = secTime + UTL.Time.GetServerTimestamp() else UIUtils.SetActive(self.group_Hero[i].group_Mask, false) self.heroInfo[i].cdEnd = nil self.heroInfo[i].reviveFrame = nil if selectIndex == nil then selectIndex = i end self.group_Hero[i].txt_Second:EndTimer() end else UIUtils.SetActive(self.group_Hero[i].btn, false) UIUtils.SetImageByAssetBundle(self.group_Hero[i].img_Player, ConstAssetPathConfig.Path21) end end self:SelectHero(selectIndex or 1) local name = BattleDataGetter.GetKillerName(BattleDataGetter.GetCurEntity()) local killNameTextComp = self.txt_Tip if not context.punishTime then killNameTextComp = self.lab_Notice end if string.isNilOrEmpty(name) then UIUtils.SetLabelText(killNameTextComp, Const_IDS.IDS_DigTreasure_Defeated) else killNameTextComp.text = string.FormatByIdsId(Const_IDS.IDS_Reborn_BeKilled, name) end self:TryWorldBossOpen() self.isReviving = false if BattleDataGetter.IsPayToReviveAtCurrentPlaceLevel() then UIUtils.SetActive(self.group_CountDown, false) UIUtils.SetActive(self.group_ReviveBtn, true) UIUtils.SetActive(self.btn_Fight, false) self:StartRepeatFunc(self.OnUpdateFun, 0.1) else local isActive = false if context.punishTime then isActive = context.punishTime > 0 end UIUtils.SetActive(self.group_CountDown, isActive) UIUtils.SetActive(self.group_ReviveBtn, false) end if BattleDataGetter.IsPayToReviveAtCurrentPlaceLevel() then local price local moneyID = 4 local deadCount = BattleDataGetter.GetReviveFromServerCount(BattleDataGetter.GetCurPlayerID()) + 1 if BattleDataGetter.IsDragonArteryLevel() then local data = DataSheetManager.DragonArteryReborn:GetDataByDeadCount(deadCount) if data then price = data.BuyPrice moneyID = data.MoneyID self.lastRebornData = data else if self.lastRebornData then price = self.lastRebornData.BuyPrice moneyID = self.lastRebornData.MoneyID else logging.error(LTAG.ERROR, "HYW : DragonArteryReborn data nil Error!") end end end if price then self.txt_CoinNum.text = price end if moneyID then UTL.Item.SetCurrencyImageIcon(self.img_Coin, moneyID) end --增加HUD CTL.Currency.OpenCurrencyPanel(self.__viewClassPath, self.currency_Info, { moneyID }) end CTL.ChannelChat.OnSelfDead(true) UIUtils.SetActive(self.event_Chanel, self:IsShowChatBtn()) end function UISwitchHeroReviveView:SetUpdateValue(value) if not BattleDataGetter.IsDragonArteryLevel() then if self.curUpdateValue == 0 or self.curUpdateValue > value then self.curUpdateValue = value self:StopRepeatFunc(self.OnUpdateFun) self:StartRepeatFunc(self.OnUpdateFun, value) self.nextUpdateTime = UTL.Time.GetServerTimestamp() + value end end end function UISwitchHeroReviveView:SetTimeInfo() local curTime = UTL.Time.GetServerTimestamp() for i, v in ipairs(self.heroInfo) do if self.heroInfo[i].cdEnd and self.heroInfo[i].cdEnd - curTime > 0 then self:SetUpdateValue(self.heroInfo[i].cdEnd - curTime) else UIUtils.SetActive(self.group_Hero[i].group_Mask, false) self.heroInfo[i].cdEnd = nil self.heroInfo[i].reviveFrame = nil end end if self.clickHelpBtnEndTime then if curTime - self.clickHelpBtnEndTime >= 0 then self.clickHelpBtnEndTime = nil self:HelpCDOver() else self:SetUpdateValue(self.clickHelpBtnEndTime - curTime) end end end function UISwitchHeroReviveView:OnUpdate(deltaTime, timeSinceUpdate) self:OnUpdateFun(deltaTime, timeSinceUpdate) end function UISwitchHeroReviveView:OnUpdateFun(deltaTime, timeSinceUpdate) self.curUpdateValue = 0 self:SetTimeInfo() if BattleDataGetter.IsPayToReviveAtCurrentPlaceLevel() then if self.selectHeroTime then if self.selectHeroTime - UTL.Time.GetServerTimestamp() >= 0 then self.txt_ReviveTime.text = string.FormatByIdsId(Const_IDS.IDS_DragonArtey_Reborn1, self.selectHeroTime - UTL.Time.GetServerTimestamp()) else self.btn_Nearby:SetGray(false) UIUtils.SetActive(self.lab_Nearby, true) self.txt_ReviveTime.text = nil end else UIUtils.SetActive(self.lab_Nearby, true) self.txt_ReviveTime.text = nil end else self:SetFightState() end end function UISwitchHeroReviveView:SetFightState() if self.selectHeroTime then if UTL.Time.GetServerTimestamp() - self.selectHeroTime >= 0 then UIUtils.SetActive(self.group_CountDown, false) UIUtils.SetActive(self.btn_Fight, true) if BattleDataGetter.IsShowAutoReviveLevel() then self.state_Revive:SetState(1) end else UIUtils.SetActive(self.group_CountDown, true) UIUtils.SetActive(self.btn_Fight, false) if BattleDataGetter.IsShowAutoReviveLevel() then self.state_Revive:SetState(2) end self:StartRepeatFunc(self.UpdateFightState, 1, 1) end end end function UISwitchHeroReviveView:UpdateFightState(deltaTime, timeSinceUpdate) self:SetFightState() end function UISwitchHeroReviveView:OnTimeToRevive() if BattleDataGetter.IsShowAutoReviveLevel() == false then return end self:StopRepeatFunc(self.OnTimeToRevive) if (self.heroInfo[self.selectIndex].reviveFrame == nil or self.heroInfo[self.selectIndex].reviveFrame < LogicUpdateManager._clientHandleFrame) then if self.toggle_Revive.isOn and self.isCanAutoBattle then self:OnButtonClicked(self.btn_Fight) end else local leftTime = (self.heroInfo[self.selectIndex].reviveFrame - LogicUpdateManager._clientHandleFrame) * LuaConst.TimeSpan self:StartRepeatFunc(self.OnTimeToRevive, leftTime) end end function UISwitchHeroReviveView:SelectHero(index) self.selectIndex = index self.isReviving = false for i, v in ipairs(self.group_Hero) do if i == index then UIUtils.SetActive(self.group_Hero[i].img_Chk, true) else UIUtils.SetActive(self.group_Hero[i].img_Chk, false) end end self:OnTimeToRevive() end function UISwitchHeroReviveView:OnAutoBattleTimeEnd() self.isCanAutoBattle = true self:OnTimeToRevive() end function UISwitchHeroReviveView:OnButtonClicked(comp) if comp == self.group_Hero[1].btn then self:SelectHero(1) elseif comp == self.group_Hero[2].btn then self:SelectHero(2) elseif comp == self.group_Hero[3].btn then self:SelectHero(3) elseif comp == self.btn_Fight then self:FightHero() elseif comp == self.event_SeekHelp then self:OnSeekHelp() elseif comp == self.btn_Add then local targetAcid = BattleDataGetter.GetKillerAcid(BattleDataGetter.GetCurEntity()) if targetAcid then MDL.Rival.RivalOperationRequest(targetAcid, MDL.Rival.RivalOperationType.RivalOptCommonEnemy) end elseif comp == self.btn_Nearby then self:FightHero() elseif comp == self.btn_Immediately then if BattleDataGetter.IsDragonArteryLevel() then local index = self.selectIndex if self.heroInfo[index].reviveFrame and self.heroInfo[index].reviveFrame >= LogicUpdateManager._clientHandleFrame then -- 策划需求:在死亡CD时 ,不允许买活 CTL.Sound.PlayGameSound("UI_invalid") local heroData = DataSheetManager.HeroNum:GetDataByID(self.heroInfo[index].heroId) local heroName = UIUtils.GetLocalizedTxt(Const_IDS[heroData.NameIDS]) local str = string.FormatByIdsId(Const_IDS.IDS_GuildWar_HeroNotAlive, heroName) CTL.Tips.AddTipsMsg(str) else MDL.DragonArtery.DAPayForReliveReq(self.selectIndex) end else logging.error(LTAG.ERROR, "HYW : 未实现原地付费复活的关卡 LevelID : ", BattleDataGetter.GetCurLevelID()) end elseif comp == self.event_Chanel then UIManager.OpenView(Const_UI_Lua.UIEnum.UIBattleChatMainParentView) end end function UISwitchHeroReviveView:FightHero() local index = self.selectIndex if self.heroInfo[index].reviveFrame and self.heroInfo[index].reviveFrame >= LogicUpdateManager._clientHandleFrame then CTL.Sound.PlayGameSound("UI_invalid") local heroData = DataSheetManager.HeroNum:GetDataByID(self.heroInfo[index].heroId) local heroName = UIUtils.GetLocalizedTxt(Const_IDS[heroData.NameIDS]) local str = string.FormatByIdsId(Const_IDS.IDS_GuildWar_HeroNotAlive, heroName) CTL.Tips.AddTipsMsg(str) else local playerIndex = -1 -- 玩家当前上场情况的排序 第几个 if index == 1 then playerIndex = BattleDataGetter.GetIndexByArmyPos_Self(LuaConst.ArmyPosType.First) elseif index == 2 then playerIndex = BattleDataGetter.GetIndexByArmyPos_Self(LuaConst.ArmyPosType.Second) elseif index == 3 then playerIndex = BattleDataGetter.GetIndexByArmyPos_Self(LuaConst.ArmyPosType.Third) else logging.error(LTAG.ERROR, "徐倩 : 玩家不能复活, selectIndex = ", index) end if playerIndex > 0 then if not self.isReviving then -- 防止连点 LuaInputManager.SetSpecialCommand(LuaConst.SpecialCommandType.ReviveAndSwitchOneHero) LuaInputManager.SetMoveType(playerIndex + LuaConst.CmdMoveTypeBaseEnum.ReviveAndSwitchBase) self.isReviving = true end else logging.error(LTAG.ERROR, "GWS : 玩家不能复活, playerIndex = ", playerIndex, "selectIndex = ", index) end end end function UISwitchHeroReviveView:TryCloseView(entity) if entity and entity:IsPlayerSelf() then self:CloseView() self.isReviving = false end end function UISwitchHeroReviveView:OnClosed() CameraController.Instance:SetGray(false) CTL.Sound.PlayGameSound("SFX_life") CTL.ChannelChat.OnSelfDead(false) end --- 世界boss独有的 求助按钮功能 ↓ local SEEK_HELP_TIME = DataSheetManager.ConstData:GetDataByID("WorldBossSeekHelpCD").IntValue function UISwitchHeroReviveView:TryWorldBossOpen() if LevelManager.CheckCurLevelType(LuaConst.LevelType.SyncWorldBoss) or LevelManager.CheckCurLevelType(LuaConst.LevelType.SyncWarZoneWorldBoss) then --求助特效 UIUtils.SetActive(self.group_SeekHelp,true) self:HelpCDOver() if MDL.WorldBoss.GetIsAttacked() then self.effect_Help:PlayUIEffect() end self:RegistSystemEvent(EventID.UI_Rival_RefreshRivalList, self.SetRivalState) self:SetRivalInfo() else UIUtils.SetActive(self.group_SeekHelp,false) self.obj_State:SetState(1) end end --请求协助后,按钮变灰色,倒计时开始,按钮不可用 function UISwitchHeroReviveView:OnSeekHelp() local req = false local killerName = BattleDataGetter.GetKillerName(BattleDataGetter.GetCurEntity()) if killerName then req = MDL.WorldBoss.WorldBossSeekHelp(false, MDL.WorldBoss.HelpType.Killed, killerName) end if req then self.event_SeekHelp:SetGray(true, false) UIUtils.SetGray(self.img_helpIcon, true) self.lab_HelpTimeCD:ResetAndBeginCustomTimer(false, SEEK_HELP_TIME, 0, UIUtils.GetLocalizedTxt(Const_IDS["IDS_TeamUI_Myteam_RecruitingTime"]), 1) self.effect_Help:StopUIEffect() local curTime = UTL.Time.GetServerTimestamp() self.clickHelpBtnEndTime = SEEK_HELP_TIME + curTime if not self.nextUpdateTime or self.nextUpdateTime - curTime > SEEK_HELP_TIME then self:SetUpdateValue(SEEK_HELP_TIME) end end end -- 请求协助CD 结束 function UISwitchHeroReviveView:HelpCDOver() self.event_SeekHelp:SetGray(false, true) UIUtils.SetGray(self.img_helpIcon, false) self.lab_HelpTimeCD:EndTimer() end --- 世界boss独有的 求助按钮功能 ↑ --- 世界boss独有的 仇敌系统功能 ↓ function UISwitchHeroReviveView:SetRivalInfo() local killerInfo = BattleDataGetter.GetKillerPlayerInfoEntity(BattleDataGetter.GetCurEntity()) if killerInfo and killerInfo.fighterType ~= LuaConst.BattleMemberType.Robot_Hero then self.obj_State:SetState(0) UIUtils.SetLabel(self.txt_PlayerName, killerInfo.name) CTL.Character.SetPortraitAndFrame(self.UIHeroHeadTempate, killerInfo.portraitId, killerInfo.frameId, nil, killerInfo.acid) if string.isNilOrEmpty(killerInfo.guildName) then UIUtils.SetActive(self.group_GuildInitiate, false) else UIUtils.SetActive(self.group_GuildInitiate, true) local framePath, emblemContent, guildDesc = CTL.Guild.GetModelNameShowParam(killerInfo.guildEmblemFrame, killerInfo.guildEmblemContent, killerInfo.guildName, killerInfo.guildJob, killerInfo.guildIdentity) UIUtils.SetImageByAssetBundle(self.img_GuildIcon, framePath) UIUtils.SetLabel(self.txt_GuildInitiate, emblemContent) UIUtils.SetLabel(self.txt_GuildName, guildDesc) end local myAcid = BattleDataGetter.GetAcID() if BattleDataGetter.IsBelongCommonRival(killerInfo.playerID, myAcid) or BattleDataGetter.IsBelongSwornRival(killerInfo.playerID, myAcid) then if killerInfo.openRivalShoutingContent then UIUtils.SetActive(self.img_SlogenBg, true) UIUtils.SetLabel(self.txt_Slogen, string.isNilOrEmpty(killerInfo.rivalShoutingContent) and UIUtils.GetLocalizedTxt(Const_IDS.IDS_Rival_InitialtRevengeShoutoutText) or killerInfo.rivalShoutingContent) else UIUtils.SetActive(self.img_SlogenBg, false) end else if killerInfo.openCommonShoutingContent then UIUtils.SetActive(self.img_SlogenBg, true) UIUtils.SetLabel(self.txt_Slogen, string.isNilOrEmpty(killerInfo.commonShoutingContent) and UIUtils.GetLocalizedTxt(Const_IDS.IDS_Rival_InitialtKillShoutoutText) or killerInfo.commonShoutingContent) else UIUtils.SetActive(self.img_SlogenBg, false) end end self:SetRivalState() else self.obj_State:SetState(1) end end function UISwitchHeroReviveView:SetRivalState() local targetAcid = BattleDataGetter.GetKillerAcid(BattleDataGetter.GetCurEntity()) if MDL.Friend.IsPlayerRival(targetAcid) then -- 是仇敌(死敌也算是仇敌) if MDL.Friend.IsPlayerRivalSworn(targetAcid) then self.obj_RivalState:SetState(1) else self.obj_RivalState:SetState(0) end else -- 不是仇敌 self.obj_RivalState:SetState(2) end end --- 世界boss独有的 仇敌系统功能 ↑ --是否展示聊天按钮 function UISwitchHeroReviveView:IsShowChatBtn() return BattleDataGetter.IsDragonArteryLevel() or BattleDataGetter.IsFightThroneLevel() or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncCountryEveningBoss) end function UISwitchHeroReviveView:OnValueChanged(comp, value) BattleDataGetter.SetIsAutoRevive(BattleDataGetter.GetCurLevelType(), value) end return UISwitchHeroReviveView