/// <summary>
        ///     Finds the <see cref="Equipment" /> with the specified short name.
        /// </summary>
        /// <param name="shortName">The short name of the <see cref="Equipment" />.</param>
        /// <param name="nationality">The nationality of the <see cref="Equipment" />.</param>
        /// <param name="type">The type.</param>
        /// <returns>
        ///     The <see cref="Equipment" /> with the specified short name and nationality or the default if no such equipment
        ///     could be found.
        /// </returns>
        public Equipment Find(string shortName, Nationality nationality, UnitType type)
        {
            List<Equipment> found =
                this._equipments.Where(equipment => equipment.ShortName == shortName)
                    .Where(equipment => equipment.Nationality == nationality)
                    .Where(equipment => equipment.Type == type)
                    .ToList();

            if (found.Count > 1)
            {
                found = found.Where(e => e.AddTraits.Contains("primary")).ToList();
            }

            return (found.Count == 1) ? found[0] : Equipment.None;
        }
        private static UnitType ParseUnitType(string[] equipmentDetails, int index, UnitType defaultValue)
        {
            Contract.Requires<ArgumentOutOfRangeException>(index >= 0);
            Contract.Requires<ArgumentNullException>(equipmentDetails != null);
            Contract.Requires<ArgumentOutOfRangeException>(defaultValue.IsValid());

            UnitType parsedUnitType;

            if (index < equipmentDetails.Length)
            {
                int parsedInt;

                if (Int32.TryParse(equipmentDetails[index], out parsedInt))
                {
                    if (((UnitType)parsedInt).IsValid())
                    {
                        Contract.Assume(Enum.IsDefined(typeof(UnitType), (UnitType)parsedInt));
                        parsedUnitType = (UnitType)parsedInt;
                    }
                    else
                    {
                        parsedUnitType = defaultValue;
                    }
                }
                else
                {
                    parsedUnitType = defaultValue;
                }
            }
            else
            {
                parsedUnitType = defaultValue;
            }

            return parsedUnitType;
        }
        /// <summary>
        ///     Finds the <see cref="Equipment" /> with the specified short name.
        /// </summary>
        /// <param name="shortName">The short name of the <see cref="Equipment" />.</param>
        /// <param name="nationality">The nationality of the <see cref="Equipment" />.</param>
        /// <param name="type">The type.</param>
        /// <returns>
        ///     The <see cref="Equipment" /> with the specified short name and nationality or the default if no such equipment
        ///     could be found.
        /// </returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public Equipment Find(string shortName, Nationality nationality, UnitType type)
        {
            Contract.Requires<ArgumentNullException>(shortName != null);
            Contract.Requires<ArgumentOutOfRangeException>(nationality.IsValid());
            Contract.Requires<ArgumentOutOfRangeException>(type.IsValid());

            throw new NotImplementedException();
        }
Пример #4
0
		public Unit(UnitType unitType) : base(EntityType.UI)
		{
			this.UnitType = unitType;
		}
Пример #5
0
 public void Awake(UnitType unitType)
 {
     this.UnitType = unitType;
 }
Пример #6
0
 public void Awake(UnitType unitType)
 {
     this.Get().Awake(unitType);
 }