定义 Place 对象抽象
Inheritance: GameDataItem
示例#1
0
    internal override void InitializeData( PlaceBase place, JsonDataObject data )
    {
      if ( place is Place )
        base.InitializeData( place, data );

      else
        throw new InvalidOperationException();
    }
示例#2
0
        /// <summary>
        /// 确认是否可以在指定地块开始这个活动
        /// </summary>
        /// <param name="place">地块对象</param>
        /// <returns>是否可以开展这个活动</returns>
        public override sealed bool CanStartAt( GamePlayer player, PlaceBase place )
        {
            var instance = place as Place;

              if ( instance == null )
            return false; ;

              return Constraint.IsSatisfy( player, place );
        }
示例#3
0
 /// <summary>
 /// 初始化建筑数据
 /// </summary>
 /// <param name="data">数据对象</param>
 internal virtual void InitializeData( PlaceBase place, JsonDataObject data )
 {
     Place = place;
       InitializeData( place.DataService, place, data );
 }
示例#4
0
        /// <summary>
        /// 尝试在指定地块开始这个活动 
        /// </summary>
        /// <param name="place">要开始活动的地方</param>
        /// <returns>正在进行的活动</returns>
        public override PlaceActing TryStartAt( GamePlayer player, PlaceBase place )
        {
            if ( player == null )
            throw new ArgumentNullException( "player" );

              if ( place == null )
            throw new ArgumentNullException( "place" );

              string errorMessage;
              if ( Constraint.IsSatisfy( player, place, out errorMessage ) == false )
            throw new InvalidOperationException( errorMessage );

              var instance = place as Place;
              if ( instance == null )
            return null;

              return TryStartAt( player, instance );
        }
示例#5
0
 /// <summary>
 /// 尝试对指定地块进行投入来进行这个活动
 /// </summary>
 /// <param name="place">进行活动的地块</param>
 /// <returns>是否成功</returns>
 public abstract PlaceActing TryStartAt( GamePlayer player, PlaceBase place );
示例#6
0
 /// <summary>
 /// 确认是否可以在指定地块开展活动
 /// </summary>
 /// <param name="place">要开展活动的地块</param>
 /// <returns>是否可以开展活动</returns>
 public abstract bool CanStartAt( GamePlayer player, PlaceBase place );
示例#7
0
        /// <summary>
        /// 检查指定地块当前是否满足限制。
        /// </summary>
        /// <param name="player">当前操作的玩家</param>
        /// <param name="place">要检查的地块</param>
        /// <returns>若不满足限制,返回原因,若满足限制,则返回null</returns>
        protected virtual string Check( GamePlayer player, PlaceBase place )
        {
            var placeInstance = place as Place;
              if ( placeInstance != null )
            return Check( player, placeInstance );

              else
            return null;//默认允许通过
        }
示例#8
0
 /// <summary>
 /// 检查指定地块当前是否满足限制。
 /// </summary>
 /// <param name="player">当前操作的玩家</param>
 /// <param name="place">要检查的地块</param>
 /// <param name="errorMessage">错误信息</param>
 /// <returns>是否满足限制</returns>
 public virtual bool IsSatisfy( GamePlayer player, PlaceBase place, out string errorMessage )
 {
     errorMessage = Check( player, place );
       return errorMessage == null;
 }
示例#9
0
 /// <summary>
 /// 检查指定地块当前是否满足限制。
 /// </summary>
 /// <param name="player">当前操作的玩家</param>
 /// <param name="place">要检查的地块</param>
 /// <returns>是否满足限制</returns>
 public virtual bool IsSatisfy( GamePlayer player, PlaceBase place )
 {
     return Check( player, place ) == null;
 }