public IEnumerable <Army> GetArmiesInEncounterZone(WorldPosition attackerPosition, WorldOrientation attackDirection) { int deploymentAreaWidth = Amplitude.Unity.Runtime.Runtime.Registry.GetValue <int>("Gameplay/Battle/DeploymentAreaWidth", 3); int deploymentAreaDepth = Amplitude.Unity.Runtime.Runtime.Registry.GetValue <int>("Gameplay/Battle/DeploymentAreaDepth", 2); DeploymentArea area = new DeploymentArea(attackerPosition, attackDirection, this.world.WorldParameters); area.Initialize(deploymentAreaWidth, deploymentAreaDepth); WorldArea attackerDeploymentArea = new WorldArea(area.GetWorldPositions(this.world.WorldParameters)); WorldOrientation battleZone2Orientation = attackDirection.Rotate(3); WorldPosition center2 = WorldPosition.GetNeighbourTile(attackerPosition, attackDirection, 1); area = new DeploymentArea(center2, battleZone2Orientation, this.world.WorldParameters); area.Initialize(deploymentAreaWidth, deploymentAreaDepth); WorldArea defenderDeploymentArea = new WorldArea(area.GetWorldPositions(this.world.WorldParameters)); WorldArea battleArea = new WorldArea(attackerDeploymentArea.Grow(this.world.WorldParameters)); battleArea = battleArea.Union(defenderDeploymentArea.Grow(this.world.WorldParameters)); foreach (WorldPosition worldPosition in battleArea) { Army army = this.worldAtlasArmies.GetValue(worldPosition); if (army != null) { yield return(army); } } yield break; }
private void GenerateBattleZone(WorldPosition attackerPosition, WorldOrientation orientation) { World world = (base.GameService.Game as global::Game).World; IGlobalPositionningService globalPositionningService = null; if (globalPositionningService == null) { WorldView worldView = Services.GetService <Amplitude.Unity.View.IViewService>().CurrentView as WorldView; if (worldView != null && worldView.CurrentWorldViewTechnique != null) { globalPositionningService = worldView.CurrentWorldViewTechnique.Services.GetService <IGlobalPositionningService>(); } } if (!attackerPosition.IsValid) { return; } WorldPosition worldPosition = attackerPosition; DeploymentArea deploymentArea = new DeploymentArea(worldPosition, orientation, world.WorldParameters); deploymentArea.Initialize(this.DeploymentAreaWidth, this.DeploymentAreaDepth); WorldArea worldArea = new WorldArea(deploymentArea.GetWorldPositions(world.WorldParameters)); WorldOrientation forward = orientation.Rotate(3); DeploymentArea deploymentArea2 = new DeploymentArea(WorldPosition.GetNeighbourTile(worldPosition, orientation, 1), forward, world.WorldParameters); deploymentArea2.Initialize(this.DeploymentAreaWidth, this.DeploymentAreaDepth); WorldArea worldArea2 = new WorldArea(deploymentArea2.GetWorldPositions(world.WorldParameters)); WorldArea worldArea3 = new WorldArea(worldArea.Grow(world.WorldParameters)); worldArea3 = worldArea3.Union(worldArea2.Grow(world.WorldParameters)); WorldPatch worldPatch = globalPositionningService.GetWorldPatch(attackerPosition); this.GenerateGeometry(worldPatch, attackerPosition, worldArea3, worldArea, worldArea2); }