/// <summary>
        /// The active faction must have at least one
        /// unit alive to make a selection.
        /// </summary>
        private bool CanSelect()
        {
            SelectableUnits.Clear();

            // Used to add units without a turn to the end of the
            // selectable units list such that they appear last
            // in the menu.
            List <Unit> unitsWithoutTurn = new List <Unit>();

            foreach (var unit in GameState.ActiveFaction.Units)
            {
                if (unit.Alive && unit != GameState.ActiveUnit)
                {
                    if (unit.HasTurn)
                    {
                        SelectableUnits.Add(unit);
                    }
                    else
                    {
                        unitsWithoutTurn.Add(unit);
                    }
                }
            }

            // Append units without a turn to the selectable units.
            SelectableUnits.AddRange(unitsWithoutTurn);

            return(SelectableUnits.Count > 0);
        }
Example #2
0
 public void AddSelectableUnit(UnitController unit)
 {
     SelectableUnits.Add(unit.unitId, unit);
 }