Ejemplo n.º 1
0
        /// <summary>
        /// 检查活动是否已经完成,若已经完成则获取相应的收益
        /// </summary>
        /// <param name="acting">正在进行的活动</param>
        /// <returns>活动是否已经完成</returns>
        public override bool TryComplete(PlaceActing acting, DateTime now)
        {
            var completedOn = acting.StartOn + Requirement.Time;

            if (completedOn > now)
            {
                return(false);
            }

            var place  = acting.Place;
            var player = acting.GetPlayer();


            if (Returns.Items != null && player != null)
            {
                player.Resources.AddItems(Returns.Items);
            }

            if (Returns.Building != null)
            {
                place.SetBuilding(Returns.Building.Guid);
            }


            place.CheckPoint = completedOn;

            if (player != null)
            {
                var message = new GameMessageEntry(completedOn, string.Format("通过不懈的努力,在位置 {0} 的活动 {1} 已经完成 {2}", place.Coordinate.ToRelative(player), Name, Returns.DescriptiveMessage));
                GameHost.MessageService.AddMessage(player.Guid, message);
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 检查活动是否已经完成,若已经完成则获取相应的收益
        /// </summary>
        /// <param name="acting">正在进行的活动</param>
        /// <returns>活动是否已经完成</returns>
        public override bool TryComplete( PlaceActing acting, DateTime now )
        {
            var completedOn = acting.StartOn + Requirement.Time;

              if ( completedOn > now )
            return false;

              var place = acting.Place;
              var player = acting.GetPlayer();

              if ( Returns.Items != null && player != null )
            player.Resources.AddItems( Returns.Items );

              if ( Returns.Building != null )
            place.SetBuilding( Returns.Building.Guid );

              place.CheckPoint = completedOn;

              if ( player != null )
              {
            var message = new GameMessageEntry( completedOn, string.Format( "通过不懈的努力,在位置 {0} 的活动 {1} 已经完成 {2}", place.Coordinate.ToRelative( player ), Name, Returns.DescriptiveMessage ) );
            GameHost.MessageService.AddMessage( player.Guid, message );
              }
              return true;
        }
Ejemplo n.º 3
0
 private string GetText( GameMessageEntry message )
 {
     return string.Format( "{0:O} {1}", message.NotifyTime, message.Content );
 }
Ejemplo n.º 4
0
 public void AddMessage( Guid playerId, GameMessageEntry message )
 {
     var filepath = Path.Combine( RootPath, playerId + ".message" );
       File.AppendAllLines( filepath, new[] { GetText( message ) } );
 }
Ejemplo n.º 5
0
 public void AddAnnouncement( GameMessageEntry message )
 {
     var filepath = Path.Combine( RootPath, "annoucement.message" );
       File.AppendAllLines( filepath, new[] { GetText( message ) } );
 }
Ejemplo n.º 6
0
        public void AddAnnouncement(GameMessageEntry message)
        {
            var filepath = Path.Combine(RootPath, "annoucement.message");

            File.AppendAllLines(filepath, new[] { GetText(message) });
        }
Ejemplo n.º 7
0
 private string GetText(GameMessageEntry message)
 {
     return(string.Format("{0:O} {1}", message.NotifyTime, message.Content));
 }
Ejemplo n.º 8
0
        public void AddMessage(Guid playerId, GameMessageEntry message)
        {
            var filepath = Path.Combine(RootPath, playerId + ".message");

            File.AppendAllLines(filepath, new[] { GetText(message) });
        }