private void BeginSimulation() { BattleConfig battleConfig = null; SerializeHelper.DeserializeJsonToData(Utils.GetBattleConfigPath(battleConfigName), out battleConfig); BattleEngine battleEngine = new BattleEngine(); battleEngine.Init(battleConfig); if (AppConst.AsyncServer) { Task <BattleReport> task = new Task <BattleReport>(battleEngine.DoPlayBattle); task.Start(); task.GetAwaiter().OnCompleted(() => EndSimulation(task)); } else { BattleReport battleReport = battleEngine.DoPlayBattle(); EndSimulation(battleReport); } }
public static Mission OpenSingleplayerMission(BattleConfig config, string map) { var playerCulture = Utility.GetCulture(config.PlayerTeamConfig); var playerSide = config.BattleTypeConfig.PlayerSide; var enemyCulture = Utility.GetCulture(config.EnemyTeamConfig); var enemySide = playerSide.GetOppositeSide(); SPCombatant[] parties = new SPCombatant[2] { SPCombatant.CreateParty(EnhancedBattleTestPartyController.PlayerParty.Party, playerSide, playerCulture, config.PlayerTeamConfig, true), SPCombatant.CreateParty(EnhancedBattleTestPartyController.EnemyParty.Party, enemySide, enemyCulture, config.EnemyTeamConfig, false) }; if (playerSide == BattleSideEnum.Attacker) { Utility.SetMapEvents(EnhancedBattleTestPartyController.PlayerParty.Party, EnhancedBattleTestPartyController.EnemyParty.Party, config.BattleTypeConfig.BattleType); } else { Utility.SetMapEvents(EnhancedBattleTestPartyController.EnemyParty.Party, EnhancedBattleTestPartyController.PlayerParty.Party, config.BattleTypeConfig.BattleType); } return(OpenMission(parties[0], parties[1], config, map)); }
public void Initialize() { BattleConfig battleConfig = _context.battleConfig.value; // unique var unique = _context.CreateEntity(); unique.AddFrameCounter(0); unique.AddRandom(new BigBattle.Random(battleConfig.randomSeed)); unique.isBattleEnd = false; unique.AddBattleReport(new BattleReport(battleConfig)); // actors int unitIndex = 1; int teamIndex = 1; foreach (var team in battleConfig.battleTeams) { foreach (var unit in team.battleUnits) { var e = _context.CreateEntity(); e.AddBattleUnitId(unitIndex); e.AddBattleTeam(teamIndex); e.AddBattleUnit(unit); e.AddPosition(team.birthPlace); e.AddTargetPos(battleConfig.mapCenter); e.AddDirection(Vec2.zero); e.AddSpeed(unit.moveSpeed); e.isMoving = true; unitIndex++; } teamIndex++; } }
private void SetActiveBattleConfig() { // Get the battlenumber where we can load the right battle config with (name, monster setup) int activeBattleNumber = PlayerPrefs.GetInt("active_battle", 1); // default value, incase something goes wrong activeBattleConfig = battleConfigs[activeBattleNumber - 1]; }
public override void dispose() { base.dispose(); _state = BattleStateType.Wait; _timeTick = -1; _config = null; }
public BattleConfigViewModel(IMapService mapService, IJumpService jumpService) { _model = new BattleConfig(); MapItems = mapService.GetMapIds(); JumpToMapCommand = new RelayCommand <MapId>(id => jumpService.JumpTo(MapSelectorEditorModule.Id, (int)id)); }
public static Mission OpenMission(IEnhancedBattleTestCombatant playerParty, IEnhancedBattleTestCombatant enemyParty, BattleConfig config, string map) { if (config.PlayerTeamConfig.HasGeneral) { Game.Current.PlayerTroop = config.PlayerTeamConfig.General.CharacterObject; } if (config.BattleTypeConfig.BattleType == BattleType.Siege && config.PlayerTeamConfig.HasGeneral) { var attackerSiegeWeaponCount = GetSiegeWeaponCount(config.SiegeMachineConfig.AttackerMeleeMachines) .Union(GetSiegeWeaponCount(config.SiegeMachineConfig.AttackerRangedMachines)) .ToDictionary(pair => pair.Key, pair => pair.Value); var defenderSiegeWeaponCount = GetSiegeWeaponCount(config.SiegeMachineConfig.DefenderMachines); int breachedWallCount = config.MapConfig.BreachedWallCount; var hitPointPercentages = new float[2]; switch (breachedWallCount) { case 0: hitPointPercentages[0] = 1; hitPointPercentages[1] = 1; break; case 1: int i = MBRandom.RandomInt(2); hitPointPercentages[i] = 0; hitPointPercentages[1 - i] = 1; break; default: hitPointPercentages[0] = 0; hitPointPercentages[1] = 0; break; } return(OpenEnhancedBattleTestSiege(map, config, playerParty, enemyParty, hitPointPercentages, attackerSiegeWeaponCount, defenderSiegeWeaponCount)); } else if (config.BattleTypeConfig.BattleType == BattleType.Field || config.BattleTypeConfig.BattleType == BattleType.Village) { //var characterObject = (config.PlayerTeamConfig.General as SPCharacterConfig)?.ActualCharacterObject; //EnhancedBattleTestPartyController.PlayerParty.Party.Owner = characterObject.HeroObject; //foreach(BasicCharacterObject player in playerParty.Characters) //{ // if (player.IsPlayerCharacter) // { // playerchar = player; // break; // } //} return(OpenEnhancedBattleTestField(map, config, playerParty, enemyParty)); } return(null); }
public static void Render(this IConsole console, BattleConfig model, BattleConfigId id) { console.WriteTitle($"{id}"); console.WriteProperty("Map", model.MapId); console.WriteProperty("Number Of Turns", model.NumberOfTurns); console.WriteProperty("Victory Condition", model.VictoryCondition); console.WriteProperty("Defeat Condition", model.DefeatCondition); console.WriteProperty("Upper Atmosphere Color", model.UpperAtmosphereColor); console.WriteProperty("Middle Atmosphere Color", model.MiddleAtmosphereColor); console.WriteProperty("Lower Atmosphere Color", model.LowerAtmosphereColor); }
public static Mission OpenMission(BattleConfig config, string mapName) { //TODO: implement in multiplayer mode if (EnhancedBattleTestSubModule.IsMultiplayer) { return(OpenMultiplayerMission(config, mapName)); } else { return(OpenSingleplayerMission(config, mapName)); } }
public static void AssertBattleModifierAccuracy(int i) { //Arrange BattleConfig battleConfig = (BattleConfig)BattleSimulatorTestData.BattleTestCases[i][0]; RealBattleResult realBattleResult = (RealBattleResult)BattleSimulatorTestData.BattleTestCases[i][1]; //Act BattleResult result = GameData.SimulateBattle(battleConfig); //Assert Assert.Equal(realBattleResult.AtkBattleModifier, result.AtkBattleModifier); Assert.Equal(realBattleResult.DefModifierBeforeBattle, result.DefModifierBeforeBattle); Assert.Equal(realBattleResult.DefModifierDuringBattle, result.DefModifierDuringBattle); }
// Use this for initialization private void Start() { string jsonData = File.ReadAllText(filePath); BattleConfig battleConfig = JsonUtility.FromJson <BattleConfig>(jsonData); MapConfig mapConfig = battleConfig.map; initializeMap(mapConfig); //initializeTurnTracker(); //initializeUnits(battleConfig.Allies, battleConfig.Enemies); EventManager.addEventListener("Save", save); }
public void preInit() { int battleID; if ((battleID = _scene.getConfig().battleID) > 0) { _config = BattleConfig.get(battleID); enabled = true; } else { enabled = false; } }
/* * public static Vector3 CalcUnitPos(DataConfig.TEAM team, int slotIndex) * { * BattleGame game = BattleGame.instance; * * float FIELD_WIDTH = game.mapGrid.GetMapWidth (); * float FIELD_HEIGHT = game.mapGrid.GetMapHeight (); * * float FIELD_MIN_X = MapGrid.GRID_SIZE; * float FIELD_MAX_X = FIELD_MIN_X + MapGrid.GRID_SIZE * 2; * float FIELD_MIN_Y = FIELD_HEIGHT / 2 - MapGrid.GRID_SIZE * 2; * float FIELD_MAX_Y = FIELD_HEIGHT / 2 + MapGrid.GRID_SIZE * 2; * * float A0 = FIELD_MIN_X / FIELD_WIDTH; * float A1 = FIELD_MAX_X / FIELD_WIDTH; * float A = A1 - A0; * * float B0 = FIELD_MIN_Y / FIELD_HEIGHT; * float B1 = FIELD_MAX_Y / FIELD_HEIGHT; * float B = B1 - B0; * * * // * int col = DataConfig.CalcSlotCol (slotIndex); * int row = DataConfig.CalcSlotRow (slotIndex); * * float kx = A1 - (float)row / (DataConfig.FORMATION_TOTAL_LINES - 1) * A; * float ky = B1 - (float)col / (DataConfig.FORMATION_LINE_SLOT - 1) * B; * * Vector3 pos = new Vector3 (); * pos.z = FIELD_HEIGHT * (ky); * * if (team == DataConfig.TEAM.MY) { * pos.x = FIELD_WIDTH * (kx); * } else { * pos.x = FIELD_WIDTH * (1 - kx); * } * * return pos; * } */ public static void AddUnitToLayer(GameObject obj, BattleConfig.LAYER layer) { GameObject battleField = GameObject.FindWithTag(AppConfig.TAB_BATTLE_FIELD); if (battleField != null) { string layerName = BattleConfig.GetLayerName(layer); if (layerName != null) { Transform layerUnits = battleField.transform.Find(layerName); obj.transform.parent = layerUnits.transform; } } }
public void AccessorsReturnCorrectValues() { BattleConfig a = new BattleConfig(new byte[] { 0x01, 0xB8, 0x68, 0x7C, 0x4D, 0x80, 0x33, 0x02, 0x00, 0x80, 0xA4, 0x14, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00 }); a.MapId.Should().Be(new MapId(1, 0)); a.UpperAtmosphereColor.Should().Be(new Rgb15(23, 8, 3)); a.MiddleAtmosphereColor.Should().Be(new Rgb15(13, 2, 0)); a.LowerAtmosphereColor.Should().Be(new Rgb15(7, 3, 1)); a.VictoryCondition.Should().Be(BattleVictoryConditionFlags.DefeatAllEnemies); a.DefeatCondition.Should().Be(BattleVictoryConditionFlags.DefeatAllEnemies); a.NumberOfTurns.Should().Be(20); }
public static Mission OpenMultiplayerMission(BattleConfig config, string map) { var playerCulture = Utility.GetCulture(config.PlayerTeamConfig); var playerSide = config.BattleTypeConfig.PlayerSide; var enemyCulture = Utility.GetCulture(config.EnemyTeamConfig); var enemySide = playerSide.GetOppositeSide(); MPCombatant[] parties = new MPCombatant[2] { MPCombatant.CreateParty(playerSide, playerCulture, config.PlayerTeamConfig, true), MPCombatant.CreateParty(enemySide, enemyCulture, config.EnemyTeamConfig, false) }; return(OpenMission(parties[0], parties[1], config, map)); }
protected override IEnumerator Initialize(AsyncProcessor asyncProcessor, LoadingState state) { AP = asyncProcessor; state.Callback("PreparingBattle", 0); yield return(null); config = (BattleConfig)GameState.sharedData["BattleConfig"]; playerCamera.GetComponentInChildren <Camera>(true).farClipPlane = 10000000; teams = new ShipTeam[] { new ShipTeam(0, new IBattleGoal[0], GoalReached), new ShipTeam(1, new IBattleGoal[0], GoalReached), }; switch (config.type) { case BattleType.DeathMatch: GenerateDeathMatch(); break; case BattleType.BattleForTheStar: GenerateBatlleForTheSun(); break; case BattleType.Escort: GenerateEscort(); break; } _updaters.Add(new MyMonoBehaviourUpdater(otherObjects)); _updaters.Add(new LastUpdateShipUpdater()); base.SetBattle( center, ships, teams, _updaters ); base.navigation = navigation; AP = null; state.Callback("EndLoading", 1f); }
public static void AssertBattleSimulatorAccuracy(int @case) { //Arrange BattleConfig battleConfig = (BattleConfig)BattleSimulatorTestData.BattleTestCases[@case][0]; RealBattleResult realBattleResult = (RealBattleResult)BattleSimulatorTestData.BattleTestCases[@case][1]; //Act BattleResult result = GameData.SimulateBattle(battleConfig); //Assert Assert.Equal(realBattleResult.AtkUnits, result.AtkUnits); Assert.Equal(realBattleResult.AtkUnitsLost, result.AtkUnitsLost); Assert.Equal(realBattleResult.DefUnits, result.DefUnits); Assert.Equal(realBattleResult.DefUnitsLost, result.DefUnitsLost); Assert.Equal(realBattleResult.WallLevelBefore, result.WallLevelBefore); Assert.Equal(realBattleResult.WallLevelAfter, result.WallLevelAfter); Assert.Equal(realBattleResult.WallLevelFinal, result.WallLevelFinal); }
public void Init(BattleConfig config) { battleActions = new Queue <BattleAction>(); battleCharacters = new List <BattleCharacter>(); states = new Stack <IBattleManagerState>(); for (int i = 0; i < config.playerCharacters.Length; i++) { // spawn characters at appropriate positions } for (int i = 0; i < config.enemyCharacters.Length; i++) { // spawn enemies at appropriate positions } states.Push(config.initialState ?? new IntroBattleManagerState()); states.Peek().OnEnter(this); }
void Start() { //Get last or initialize new config config = (BattleConfig)GameState.sharedData["BattleConfig", new BattleConfig()]; table.SetModel <ValueOption>( vo => vo.optionName, vo => vo); table.AddRange(config.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public).Select(f => new ValueOption() { optionName = f.Name, value = f.GetValue(config), setAction = v => f.SetValue(config, v) } ).ToArray()); GetComponent <ThemeListener>().UpdateTheme(); }
public void Init(BattleConfig battleConfig) { Service.Instance.InitInjections(); var contexts = Contexts.sharedInstance; contexts.server.CreateEntity().AddBattleConfig(battleConfig); _systems = new Feature("Server"); _systems.Add(new SBattleInitSystem(contexts)); _systems.Add(new STimerSystem(contexts)); _systems.Add(new SBattleStateSystem(contexts)); _systems.Add(new STargetingSystem(contexts)); _systems.Add(new SDirectionSystem(contexts)); _systems.Add(new SSpeedSystem(contexts)); _systems.Add(new SMoveSystem(contexts)); _systems.Add(new SBattleActionSystem(contexts)); _systems.Add(new SBattleActionCleanUpSystem(contexts)); _systems.Initialize(); }
public void AccessorsSetCorrectValues() { BattleConfig a = new BattleConfig() { MapId = new MapId(10, 1), UpperAtmosphereColor = new Rgb15(9, 7, 21), MiddleAtmosphereColor = new Rgb15(20, 19, 16), LowerAtmosphereColor = new Rgb15(12, 11, 1), VictoryCondition = BattleVictoryConditionFlags.ClaimAllBanners | BattleVictoryConditionFlags.HoldAllBannersFor5Turns, DefeatCondition = BattleVictoryConditionFlags.ClaimAllBanners, NumberOfTurns = 17 }; a.MapId.Should().Be(new MapId(10, 1)); a.UpperAtmosphereColor.Should().Be(new Rgb15(9, 7, 21)); a.MiddleAtmosphereColor.Should().Be(new Rgb15(20, 19, 16)); a.LowerAtmosphereColor.Should().Be(new Rgb15(12, 11, 1)); a.VictoryCondition.Should().Be(BattleVictoryConditionFlags.ClaimAllBanners | BattleVictoryConditionFlags.HoldAllBannersFor5Turns); a.DefeatCondition.Should().Be(BattleVictoryConditionFlags.ClaimAllBanners); a.NumberOfTurns.Should().Be(17); }
private void Awake() { _battleConfig = JsonConverter.LoadBattleConfig(); //lambda expression subscribed to the delegate. //I used lambda here even tho the func is a little long for an inline func just to show what a lambda is //(lambda = unnamed func here, delegate = "monsterDestroy" which broadcasts events to 'subscribed' functions) //tip: another possible func to subscribe to "monsterDestroy" could include a death animation func in an Animation Controller class monsterDestroy = (Monster monsterToDestroy) => { _waveMonstersKilled++; if (_waveMonstersKilled >= _battleConfig.waveConfigs[_currentWave].monsterConfigs.Count) //next wave { _waveMonstersKilled = 0; _currentWave++; _currentWave %= _battleConfig.waveConfigs.Count; // TODO: you'd actually stop the battle scene after last wave, or a win screen, etc } GetNextMonster(); UpdateUI(); }; }
public static Mission OpenMission(IEnhancedBattleTestCombatant playerParty, IEnhancedBattleTestCombatant enemyParty, BattleConfig config, string map) { if (config.BattleTypeConfig.BattleType == BattleType.Siege) { var attackerSiegeWeaponCount = GetSiegeWeaponCount(config.SiegeMachineConfig.AttackerMeleeMachines) .Union(GetSiegeWeaponCount(config.SiegeMachineConfig.AttackerRangedMachines)) .ToDictionary(pair => pair.Key, pair => pair.Value); var defenderSiegeWeaponCount = GetSiegeWeaponCount(config.SiegeMachineConfig.DefenderMachines); int breachedWallCount = config.MapConfig.BreachedWallCount; var hitPointPercentages = new float[2]; switch (breachedWallCount) { case 0: hitPointPercentages[0] = 1; hitPointPercentages[1] = 1; break; case 1: int i = MBRandom.RandomInt(2); hitPointPercentages[i] = 0; hitPointPercentages[1 - i] = 1; break; default: hitPointPercentages[0] = 0; hitPointPercentages[1] = 0; break; } return(OpenEnhancedBattleTestSiege(map, config, playerParty, enemyParty, hitPointPercentages, attackerSiegeWeaponCount, defenderSiegeWeaponCount)); } else { return(OpenEnhancedBattleTestField(map, config, playerParty, enemyParty)); } }
public static void GoToBattle(BattleConfig config) { sharedData["BattleConfig"] = config; GoToSpace(); }
public CommanderLogic(BattleConfig config) { _config = config; }
public static bool TeammateCountBattle(ref BattleFactory __instance, BattleConfig config, IEnumerable <BattleCreateInfo> __result) { bBattle = true; return(true); }
public void SetModel(BattleConfigId id, BattleConfig model) { Id = id; _model = model; RaiseAllPropertiesChanged(); }
public void configure(IConfig config) { BattleConfig battleConfig = config as BattleConfig; }
public static Mission OpenEnhancedBattleTestSiege( string scene, BattleConfig config, IEnhancedBattleTestCombatant playerParty, IEnhancedBattleTestCombatant enemyParty, float[] wallHitPointPercentages, Dictionary <SiegeEngineType, int> siegeWeaponsCountOfAttackers, Dictionary <SiegeEngineType, int> siegeWeaponsCountOfDefenders, bool isSallyOut = false, bool isReliefForceAttack = false, float timeOfDay = 6f) { bool hasAnySiegeTower = siegeWeaponsCountOfAttackers.ContainsKey(DefaultSiegeEngineTypes.SiegeTower); string levelString; switch (config.MapConfig.SceneLevel) { case 1: levelString = "level_1"; break; case 2: levelString = "level_2"; break; case 3: levelString = "level_3"; break; default: levelString = ""; break; } var sceneLevelString = !(isSallyOut | isReliefForceAttack) ? levelString + " siege" : levelString + " sally"; var playerSide = config.BattleTypeConfig.PlayerSide; var enemySide = config.BattleTypeConfig.PlayerSide.GetOppositeSide(); var player = config.PlayerTeamConfig.General; if (player == null) { return(null); } bool hasPlayer = config.PlayerTeamConfig.HasGeneral; bool isPlayerAttacker = playerSide == BattleSideEnum.Attacker; IMissionTroopSupplier[] troopSuppliers = new IMissionTroopSupplier[2]; bool isMultiplayer = EnhancedBattleTestSubModule.IsMultiplayer; troopSuppliers[(int)playerSide] = CreateTroopSupplier(playerParty, isMultiplayer, true); troopSuppliers[(int)enemySide] = CreateTroopSupplier(enemyParty, isMultiplayer, false); bool isPlayerGeneral = config.BattleTypeConfig.PlayerType == PlayerType.Commander || !hasPlayer; bool isPlayerSergeant = hasPlayer && config.BattleTypeConfig.PlayerType == PlayerType.Sergeant; List <CharacterObject> charactersInPlayerSideByPriority = null; List <CharacterObject> charactersInEnemySideByPriority = null; string playerTeamGeneralName = null; string enemyTeamGeneralName = null; if (!isMultiplayer) { var playerCharacter = player.CharacterObject as CharacterObject; if (playerCharacter == null) { return(null); } charactersInPlayerSideByPriority = Utility.OrderHeroesByPriority(config.PlayerTeamConfig); var playerGeneral = hasPlayer && isPlayerGeneral ? playerCharacter : (hasPlayer && charactersInPlayerSideByPriority.First() == playerCharacter ? charactersInPlayerSideByPriority.Skip(1).FirstOrDefault() : charactersInPlayerSideByPriority.FirstOrDefault()); if (playerGeneral != null) { charactersInPlayerSideByPriority.Remove(playerGeneral); playerTeamGeneralName = TextObject.ConvertToStringList(new List <TextObject>() { playerGeneral.Name }).FirstOrDefault(); } charactersInEnemySideByPriority = Utility.OrderHeroesByPriority(config.EnemyTeamConfig); var enemyGeneral = charactersInEnemySideByPriority.FirstOrDefault(); if (enemyGeneral != null) { charactersInEnemySideByPriority.Remove(enemyGeneral); enemyTeamGeneralName = TextObject.ConvertToStringList(new List <TextObject>() { enemyGeneral.Name }).FirstOrDefault(); } } AtmosphereInfo atmosphereInfo = CreateAtmosphereInfoForMission(config.MapConfig.Season, timeOfDay); var attackerSiegeWeapons = GetSiegeWeaponTypes(siegeWeaponsCountOfAttackers); var defenderSiegeWeapons = GetSiegeWeaponTypes(siegeWeaponsCountOfDefenders); return(MissionState.OpenNew("EnhancedBattleTestSiegeBattle", new MissionInitializerRecord(scene) { PlayingInCampaignMode = false, AtmosphereOnCampaign = atmosphereInfo, SceneLevels = sceneLevelString, TimeOfDay = timeOfDay }, mission => { List <MissionBehaviour> missionBehaviourList = new List <MissionBehaviour> { new CommanderLogic(config), new BattleSpawnLogic(isSallyOut ? "sally_out_set" : (isReliefForceAttack ? "relief_force_attack_set" : "battle_set")), new MissionOptionsComponent(), new BattleEndLogic(), new MissionCombatantsLogic(null, playerParty, !isPlayerAttacker ? playerParty : enemyParty, isPlayerAttacker ? playerParty : enemyParty, !isSallyOut ? Mission.MissionTeamAITypeEnum.Siege : Mission.MissionTeamAITypeEnum.SallyOut, isPlayerSergeant), new SiegeMissionPreparationHandler(isSallyOut, isReliefForceAttack, wallHitPointPercentages, hasAnySiegeTower), new MissionAgentSpawnLogic(troopSuppliers, playerSide), new BattleObserverMissionLogic(), new CustomBattleAgentLogic(), new AgentBattleAILogic(), new AmmoSupplyLogic(new List <BattleSideEnum> { BattleSideEnum.Defender }), new AgentVictoryLogic(), new MissionAgentPanicHandler(), new SiegeMissionController( attackerSiegeWeapons, defenderSiegeWeapons, isPlayerAttacker, isSallyOut), new SiegeDeploymentHandler(isPlayerAttacker, isPlayerAttacker ? attackerSiegeWeapons : defenderSiegeWeapons), new MissionBoundaryPlacer(), new MissionBoundaryCrossingHandler(), new AgentMoraleInteractionLogic(), new HighlightsController(), new BattleHighlightsController(), new AssignPlayerRoleInTeamMissionController(isPlayerGeneral, isPlayerSergeant, hasPlayer, charactersInPlayerSideByPriority?.Select(character => character.StringId).ToList()), new CreateBodyguardMissionBehavior( isPlayerAttacker ? playerTeamGeneralName : enemyTeamGeneralName, !isPlayerAttacker ? playerTeamGeneralName : enemyTeamGeneralName, null, null, false), }; if (isSallyOut) { missionBehaviourList.Add(new EnhancedBattleTestSiegeSallyOutMissionSpawnHandler( isPlayerAttacker ? enemyParty : playerParty, isPlayerAttacker ? playerParty : enemyParty)); } else { missionBehaviourList.Add(new EnhancedBattleTestSiegeMissionSpawnHandler( isPlayerAttacker ? enemyParty : playerParty, isPlayerAttacker ? playerParty : enemyParty)); missionBehaviourList.Add(new AgentFadeOutLogic()); } return missionBehaviourList; })); }
public static Mission OpenEnhancedBattleTestField( string scene, BattleConfig config, IEnhancedBattleTestCombatant playerParty, IEnhancedBattleTestCombatant enemyParty, float timeOfDay = 12f) { var playerSide = config.BattleTypeConfig.PlayerSide; var enemySide = config.BattleTypeConfig.PlayerSide.GetOppositeSide(); var player = config.PlayerTeamConfig.General; if (player == null) { return(null); } bool hasPlayer = config.PlayerTeamConfig.HasGeneral; bool isPlayerAttacker = playerSide == BattleSideEnum.Attacker; IMissionTroopSupplier[] troopSuppliers = new IMissionTroopSupplier[2]; bool isMultiplayer = EnhancedBattleTestSubModule.IsMultiplayer; troopSuppliers[(int)playerSide] = CreateTroopSupplier(playerParty, isMultiplayer, true); troopSuppliers[(int)enemySide] = CreateTroopSupplier(enemyParty, isMultiplayer, false); bool isPlayerGeneral = config.BattleTypeConfig.PlayerType == PlayerType.Commander; bool isPlayerSergeant = hasPlayer && config.BattleTypeConfig.PlayerType == PlayerType.Sergeant; List <CharacterObject> charactersInPlayerSideByPriority = null; List <CharacterObject> charactersInEnemySideByPriority = null; string playerTeamGeneralName = null; string enemyTeamGeneralName = null; if (!isMultiplayer) { var playerCharacter = player.CharacterObject as CharacterObject; if (playerCharacter == null) { return(null); } charactersInPlayerSideByPriority = Utility.OrderHeroesByPriority(config.PlayerTeamConfig); var playerGeneral = hasPlayer && isPlayerGeneral ? playerCharacter : (hasPlayer && charactersInPlayerSideByPriority.First() == playerCharacter ? charactersInPlayerSideByPriority.Skip(1).FirstOrDefault() : charactersInPlayerSideByPriority.FirstOrDefault()); if (playerGeneral != null) { charactersInPlayerSideByPriority.Remove(playerGeneral); playerTeamGeneralName = TextObject.ConvertToStringList(new List <TextObject>() { playerGeneral.Name }).FirstOrDefault(); } charactersInEnemySideByPriority = Utility.OrderHeroesByPriority(config.EnemyTeamConfig); var enemyGeneral = charactersInEnemySideByPriority.FirstOrDefault(); if (enemyGeneral != null) { charactersInEnemySideByPriority.Remove(enemyGeneral); enemyTeamGeneralName = TextObject.ConvertToStringList(new List <TextObject>() { enemyGeneral.Name }).FirstOrDefault(); } } AtmosphereInfo atmosphereInfo = CreateAtmosphereInfoForMission(config.MapConfig.Season, timeOfDay); return(MissionState.OpenNew("EnhancedBattleTestFieldBattle", new MissionInitializerRecord(scene) { DoNotUseLoadingScreen = false, PlayingInCampaignMode = false, AtmosphereOnCampaign = atmosphereInfo, SceneLevels = "", TimeOfDay = timeOfDay }, mission => new MissionBehaviour[] { new CommanderLogic(config), new MissionOptionsComponent(), new BattleEndLogic(), new MissionCombatantsLogic(null, playerParty, !isPlayerAttacker ? playerParty : enemyParty, isPlayerAttacker ? playerParty : enemyParty, Mission.MissionTeamAITypeEnum.FieldBattle, isPlayerSergeant), new BattleObserverMissionLogic(), new CustomBattleAgentLogic(), new MissionAgentSpawnLogic(troopSuppliers, playerSide), new EnhancedBattleTestMissionSpawnHandler(!isPlayerAttacker ? playerParty : enemyParty, isPlayerAttacker ? playerParty : enemyParty), new AgentBattleAILogic(), new AgentVictoryLogic(), new MissionAgentPanicHandler(), new MissionHardBorderPlacer(), new MissionBoundaryPlacer(), new MissionBoundaryCrossingHandler(), new BattleMissionAgentInteractionLogic(), new FieldBattleController(), new AgentFadeOutLogic(), new AgentMoraleInteractionLogic(), new AssignPlayerRoleInTeamMissionController(isPlayerGeneral, isPlayerSergeant, isPlayerInArmy: false, isPlayerSergeant ? Enumerable.Repeat(config.PlayerTeamConfig.General.CharacterObject.StringId, 1).ToList() : new List <string>()), new CreateBodyguardMissionBehavior( isPlayerAttacker ? playerTeamGeneralName : enemyTeamGeneralName, !isPlayerAttacker ? playerTeamGeneralName : enemyTeamGeneralName, null, null, true), new HighlightsController(), new BattleHighlightsController() })); }