当前位置: 首页>>代码示例>>C#>>正文


C# TimeSpan.ToMiniString方法代码示例

本文整理汇总了C#中System.TimeSpan.ToMiniString方法的典型用法代码示例。如果您正苦于以下问题:C# TimeSpan.ToMiniString方法的具体用法?C# TimeSpan.ToMiniString怎么用?C# TimeSpan.ToMiniString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.TimeSpan的用法示例。


在下文中一共展示了TimeSpan.ToMiniString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Announce

 void Announce( TimeSpan timeLeft )
 {
     if( String.IsNullOrEmpty( Message ) ) {
         Chat.SendSay( Player.Console, "(Timer) " + timeLeft.ToMiniString() );
     } else {
         Chat.SendSay( Player.Console,
                       String.Format( "(Timer) {0} until {1}",
                                      timeLeft.ToMiniString(),
                                      Message ) );
     }
 }
开发者ID:Blingpancakeman,项目名称:800craft,代码行数:11,代码来源:ChatTimer.cs

示例2: Announce

        void Announce( TimeSpan timeLeft ) {
            if( String.IsNullOrEmpty( Message ) ) {
                Server.Players.Message("&2[&7CountDown&2][&7{0}&2]", timeLeft.ToMiniString());
				IRC.SendChannelMessage("\u212C&S[&7CountDown&S][&7{0}&S]", timeLeft.ToMiniNoColorString());
            } else {
                Server.Players.Message("&2[&7Timer&2][&7{0}&2] &7{1} &2-&7{2}", timeLeft.ToMiniString(), Message, StartedBy);
				IRC.SendChannelMessage("\u212C&S[&7Timer&S][&7{2}&S][&7{0}&S]\u211C {1}", timeLeft.ToMiniNoColorString(), Message, StartedBy);
            }
        }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:9,代码来源:ChatTimer.cs

示例3: Mute

        /// <summary> Mutes this player (prevents from writing chat messages). </summary>
        /// <param name="player"> Player who is doing the muting. </param>
        /// <param name="duration"> Duration of the mute. If a player is already muted for same or greater length of time,
        /// PlayerOpException is thrown with NoActionNeeded code. If a player is already muted for a shorter length of time,
        /// the mute duration is extended. </param>
        /// <param name="announce"> Whether to announce muting publicly on the sever. </param>
        /// <param name="raiseEvents"> Whether to raise PlayerInfo.MuteChanging and MuteChanged events. </param>
        public void Mute( [NotNull] Player player, TimeSpan duration, bool announce, bool raiseEvents ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( duration <= TimeSpan.Zero ) {
                throw new ArgumentException( "Mute duration may not be zero or negative.", "duration" );
            }

            // Check if player is trying to mute self
            if( player.Info == this ) {
                PlayerOpException.ThrowCannotTargetSelf( player, this, "mute" );
            }

            lock( actionLock ) {
                // Check if player can mute in general
                if( !player.Can( Permission.Mute ) ) {
                    PlayerOpException.ThrowPermissionMissing( player, this, "mute", Permission.Mute );
                }

                // Check if player has sufficient rank permissions
                if( !player.Can( Permission.Mute, Rank ) ) {
                    PlayerOpException.ThrowPermissionLimit( player, this, "mute", Permission.Mute );
                }

                // Check if target is already muted for longer
                DateTime newMutedUntil = DateTime.UtcNow.Add( duration );
                if( newMutedUntil > MutedUntil ) {

                    // raise PlayerInfo.MuteChanging event
                    if( raiseEvents ) {
                        if( RaiseMuteChangingEvent( this, player, duration, false, announce ) ) {
                            PlayerOpException.ThrowCancelled( player, this );
                        }
                    }

                    // actually mute
                    MutedUntil = newMutedUntil;
                    MutedBy = player.Name;
                    LastModified = DateTime.UtcNow;

                    // raise PlayerInfo.MuteChanged event
                    if( raiseEvents ) {
                        RaiseMuteChangedEvent( this, player, duration, false, announce );
                    }

                    // log and announce mute publicly
                    Logger.Log( LogType.UserActivity,
                                "Player {0} was muted by {1} for {2}",
                                Name, player.Name, duration );
                    if( announce ) {
                        Player target = PlayerObject;
                        if( target != null ) {
                            target.Message( "You were muted by {0}&S for {1}",
                                            player.ClassyName, duration.ToMiniString() );
                        }
                        Server.Message( target,
                                        "&SPlayer {0}&S was muted by {1}&S for {2}",
                                        ClassyName, player.ClassyName, duration.ToMiniString() );
                    }

                } else {
                    // no action needed - already muted for same or longer duration
                    string msg = String.Format( "Player {0} was already muted by {1} ({2} left)",
                                                ClassyName, MutedBy,
                                                TimeMutedLeft.ToMiniString() );
                    string colorMsg = String.Format( "&SPlayer {0}&S was already muted by {1}&S ({2} left)",
                                                     ClassyName, MutedByClassy,
                                                     TimeMutedLeft.ToMiniString() );
                    throw new PlayerOpException( player, this, PlayerOpExceptionCode.NoActionNeeded, msg, colorMsg );
                }
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:77,代码来源:PlayerInfo.Actions.cs

示例4: CheckIdles

        private static void CheckIdles(SchedulerTask task) {

            Player[] tempPlayerList = Players;
            for (int i = 0; i < tempPlayerList.Length; i++) {
                Player player = tempPlayerList[i];

				if (player.Supports(CpeExtension.MessageType)) {
                    player.Send(Packet.Message((byte)MessageType.BottomRight2,
                        player.Position.ToBlockCoordsExt().ToString() + "&s[" + compassString(player.Position.R) + "&s]"));
                    if (player.LastDrawOp != null && !player.IsPlayingCTF)
                        if (player.LastDrawOp.PercentDone < 100) {
                            player.Send(Packet.Message((byte)MessageType.Status3, Color.Sys + player.LastDrawOp.Description + " percent done: " + Color.White + player.LastDrawOp.PercentDone.ToString() + "&s%"));
                        } else if (player.LastDrawOp.PercentDone == 100 || player.LastDrawOp.IsDone) {
                            player.Send(Packet.Message((byte)MessageType.Status3, ""));
                        }
                }
                CTF.PrintCtfState(player);
                player.lastSolidPos = player.Position;

                if (player.Info.Rank.IdleKickTimer <= 0) continue;
                TimeSpan TimeLeft = new TimeSpan(0, player.Info.Rank.IdleKickTimer, 0) - player.IdBotTime;

                if (player.IdBotTime.ToSeconds()%300 == 0 && player.IdBotTime.ToSeconds() >= 300) {
                    if (player.Info.IsAFK == false) {
                        Players.CanSee(player).Message("&S{0} is now AFK (Auto)", player.Name);
                        player.Info.IsAFK = true;
                        player.Info.oldafkMob = player.Info.afkMob;
                        player.Info.afkMob = player.AFKModel;

                    }
                    player.Message("You have " + TimeLeft.ToMiniString() + " left before being kicked for idleing");
                }

                if (player.IdBotTime.TotalMinutes >= player.Info.Rank.IdleKickTimer) {
                    Message("{0}&S was kicked for being idle for {1} min", player.ClassyName,
                        player.Info.Rank.IdleKickTimer);
                    string kickReason = "Idle for " + player.Info.Rank.IdleKickTimer + " minutes";
                    player.Kick(Player.Console, kickReason, LeaveReason.IdleKick, false, true, false);
                    player.Info.TotalTime = player.Info.TotalTime - player.IdBotTime;
                    player.Info.IsAFK = false;
                    player.Info.oldafkMob = player.Info.afkMob;
                    player.Info.afkMob = player.Info.Mob;
                    player.ResetIdBotTimer(); // to prevent kick from firing more than once
                }
			}
			UpdateTabList();
        }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:47,代码来源:Server.cs


注:本文中的System.TimeSpan.ToMiniString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。