/// <summary>Creates a new <see cref="Unit"/> instance. /// </summary> /// <param name="type">Type.</param> /// <param name="power">Power.</param> /// <param name="location">Location.</param> public Unit(UnitType type, Power power, Location location) { this.type = type; this.power = power; this.location = location; this.retreatLocations = new LocationCollection(); }
/// <summary>Gets a value indicating whether a specific <see cref="Power"/> can build a specific <see cref="UnitType"/> on this <see cref="Province"/> /// </summary> /// <param name="power">Power</param> /// <param name="unitType">Unit type.</param> /// <returns><c>true</c> if the specified <see cref="Power"/> can build the specified <see cref="UnitType"/> on this <see cref="Province"/>; otherwise, <c>false</c>.</returns> public bool CanBuildUnitType(Power power, UnitType unitType) { switch(unitType) { case UnitType.Army : return CanBuild(power) && ArmyMoveable; case UnitType.Fleet : return CanBuild(power) && FleetMoveable; default : throw new ArgumentException(Properties.ErrorMessages.Province_UnknownUnitType, "unitType"); } }
/// <summary>Gets a value indicating whether a specific <see cref="Power"/> can build a fleet on this <see cref="Province"/> /// </summary> /// <param name="power">Power</param> /// <returns><c>true</c> if the specified <see cref="Power"/> can build a fleet on this <see cref="Province"/>; otherwise, <c>false</c>.</returns> public bool CanBuildFleet(Power power) { return CanBuildUnitType(power, UnitType.Fleet); }
/// <summary>Gets a value indicating whether a specific <see cref="Power"/> can build an army on this <see cref="Province"/> /// </summary> /// <param name="power">Power</param> /// <returns><c>true</c> if the specified <see cref="Power"/> can build an army on this <see cref="Province"/>; otherwise, <c>false</c>.</returns> public bool CanBuildArmy(Power power) { return CanBuildUnitType(power, UnitType.Army); }
/// <summary>Gets a value indicating whether a specific power can build on this <see cref="Province"/>. /// </summary> /// <param name="power">Power.</param> /// <returns><c>true</c> if the power can build on this <see cref="Province"/>; otherwise, <c>false</c>.</returns> public bool CanBuild(Power power) { return IsOpenForBuilding && ( this.owningPower == power ); }