local UIGuildWarRevive = UIViewClass() local DeathPunishTime = DataSheetManager.ConstData:GetDataByID("GuildWarDeathPunishTime").IntValue local MiddleRedLeftTouShi = 2041 local MiddleBlueLeftTouShi = 2042 local MiddleRedRightTouShi = 2051 local MiddleBlueRightTouShi = 2052 function UIGuildWarRevive:OnOpened(context) self:RegistSystemEvent(EventID.UI_GuildWarKillInfoNotice,self.OnNewKillMsg) self:RegistSystemEvent(EventID.UI_GuildWarCloseRevive,self.TryCloseView) self:RegistSystemEvent(EventID.UI_GuildWarCanBuyNotify, self.RefreshShopRedPoint) local playerId = context.heroIDs local reviveTime = context.time self.heroInfo = {} self.curUpdateValue = 0 self.txt_Second:ResetAndBeginCustomTimer(false,DeathPunishTime,0,UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_Countdown),1) self:SetUpdateValue(DeathPunishTime) self.selectHeroTime = DeathPunishTime + UTL.Time.GetServerTimestamp() self.isReviving = false local selectIndex = nil for i,v in ipairs(playerId) do 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 self.group_Hero[i].group_Mask.gameObject:SetActive(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 self.group_Hero[i].group_Mask.gameObject:SetActive(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 end self:SelectHero(selectIndex or 1) self:ShowKillInfo() self.mapCanvas:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIGuildWarMapInfo), {}) CTL.ChannelChat.OnSelfDead(true) UIUtils.SetActive(self.group_SelectRevivalPoint, BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncGuildWarMapMiddle)) if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncGuildWarMapMiddle) then local leftItem = LevelItemManager.GetMonsterByItemID(MiddleRedLeftTouShi) or LevelItemManager.GetMonsterByItemID(MiddleBlueLeftTouShi) local rightItem = LevelItemManager.GetMonsterByItemID(MiddleRedRightTouShi) or LevelItemManager.GetMonsterByItemID(MiddleBlueRightTouShi) if leftItem and leftItem:GetCampID() ~= BattleDataGetter.GetMyCampID() then if MDL.GuildWar.IsMirrorMap() then self:OnButtonClicked(self.btn_LeftCamp) else self:OnButtonClicked(self.btn_RightCamp) end elseif rightItem and rightItem:GetCampID() ~= BattleDataGetter.GetMyCampID() then if MDL.GuildWar.IsMirrorMap() then self:OnButtonClicked(self.btn_RightCamp) else self:OnButtonClicked(self.btn_LeftCamp) end else local index = MDL.GuildWar.GetLastSelectReviveIndex(MDL.GuildWar.ReviveType.GuildWar) if index == 1 then self:OnButtonClicked(self.btn_LeftCamp) else self:OnButtonClicked(self.btn_RightCamp) end end end UIUtils.SetActive(self.Iab_arrow, MDL.GuildWar.GetCanBuyNotify() or false) end function UIGuildWarRevive:ShowKillInfo() local killInfo = MDL.GuildWar.GetGuildWarKillInfo() for i,v in ipairs(killInfo) do self.loop_Kill:AddData(v,0) end end function UIGuildWarRevive:OnNewKillMsg(msg) self.loop_Kill:InsertData(0,msg,0) end function UIGuildWarRevive:SetUpdateValue(value) if self.curUpdateValue == 0 or self.curUpdateValue > value then self.curUpdateValue = value self:StartRepeatFunc(self.OnUpdateFun, value) end end function UIGuildWarRevive:OnUpdateFun(deltaTime, timeSinceUpdate) self.curUpdateValue = 0 self:SetFightState() end function UIGuildWarRevive:SetFightState() if UTL.Time.GetServerTimestamp() - self.selectHeroTime < 0 then logging.error(LTAG, "错误 服务器时间比客户端时间慢?") end self.group_CountDown.gameObject:SetActive(false) self.btn_Fight.gameObject:SetActive(true) end function UIGuildWarRevive:SelectHero(index) self.selectIndex = index self.isReviving = false for i,v in ipairs(self.group_Hero) do if i == index then self.group_Hero[i].img_Chk.gameObject:SetActive(true) else self.group_Hero[i].img_Chk.gameObject:SetActive(false) end end end function UIGuildWarRevive: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_Chanel then UIManager.OpenView(Const_UI_Lua.UIEnum.UIBattleChatMainParentView) elseif comp == self.btn_LeftCamp or comp == self.icon_left then UIUtils.SetActive(self.Left_Selected, true) UIUtils.SetActive(self.Right_Selected, false) UIUtils.SetActive(self.Front_UnSelected, true) UIUtils.SetActive(self.Rear_UnSelected, true) print(MDL.GuildWar.IsMirrorMap()) UIUtils.SetActive(self.icon_select_L, true) UIUtils.SetActive(self.icon_select_R, false) if MDL.GuildWar.IsMirrorMap() then LuaInputManager.PressSelectBornItemIndex(2) else LuaInputManager.PressSelectBornItemIndex(1) end MDL.GuildWar.SetLastSelectReviveIndex(MDL.GuildWar.ReviveType.GuildWar, 1) elseif comp == self.btn_RightCamp or comp == self.icon_right then UIUtils.SetActive(self.Left_Selected, false) UIUtils.SetActive(self.Right_Selected, true) UIUtils.SetActive(self.Front_UnSelected, true) UIUtils.SetActive(self.Rear_UnSelected, true) UIUtils.SetActive(self.icon_select_L, false) UIUtils.SetActive(self.icon_select_R, true) if MDL.GuildWar.IsMirrorMap() then LuaInputManager.PressSelectBornItemIndex(1) else LuaInputManager.PressSelectBornItemIndex(2) end MDL.GuildWar.SetLastSelectReviveIndex(MDL.GuildWar.ReviveType.GuildWar, 2) elseif comp == self.event_MaterialShop then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildWarShopPanel) end end function UIGuildWarRevive: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 UIGuildWarRevive:TryCloseView(entity) if entity and entity:IsPlayerSelf() then self:CloseView() self.isReviving = false end end function UIGuildWarRevive:OnClosed() CameraController.Instance:SetGray(false) CTL.Sound.PlayGameSound("SFX_life") CTL.ChannelChat.OnSelfDead(false) if BattleDataGetter.GetCurEntity() == nil or not BattleDataGetter.GetCurEntity():IsAlive() then logging.error(LTAG.ERROR, "[GuildWarReviveError] 玩家死亡后关闭复活界面,但是玩家还是死亡状态") end end function UIGuildWarRevive:OnCellInit(scrollRect, index, cellTable, data) if self:IsMyCamp(data) then cellTable.txt_Name01.text = UTL.Color.FormatTextByColor("e46b71",data.playerNameA) cellTable.txt_Name02.text = self:GetPlayerNameColor(data.playerNameB) else cellTable.txt_Name01.text = self:GetPlayerNameColor(data.playerNameA) cellTable.txt_Name02.text = UTL.Color.FormatTextByColor("e46b71",data.playerNameB) end end function UIGuildWarRevive:IsMyCamp(data) if string.isNilOrEmpty(data.guildIdA) then return data.guildIdB == MDL.Guild.GetMyGuildInfo().guildId else return data.guildIdA ~= MDL.Guild.GetMyGuildInfo().guildId end end function UIGuildWarRevive:GetPlayerNameColor(playerName) if playerName == BattleDataGetter.GetPlayerName() then return UTL.Color.FormatGreenColor(playerName) else return UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue, playerName) end end function UIGuildWarRevive:RefreshShopRedPoint(value) UIUtils.SetActive(self.Iab_arrow, value) end return UIGuildWarRevive