Exemplo n.º 1
0
        public IEnumerable <Order> Handle(ConvoyDeployment Deployment)
        {
            var order = Deployment.Units
                        .Where(i => !Root.UnitAssignments.GetAssignments(i).Any(
                                   j => j.Object == i && j.AssignmentType == UnitAssignmentType.CARRIER))
                        .ToList();

            order.Sort(new FluentComparator <Unit>(i => i.Configuration.IsVehicle)
                       .ThenCompare(i => i.Configuration.IsArmored)
                       .ThenCompare(i => i.Configuration.UnitClass != UnitClass.TRANSPORT)
                       .ThenCompare(i => i.Configuration.Movement)
                       .Invert());

            foreach (var assignment in order.SelectMany(
                         i => Root.UnitAssignments.GetAssignments(i)).Where(i => i.AssignmentType == UnitAssignmentType.CARRIER))
            {
                yield return(new LoadOrder(assignment.Subject, assignment.Object, false));
            }
            yield return(new ConvoyOrderDeployOrder(Deployment, order));

            var entryTiles = Root.Match.GetMap().TilesEnumerable.Where(
                i => i.Configuration.HasPathOverlay(TilePathOverlay.ROAD) &&
                Deployment.Validate(i) == OrderInvalidReason.NONE).ToList();

            yield return(new EntryTileDeployOrder(
                             Deployment,
                             entryTiles.ArgMax(
                                 i => Root.Random.NextDouble() - (.9 + Root.Random.NextDouble() * .1)
                                 * order.Sum(j => Root.TileEvaluations.GetThreatRating(i, j)))));
        }
Exemplo n.º 2
0
        public ConvoyDeploymentPage(
            ConvoyDeployment Deployment, UnitConfigurationRenderer Renderer, DeploymentPane Pane)
        {
            _Deployment = Deployment;
            _Renderer   = Renderer;

            _MoveUpButton.OnClick   += HandleMoveUp;
            _MoveDownButton.OnClick += HandleMoveDown;
            _LoadButton.OnClick     += HandleLoadButton;
            _UnloadButton.OnClick   += HandleUnloadButton;

            _Selection = new ValuedScrollCollection <SingularUnitSelectionOption, StackView>("deployment-select");

            var units = Deployment.Units.ToList();

            units.Sort(new FluentComparator <Unit>(i => i.Configuration.IsVehicle)
                       .ThenCompare(i => i.Configuration.IsArmored)
                       .ThenCompare(i => i.Configuration.UnitClass != UnitClass.TRANSPORT)
                       .ThenCompare(i => i.Configuration.Movement)
                       .Invert());
            foreach (Unit u in units)
            {
                u.OnLoad   += HandleLoad;
                u.OnUnload += HandleUnload;

                var option = new SingularUnitSelectionOption("deployment-selection-option", u, _Renderer);
                _Selection.Add(option);
            }

            _Selection.Position      = new Vector2f(0, 48);
            _LoadButton.Position     = new Vector2f(0, Pane.Size.Y - _LoadButton.Size.Y - 32);
            _UnloadButton.Position   = new Vector2f(_LoadButton.Size.X + 8, Pane.Size.Y - _UnloadButton.Size.Y - 32);
            _MoveUpButton.Position   = new Vector2f(0, Pane.Size.Y - _LoadButton.Size.Y - _MoveUpButton.Size.Y - 36);
            _MoveDownButton.Position = new Vector2f(
                _MoveUpButton.Size.X + 8, Pane.Size.Y - _UnloadButton.Size.Y - _MoveDownButton.Size.Y - 36);

            Add(_Selection);
            Add(_LoadButton);
            Add(_UnloadButton);
            Add(_MoveUpButton);
            Add(_MoveDownButton);
        }
Exemplo n.º 3
0
 public ConvoyOrderDeployOrder(ConvoyDeployment Deployment, IEnumerable <Unit> ConvoyOrder)
 {
     this.Deployment  = Deployment;
     this.ConvoyOrder = ConvoyOrder;
 }
 public EntryTileDeployOrder(ConvoyDeployment Deployment, Tile Tile)
 {
     this.Deployment = Deployment;
     this.Tile       = Tile;
 }
 public ConvoyDeploymentMicrocontroller(HumanMatchPlayerController Controller, ConvoyDeployment Deployment)
     : base(Controller)
 {
     _Deployment = Deployment;
 }