local Base = require("Battle/Logic/Level/LevelFunction/LevelFunction") local ExpelMonsterLevelFunction = class("ExpelMonsterLevelFunction",Base) function ExpelMonsterLevelFunction:GetExpClass() return require "Battle/Expression/ExpLevel/ExpLevelFunction/ExpExpelMonsterLevelFunction" end function ExpelMonsterLevelFunction:InitLevel() Base.InitLevel(self) self.dontIgnoreEnemy = true self.dmgToBoss = FP.newV1(0) end function ExpelMonsterLevelFunction:CurLevelCanSwitchHeroByCmd(fromEntity, index) return index == 2 end function ExpelMonsterLevelFunction:HandleSwitchHeroData(heroEntitys, fromEntity, switchToIndex, toEntity, playerID, isOriginalArmy) if switchToIndex == 2 then if heroEntitys[3] and heroEntitys[3]:IsAlive() then -- 不调用Base heroEntitys[3]:SetIndex(2) heroEntitys[2] = heroEntitys[3] heroEntitys[3] = fromEntity fromEntity:SetIndex(3) heroEntitys[1] = toEntity toEntity:SetIndex(1) --如果是初始阵容,那么PlayerArmyTable顺序也改变,这里HeroArmyTable起到的作用是记录顺序,方便切换阵容后恢复回来保证顺序跟切换前一致 local army = LevelPlayerManager.GetPlayerArmyByPlayerIDInRoom(playerID) local fromHeroArmy = army[1] local toHeroArmy = army[2] army[2] = army[3] army[3] = fromHeroArmy army[1] = toHeroArmy else --三号位已经死亡,此时走基类逻辑 Base.HandleSwitchHeroData(self, heroEntitys, fromEntity, switchToIndex, toEntity, playerID, isOriginalArmy) end else Base.HandleSwitchHeroData(self, heroEntitys, fromEntity, switchToIndex, toEntity, playerID, isOriginalArmy) logging.error(LTAG.ERROR, "HYW : 警告!试图在恶兽驱役玩法中切换到非2号位英雄!") end end function ExpelMonsterLevelFunction:GetInitAutoFightState() --这个玩法一开始不开启自动战斗 return false end function ExpelMonsterLevelFunction:OnHpChange(entity, caster, delta, op, realDelta) if delta < FP.Const.Zero and caster then local originEntity = caster:GetOriginEntity() if entity:IsBoss() and originEntity:IsHero() then self.dmgToBoss:Sub(delta) end end end function ExpelMonsterLevelFunction:GetBossHpLeftPercent() return self.bossHpLeft or 1 end function ExpelMonsterLevelFunction:OnBossBorn(entity) Base.OnBossBorn(self, entity) self.bossMaxHp = entity:GetAttrValueNum(LuaConst.AttrType.hplmt) end function ExpelMonsterLevelFunction:OnUpdate() Base.OnUpdate(self) if LogicUpdateManager._clientHandleFrame == self.callBaseSucceedFrame then Base.OnLevelSucceed(self, self.callBaseSucceedWithShow) end end function ExpelMonsterLevelFunction:BeforeEndLevel() Base.BeforeEndLevel(self) --在关卡结束之前,记录boss血量,因为关卡结束后(OnLevelSucceed、OnLevelFail),怪物会被全部清空,boss剩余血量就再也取不到了 if #self.bossList > 0 then self.bossHpLeft = FP.tonumberV1(self.bossList[1].components.attr:HitPointPercents()) else self.bossHpLeft = 0 end end function ExpelMonsterLevelFunction:OnLevelSucceed(withShow) self.callBaseSucceedFrame = LogicUpdateManager._clientHandleFrame + 20 --这里不延迟,处理不了一个动画的问题,因为现在配了是全部英雄死亡就胜利,此时会播一个受击动画 self.callBaseSucceedWithShow = withShow end return ExpelMonsterLevelFunction