定义 Place 对象抽象
Inheritance: GameDataItem
Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
    internal override void InitializeData( PlaceBase place, JsonDataObject data )
    {
      if ( place is Place )
        base.InitializeData( place, data );

      else
        throw new InvalidOperationException();
    }
Exemplo n.º 3
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 );
        }
Exemplo n.º 4
0
        internal override void InitializeData(PlaceBase place, JsonDataObject data)
        {
            if (place is Place)
            {
                base.InitializeData(place, data);
            }

            else
            {
                throw new InvalidOperationException();
            }
        }
Exemplo n.º 5
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));
        }
Exemplo n.º 6
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);//默认允许通过
            }
        }
Exemplo n.º 7
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);
 }
Exemplo n.º 8
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);
 }
Exemplo n.º 9
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 );
        }
Exemplo n.º 10
0
 /// <summary>
 /// 尝试对指定地块进行投入来进行这个活动
 /// </summary>
 /// <param name="place">进行活动的地块</param>
 /// <returns>是否成功</returns>
 public abstract PlaceActing TryStartAt(GamePlayer player, PlaceBase place);
Exemplo n.º 11
0
 /// <summary>
 /// 确认是否可以在指定地块开展活动
 /// </summary>
 /// <param name="place">要开展活动的地块</param>
 /// <returns>是否可以开展活动</returns>
 public abstract bool CanStartAt( GamePlayer player, PlaceBase place );
Exemplo n.º 12
0
 /// <summary>
 /// 初始化建筑数据
 /// </summary>
 /// <param name="data">数据对象</param>
 internal virtual void InitializeData(PlaceBase place, JsonDataObject data)
 {
     Place = place;
     InitializeData(place.DataService, place, data);
 }
Exemplo n.º 13
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;//默认允许通过
        }
Exemplo n.º 14
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;
 }
Exemplo n.º 15
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;
 }
Exemplo n.º 16
0
 /// <summary>
 /// 尝试对指定地块进行投入来进行这个活动
 /// </summary>
 /// <param name="place">进行活动的地块</param>
 /// <returns>是否成功</returns>
 public abstract PlaceActing TryStartAt( GamePlayer player, PlaceBase place );
Exemplo n.º 17
0
 /// <summary>
 /// 初始化建筑数据
 /// </summary>
 /// <param name="data">数据对象</param>
 internal virtual void InitializeData( PlaceBase place, JsonDataObject data )
 {
     Place = place;
       InitializeData( place.DataService, place, data );
 }
Exemplo n.º 18
0
 /// <summary>
 /// 确认是否可以在指定地块开展活动
 /// </summary>
 /// <param name="place">要开展活动的地块</param>
 /// <returns>是否可以开展活动</returns>
 public abstract bool CanStartAt(GamePlayer player, PlaceBase place);