コード例 #1
0
ファイル: Location.cs プロジェクト: evandrix/DAIDE10
        /// <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();
        }
コード例 #2
0
ファイル: Location.cs プロジェクト: evandrix/DAIDE10
        /// <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();
        }
コード例 #3
0
ファイル: Unit.cs プロジェクト: evandrix/DAIDE10
 /// <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;
 }
コード例 #4
0
ファイル: Route.cs プロジェクト: evandrix/DAIDE10
 /// <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);
 }
コード例 #5
0
ファイル: Route.cs プロジェクト: evandrix/DAIDE10
 /// <summary>Creates a new <see cref="Route"/> instance.
 /// </summary>
 /// <param name="province">Province.</param>
 public Route(Province province)
 {
     route = new ProvinceCollection();
     Add(province);
 }
コード例 #6
0
ファイル: Route.cs プロジェクト: evandrix/DAIDE10
 /// <summary>Adds a province to the end of the route.
 /// </summary>
 /// <param name="province">Province.</param>
 public void Add(Province province)
 {
     route.Add(province);
 }