public void ClearMinefield()
        {
            if (SelectedUnit == null)
            {
                return;
            }

            var onMine =
                SelectedUnit.Position.Units.FirstOrDefault(
                    i => i.Configuration.UnitClass == UnitClass.MINEFIELD);

            if (onMine != null)
            {
                ClearMinefield(onMine);
            }
            else
            {
                var mines =
                    SelectedUnit.Position.Neighbors()
                    .SelectMany(i => i.Units)
                    .Where(i => i.Configuration.UnitClass == UnitClass.MINEFIELD);
                if (mines.Count() == 1)
                {
                    ClearMinefield(mines.First());
                }
                else if (mines.Count() > 1)
                {
                    var pane = new SelectPane <Unit>("Clear Minefield", mines);
                    pane.OnItemSelected += ClearMinefield;
                    SetPane(pane);
                }
            }
        }
 void HandleLoad(object Sender, EventArgs E)
 {
     if (_DeploymentPage.SelectedUnit != null)
     {
         var units = Deployment.Units.Where(
             i => _DeploymentPage.SelectedUnit.CanLoad(i, false) == OrderInvalidReason.NONE);
         if (units.Count() > 0)
         {
             Clear();
             var pane = new SelectPane <Unit>("Load Unit", units);
             pane.OnItemSelected += LoadUnit;
             _LoadUnitPane        = pane;
             _Controller.AddPane(_LoadUnitPane);
         }
     }
 }
        public void Evacuate()
        {
            if (SelectedUnit == null)
            {
                return;
            }

            var directions = GetEvacuateDirections().ToList();

            if (directions.Count == 1)
            {
                EvacuateDirection(directions.First());
            }
            else if (directions.Count > 1)
            {
                var pane = new SelectPane <Direction>("Evacuate", directions);
                pane.OnItemSelected += EvacuateDirection;
                SetPane(pane);
            }
        }
        public void Recon()
        {
            if (SelectedUnit == null)
            {
                return;
            }

            var directions = GetReconDirections().ToList();

            if (directions.Count == 1)
            {
                ReconDirection(directions.First());
            }
            else if (directions.Count > 1)
            {
                var pane = new SelectPane <Direction>("Recon", directions);
                pane.OnItemSelected += ReconDirection;
                SetPane(pane);
            }
        }
        public void LoadUnit(bool UseMovement)
        {
            if (SelectedUnit == null)
            {
                return;
            }

            var canLoad = SelectedUnit.Position.Units
                          .Where(i => SelectedUnit.CanLoad(i, UseMovement) == OrderInvalidReason.NONE)
                          .ToList();

            if (canLoad.Count == 1)
            {
                LoadUnit(canLoad.First());
            }
            else if (canLoad.Count > 1)
            {
                var pane = new SelectPane <Unit>("Load Unit", canLoad);
                pane.OnItemSelected += LoadUnit;
                SetPane(pane);
            }
        }
        public void Emplace()
        {
            if (SelectedUnit == null)
            {
                return;
            }

            var emplaceables =
                SelectedUnit.Position.Neighbors()
                .SelectMany(i => i.Units)
                .Where(i => i.Configuration.IsEmplaceable());

            if (emplaceables.Count() == 1)
            {
                Emplace(emplaceables.First());
            }
            else if (emplaceables.Count() > 1)
            {
                var pane = new SelectPane <Unit>("Emplace Unit", emplaceables);
                pane.OnItemSelected += Emplace;
                SetPane(pane);
            }
        }