Esempio n. 1
0
        /// <summary>Creates a new <see cref="Location"/> instance.
        /// </summary>
        /// <param name="province">Province.</param>
        /// <param name="unitType">Unit type.</param>
        public Location(Province province, UnitType unitType)
        {
            Robustness.ValidateArgumentNotNull("province", province);

            //Make sure that a bicoastal province has a coast for a fleet
            Debug.Assert(!(province.IsBicoastal && unitType == UnitType.Fleet));

            this.province = province;
            this.unitType = unitType;
            this.coast = Coast.NoCoast;
            this.adjacentLocations = new LocationCollection();
        }
Esempio n. 2
0
        /// <summary>Creates a new <see cref="Location"/> instance.
        /// </summary>
        /// <param name="province">Province.</param>
        /// <param name="unitType">Unit type.</param>
        /// <param name="coast">Coast.</param>
        public Location(Province province, UnitType unitType, Coast coast)
        {
            Robustness.ValidateArgumentNotNull("province", province);

            //Make sure that we do not enter a coast for an Army
            Debug.Assert(unitType == UnitType.Army ? coast == Coast.NoCoast : true);
            //Make sure that the province is a coastal province if there is a coast specified
            Debug.Assert(coast != Coast.NoCoast ? province.IsCoastal : true);

            this.province = province;
            this.unitType = unitType;
            this.coast = coast;
            this.adjacentLocations = new LocationCollection();
        }
Esempio n. 3
0
 /// <summary>Determines if the <see cref="Unit"/> can move to the indicated <see cref="Province"/>.
 /// </summary>
 /// <param name="province">Province.</param>
 /// <returns><c>True</c> if the <see cref="Unit"/> can move to the <see cref="Province"/>; false otherwise.</returns>
 /// <remarks>This function will not check if the unit can be conveyed anywhere.</remarks>
 public bool CanMoveTo(Province province)
 {
     foreach(Location loc in location.AdjacentLocations)
     {
         if (loc.Province == province)
         {
             return true;
         }
     }
     return false;
 }
Esempio n. 4
0
 /// <summary>Creates a new <see cref="Route"/> instance, based on another <see cref="Route"/>.
 /// The <see cref="Province"/> is added on to the end of the new <see cref="Route"/>.
 /// </summary>
 /// <param name="route">Route.</param>
 /// <param name="province">Province.</param>
 public Route(Route route, Province province)
     : this(route)
 {
     this.route.Add(province);
 }
Esempio n. 5
0
 /// <summary>Creates a new <see cref="Route"/> instance.
 /// </summary>
 /// <param name="province">Province.</param>
 public Route(Province province)
 {
     route = new ProvinceCollection();
     Add(province);
 }
Esempio n. 6
0
 /// <summary>Adds a province to the end of the route.
 /// </summary>
 /// <param name="province">Province.</param>
 public void Add(Province province)
 {
     route.Add(province);
 }