local Base = require("Battle/Logic/Level/LevelFunction/LevelFunction") local AttackCityLevelFunction = class("AttackCityLevelFunction",Base) function AttackCityLevelFunction:GetExpClass() return require "Battle/Expression/ExpLevel/ExpLevelFunction/ExpAttackCityLevelFunction" end function AttackCityLevelFunction:InitLevel() Base.InitLevel(self) self.SwitchHeroInheritSA = false LevelPlayerManager.SetCanSwitchHeroByCommand(false) --本玩法禁止手动切将 self.isForbidPlayerInput = true --本玩法禁止玩家输入 end function AttackCityLevelFunction:IsMusouShowOpen() return false --攻城略地玩法不播无双小黑屋动画 end function AttackCityLevelFunction:GetRobotAI(entity) return LuaConst.PveRobotAIID end --local SA_SPEED_UP_BUFF = 500088 --无双值获取加速buff function AttackCityLevelFunction:CreatePlayers(pos, dir) Base.CreatePlayers(self,dir) self:CreateEnemyHeroes() self:StartAutoFight(LogicUpdateManager._curEntity) end --是否三军武将同时上场 function AttackCityLevelFunction:IsAllHeroJoinBattle() return true end function AttackCityLevelFunction:IsIndividualSa() return true end function AttackCityLevelFunction:IsAutoUseMusou() return true end function AttackCityLevelFunction:GetBornPosAndDirByArmyIndex(i, originBornPos, bornDir) local bornItem = self:GetBornItemByIndex(i) return LogicRandom.GetRandomPointInLevelItem(nil, bornItem.ItemData, 8238236), bornItem.ItemData.ItemDir end function AttackCityLevelFunction:SwitchAutoFight(entity) --不调用base,这个玩法不允许修改自动战斗状态 --do nothing end function AttackCityLevelFunction:StopAutoFight(entity) --不调用base,这个玩法不允许停止自动战斗 --do nothing end --armyData是LevelPlayerManager.GetPlayerArmyByPlayerIDInRoom返回的list里的元素 function AttackCityLevelFunction:GetGsByArmyData(wholeArmyGs, armyData) return armyData.heroGs end --创建敌方玩家的英雄 function AttackCityLevelFunction:CreateEnemyHeroes() local heroEntityTable = {} repeat local army = LevelPlayerManager.GetPlayerArmyByPlayerIDInRoom(LuaConst.STANDALONE_ENEMYPLAYER1_PLAYID) if not army then logging.error(LTAG.ERROR, "HYW : army nil Error @AttackCityLevelFunction:CreateEnemyHeroes!!") break end local playerInfo = LevelPlayerManager.GetPlayerInfoByPlayerIDInRoom(LuaConst.STANDALONE_ENEMYPLAYER1_PLAYID) for i,v in ipairs(army) do local bornItem = self:GetBornItemByIndex(i + 3) if not bornItem then logging.error(LTAG.ERROR, "HYW : bornItem nil Error @AttackCityLevelFunction:CreateEnemyHeroes!!") break end local pos = LogicRandom.GetRandomPointInLevelItem(nil, bornItem.ItemData, 8238236) local bornItemID = bornItem.LevelItemID EntityFactory.SetParams("BornItemID", bornItemID, "InitHP", v.HP, "Name", playerInfo.name) EntityFactory.SetParams("CampID", LuaConst.STANDALONE_ENEMY_CAMP) EntityFactory.SetParams("StratagemSkill", playerInfo.stratagemSkill) EntityFactory.SetType_ID(LuaConst.CharacterType.Hero, v.HeroID) EntityFactory.SetAttrTable_ID(v.Attr) EntityFactory.SetPos_Dir(pos, bornItem.ItemData.ItemDir) EntityFactory.SetSelf_Sync(false, false) EntityFactory.SetEffectBreak_Weapon(v.mainHeroBreakNums,v.isMagicWeaponActive,v.mainHeroWeaponLevels) EntityFactory.SetHorse_ID(v.horseID, v.horseAppearanceId) EntityFactory.SetPet_Info(v.petInfo.petId, v.petInfo.stage, v.petInfo.petName, v.petInfo.petSkill) EntityFactory.SetHeroAppearance_ID(v.heroAppearanceId) EntityFactory.SetWeaponAppearance_ID(v.weaponAppearanceId) EntityFactory.SetDyeAppearanceList(v.mainDyeCurPartList) EntityFactory.SetLightEffect_ID(v.lightEffectIds) EntityFactory.SetWeaponSoulInfo(v.weaponSoulInfo) EntityFactory.SetParams("PlayerID", LuaConst.STANDALONE_ENEMYPLAYER1_PLAYID) local entity = EntityFactory.DoCreatePlayerEntity() entity._logicInitData.OfficialPosition = playerInfo.officialPosition entity:SetGs(self:GetGsByArmyData(v.heroGs, v)) table.insert(heroEntityTable, entity) local adjutantID = v.AdjutantID if adjutantID and adjutantID > 0 then EntityFactory.SetType_ID(LuaConst.CharacterType.Adjutant, adjutantID) EntityFactory.SetAttrTable_ID(v.Attr) EntityFactory.SetEffectBreak_Weapon(v.viceHeroBreakNums,v.isViceMagicWeaponActive,v.viceHeroWeaponLevels) EntityFactory.SetHeroAppearance_ID(v.viceHeroAppearanceId) EntityFactory.SetWeaponAppearance_ID(v.viceWeaponAppearanceId) EntityFactory.SetDyeAppearanceList(v.viceDyeCurPartList) EntityFactory.DoCreateAdjutantEntity(entity) end end self:TryAddPlayerBuff(LuaConst.STANDALONE_ENEMYPLAYER1_PLAYID) LevelPlayerManager.SetPlayerEntityTable(heroEntityTable, LuaConst.STANDALONE_ENEMYPLAYER1_PLAYID) for i,entity in ipairs(heroEntityTable) do SystemManager.Active(entity) self:StartAutoFight(entity, true) end self.exp:AfterEnemyHeroesCreated(heroEntityTable) until true end function AttackCityLevelFunction:OnPlayerAllHeroDead(entity) Base.OnPlayerAllHeroDead(self, entity) if entity:GetPlayerID() == LevelPlayerManager.MyPlayerIDInRoom then LevelItemManager.Global:HandleEndLevel(false) else LevelItemManager.Global:HandleEndLevel(true) end end return AttackCityLevelFunction