public IEnumerable <Order> Handle(PositionalDeployment Deployment) { var deployments = new Dictionary <Unit, Tile>(); var seeds = Deployment.Units.Where( i => i.Position == null && Root.UnitAssignments.GetAssignments(i).All(j => j.Subject != i)).ToList(); seeds.Sort(new FluentComparator <Unit>(i => i.Configuration.UnitClass == UnitClass.COMMAND_POST) .ThenCompare(i => i.Configuration.SpotRange) .Invert()); var coveredTiles = new HashSet <Tile>(); foreach (var unit in seeds) { var tile = Root.Match.GetMap().TilesEnumerable .Where(i => Deployment.Validate(unit, i) == OrderInvalidReason.NONE) .ArgMax(i => ScoreSeedTile(unit, i, coveredTiles)); deployments.Add(unit, tile); foreach (var t in unit.GetFieldOfSight(AttackMethod.DIRECT_FIRE, tile)) { coveredTiles.Add(t.Final); } yield return(new PositionalDeployOrder(unit, tile)); } var defenders = Deployment.Units .SelectMany(i => Root.UnitAssignments.GetAssignments(i).Where( j => j.Subject == i && j.AssignmentType == UnitAssignmentType.DEFENDER)) .ToList(); foreach (var assignment in defenders) { var tile = Root.Match.GetMap().TilesEnumerable .Where(i => Deployment.Validate(assignment.Subject, i) == OrderInvalidReason.NONE) .ArgMax(i => ScoreDefenseTile(assignment, i, deployments)); deployments.Add(assignment.Subject, tile); yield return(new PositionalDeployOrder(assignment.Subject, tile)); } var carriers = Deployment.Units .SelectMany(i => Root.UnitAssignments.GetAssignments(i).Where( j => j.Subject == i && j.AssignmentType == UnitAssignmentType.CARRIER)) .ToList(); foreach (var assignment in carriers) { var tile = Root.Match.GetMap().TilesEnumerable .Where(i => Deployment.Validate(assignment.Subject, i) == OrderInvalidReason.NONE) .ArgMax(i => ScoreCarrierTile(assignment, i, deployments)); deployments.Add(assignment.Subject, tile); yield return(new PositionalDeployOrder(assignment.Subject, tile)); } }
public PositionalDeploymentPage(PositionalDeployment Deployment, UnitConfigurationRenderer Renderer) { _Deployment = Deployment; _Renderer = Renderer; _Selection = new ValuedScrollCollection <GroupedUnitSelectionOption, HomogenousStackView>("deployment-select"); _Selection.OnChange += (sender, e) => { if (OnSelectedStack != null) { OnSelectedStack(this, EventArgs.Empty); } }; foreach (var g in Deployment.Units.Where(i => i.Position == null).GroupBy(i => i.Configuration)) { _Selection.Add( new GroupedUnitSelectionOption( "deployment-selection-option", "deployment-selection-option-overlay", g, _Renderer)); } _Selection.Position = new Vector2f(0, 48); Add(_Selection); }
public PositionalDeploymentMicrocontroller( HumanMatchPlayerController Controller, PositionalDeployment Deployment) : base(Controller) { _Deployment = Deployment; }