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


C# Command.NextInt方法代码示例

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


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

示例1: Mark

        internal static void Mark( Player player, Command command ) {
            int x, y, h;
            Position pos;
            if( command.NextInt( out x ) && command.NextInt( out y ) && command.NextInt( out h ) ) {
                pos = new Position( x, y, h );
            } else {
                pos = new Position( (player.Position.X - 1) / 32,
                                    (player.Position.Y - 1) / 32,
                                    (player.Position.H - 1) / 32 );
            }
            pos.X = (short)Math.Min( player.World.Map.WidthX - 1, Math.Max( 0, (int)pos.X ) );
            pos.Y = (short)Math.Min( player.World.Map.WidthY - 1, Math.Max( 0, (int)pos.Y ) );
            pos.H = (short)Math.Min( player.World.Map.Height - 1, Math.Max( 0, (int)pos.H ) );

            if( player.SelectionMarksExpected > 0 ) {
                player.AddSelectionMark( pos, true );
            } else {
                player.MessageNow( "Cannot mark - no draw or zone commands initiated." );
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:20,代码来源:BuildingCommands.cs

示例2: TreeHandler

        static void TreeHandler(Player player, Command cmd)
        {
            string shapeName = cmd.Next();
            int height;
            Forester.TreeShape shape;

            // that's one ugly if statement... does the job though.
            if (shapeName == null ||
                !cmd.NextInt(out height) ||
                !EnumUtil.TryParse(shapeName, out shape, true) ||
                shape == Forester.TreeShape.Stickly ||
                shape == Forester.TreeShape.Procedural)
            {
                CdTree.PrintUsage(player);
                player.Message("Available shapes: Normal, Bamboo, Palm, Cone, Round, Rainforest, Mangrove.");
                return;
            }

            if (height < 6 || height > 1024)
            {
                player.Message("Tree height must be 6 blocks or above");
                return;
            }

            Map map = player.World.Map;

            ForesterArgs args = new ForesterArgs
            {
                Height = height - 1,
                Operation = Forester.ForesterOperation.Add,
                Map = map,
                Shape = shape,
                TreeCount = 1,
                RootButtresses = false,
                Roots = Forester.RootMode.None,
                Rand = new Random()
            };
            player.SelectionStart(1, TreeCallback, args, CdTree.Permissions);
            player.MessageNow("Tree: Place a block or type /Mark to use your location.");
        }
开发者ID:Eeyle,项目名称:LegendCraftSource,代码行数:40,代码来源:BuildingCommands.cs

示例3: InfoHandler

        internal static void InfoHandler( Player player, Command cmd ) {
            string name = cmd.Next();
            if( name == null ) {
                // no name given, print own info
                PrintPlayerInfo( player, player.Info );
                return;

            } else if( name.Equals( player.Name, StringComparison.OrdinalIgnoreCase ) ) {
                // own name given
                player.LastUsedPlayerName = player.Name;
                PrintPlayerInfo( player, player.Info );
                return;

            } else if( !player.Can( Permission.ViewOthersInfo ) ) {
                // someone else's name or IP given, permission required.
                player.MessageNoAccess( Permission.ViewOthersInfo );
                return;
            }

            // repeat last-typed name
            if( name == "-" ) {
                if( player.LastUsedPlayerName != null ) {
                    name = player.LastUsedPlayerName;
                } else {
                    player.Message( "Cannot repeat player name: you haven't used any names yet." );
                    return;
                }
            }

            PlayerInfo[] infos;
            IPAddress ip;

            if( name.Contains( "/" ) ) {
                // IP range matching (CIDR notation)
                string ipString = name.Substring( 0, name.IndexOf( '/' ) );
                string rangeString = name.Substring( name.IndexOf( '/' ) + 1 );
                byte range;
                if( Server.IsIP( ipString ) && IPAddress.TryParse( ipString, out ip ) &&
                    Byte.TryParse( rangeString, out range ) && range <= 32 ) {
                    player.Message( "Searching {0}-{1}", ip.RangeMin( range ), ip.RangeMax( range ) );
                    infos = PlayerDB.FindPlayersCidr( ip, range );
                } else {
                    player.Message( "Info: Invalid IP range format. Use CIDR notation." );
                    return;
                }

            } else if( Server.IsIP( name ) && IPAddress.TryParse( name, out ip ) ) {
                // find players by IP
                infos = PlayerDB.FindPlayers( ip );

            } else if( name.Contains( "*" ) || name.Contains( "?" ) ) {
                // find players by regex/wildcard
                string regexString = "^" + RegexNonNameChars.Replace( name, "" ).Replace( "*", ".*" ).Replace( "?", "." ) + "$";
                Regex regex = new Regex( regexString, RegexOptions.IgnoreCase | RegexOptions.Compiled );
                infos = PlayerDB.FindPlayers( regex );

            } else {
                // find players by partial matching
                PlayerInfo tempInfo;
                if( !PlayerDB.FindPlayerInfo( name, out tempInfo ) ) {
                    infos = PlayerDB.FindPlayers( name );
                } else if( tempInfo == null ) {
                    player.MessageNoPlayer( name );
                    return;
                } else {
                    infos = new[] { tempInfo };
                }
            }

            Array.Sort( infos, new PlayerInfoComparer( player ) );

            if( infos.Length == 1 ) {
                // only one match found; print it right away
                player.LastUsedPlayerName = infos[0].Name;
                PrintPlayerInfo( player, infos[0] );

            } else if( infos.Length > 1 ) {
                // multiple matches found
                if( infos.Length <= PlayersPerPage ) {
                    // all fit to one page
                    player.MessageManyMatches( "player", infos );

                } else {
                    // pagination
                    int offset;
                    if( !cmd.NextInt( out offset ) ) offset = 0;
                    if( offset >= infos.Length ) {
                        offset = Math.Max( 0, infos.Length - PlayersPerPage );
                    }
                    PlayerInfo[] infosPart = infos.Skip( offset ).Take( PlayersPerPage ).ToArray();
                    player.MessageManyMatches( "player", infosPart );
                    if( offset + infosPart.Length < infos.Length ) {
                        // normal page
                        player.Message( "Showing {0}-{1} (out of {2}). Next: &H/Info {3} {4}",
                                        offset + 1, offset + infosPart.Length, infos.Length,
                                        name, offset + infosPart.Length );
                    } else {
                        // last page
                        player.Message( "Showing matches {0}-{1} (out of {2}).",
                                        offset + 1, offset + infosPart.Length, infos.Length );
//.........这里部分代码省略.........
开发者ID:fragmer,项目名称:fCraft,代码行数:101,代码来源:InfoCommands.cs

示例4: RollHandler

        static void RollHandler( Player player, Command cmd ) {
            if( player.Info.IsMuted ) {
                player.MessageMuted();
                return;
            }

            if( player.DetectChatSpam() ) return;

            Random rand = new Random();
            int n1;
            int min, max;
            if( cmd.NextInt( out n1 ) ) {
                int n2;
                if( !cmd.NextInt( out n2 ) ) {
                    n2 = 1;
                }
                min = Math.Min( n1, n2 );
                max = Math.Max( n1, n2 );
            } else {
                min = 1;
                max = 100;
            }

            int num = rand.Next( min, max + 1 );
            Server.Message( player,
                            "{0}{1} rolled {2} ({3}...{4})",
                            player.ClassyName, Color.Silver, num, min, max );
            player.Message( "{0}You rolled {1} ({2}...{3})",
                            Color.Silver, num, min, max );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:30,代码来源:ChatCommands.cs

示例5: MarkHandler

        static void MarkHandler( Player player, Command cmd )
        {
            Map map = player.WorldMap;
            int x, y, z;
            Vector3I coords;
            if( cmd.NextInt( out x ) && cmd.NextInt( out y ) && cmd.NextInt( out z ) ) {
                if( cmd.HasNext ) {
                    CdMark.PrintUsage( player );
                    return;
                }
                coords = new Vector3I( x, y, z );
            } else {
                coords = player.Position.ToBlockCoords();
            }
            coords.X = Math.Min( map.Width - 1, Math.Max( 0, coords.X ) );
            coords.Y = Math.Min( map.Length - 1, Math.Max( 0, coords.Y ) );
            coords.Z = Math.Min( map.Height - 1, Math.Max( 0, coords.Z ) );

            if( player.SelectionMarksExpected > 0 ) {
                player.SelectionAddMark( coords, true );
            } else {
                player.MessageNow( "Cannot mark - no selection in progress." );
            }
        }
开发者ID:Eeyle,项目名称:LegendCraftSource,代码行数:24,代码来源:BuildingCommands.cs

示例6: GenHandler

        static void GenHandler(Player player, Command cmd)
        {
            World playerWorld = player.World;
            string themeName = cmd.Next();
            string templateName;
            bool genOcean = false;
            bool genEmpty = false;
            bool noTrees = false;

            if (themeName == null)
            {
                CdGenerate.PrintUsage(player);
                return;
            }
            MapGenTheme theme = MapGenTheme.Forest;
            MapGenTemplate template = MapGenTemplate.Flat;

            // parse special template names (which do not need a theme)
            if (themeName.Equals("ocean"))
            {
                genOcean = true;

            }
            else if (themeName.Equals("empty"))
            {
                genEmpty = true;

            }
            else
            {
                templateName = cmd.Next();
                if (templateName == null)
                {
                    CdGenerate.PrintUsage(player);
                    return;
                }

                // parse theme
                bool swapThemeAndTemplate = false;
                if (themeName.Equals("grass", StringComparison.OrdinalIgnoreCase))
                {
                    theme = MapGenTheme.Forest;
                    noTrees = true;

                }
                else if (templateName.Equals("grass", StringComparison.OrdinalIgnoreCase))
                {
                    theme = MapGenTheme.Forest;
                    noTrees = true;
                    swapThemeAndTemplate = true;

                }
                else if (EnumUtil.TryParse(themeName, out theme, true))
                {
                    noTrees = (theme != MapGenTheme.Forest);

                }
                else if (EnumUtil.TryParse(templateName, out theme, true))
                {
                    noTrees = (theme != MapGenTheme.Forest);
                    swapThemeAndTemplate = true;

                }
                else
                {
                    player.Message("Gen: Unrecognized theme \"{0}\". Available themes are: Grass, {1}",
                                    themeName,
                                    Enum.GetNames(typeof(MapGenTheme)).JoinToString());
                    return;
                }

                // parse template
                if (swapThemeAndTemplate)
                {
                    if (!EnumUtil.TryParse(themeName, out template, true))
                    {
                        player.Message("Unrecognized template \"{0}\". Available terrain types: Empty, Ocean, {1}",
                                        themeName,
                                        Enum.GetNames(typeof(MapGenTemplate)).JoinToString());
                        return;
                    }
                }
                else
                {
                    if (!EnumUtil.TryParse(templateName, out template, true))
                    {
                        player.Message("Unrecognized template \"{0}\". Available terrain types: Empty, Ocean, {1}",
                                        templateName,
                                        Enum.GetNames(typeof(MapGenTemplate)).JoinToString());
                        return;
                    }
                }
            }

            // parse map dimensions
            int mapWidth, mapLength, mapHeight;
            if (cmd.HasNext)
            {
                int offset = cmd.Offset;
                if (!(cmd.NextInt(out mapWidth) && cmd.NextInt(out mapLength) && cmd.NextInt(out mapHeight)))
//.........这里部分代码省略.........
开发者ID:Rhinovex,项目名称:LegendCraft,代码行数:101,代码来源:WorldCommands.cs

示例7: WorldsHandler

        static void WorldsHandler(Player player, Command cmd)
        {
            string param = cmd.Next();
            World[] worlds;

            string listName;
            string extraParam;
            int offset = 0;

            if (param == null || Int32.TryParse(param, out offset))
            {
                listName = "available worlds";
                extraParam = "";
                worlds = WorldManager.Worlds.Where(w => !w.IsRealm).Where(player.CanSee).ToArray();

            }
            else
            {
                switch (Char.ToLower(param[0]))
                {
                    case 'a':
                        listName = "worlds";
                        extraParam = "all ";
                        worlds = WorldManager.Worlds;
                        break;
                    case 'h':
                        listName = "hidden worlds";
                        extraParam = "hidden ";
                        worlds = WorldManager.Worlds.Where(w => !player.CanSee(w)).ToArray();
                        break;
                    case 'r':
                        listName = "Available Realms";
                        extraParam = "realms";
                        worlds = WorldManager.Worlds.Where(w => w.IsRealm).ToArray();
                        break;
                    case 'p':
                        listName = "populated worlds";
                        extraParam = "populated ";
                        worlds = WorldManager.Worlds.Where(w => w.Players.Any(player.CanSee)).ToArray();
                        break;
                    case '@':
                        if (param.Length == 1)
                        {
                            CdWorlds.PrintUsage(player);
                            return;
                        }
                        string rankName = param.Substring(1);
                        Rank rank = RankManager.FindRank(rankName);
                        if (rank == null)
                        {
                            player.MessageNoRank(rankName);
                            return;
                        }
                        listName = String.Format("worlds where {0}&S+ can build", rank.ClassyName);
                        extraParam = "@" + rank.Name + " ";
                        worlds = WorldManager.Worlds.Where(w => (w.BuildSecurity.MinRank <= rank) && player.CanSee(w))
                                                    .ToArray();
                        break;
                    default:
                        CdWorlds.PrintUsage(player);
                        return;
                }
                if (cmd.HasNext && !cmd.NextInt(out offset))
                {
                    CdWorlds.PrintUsage(player);
                    return;
                }
            }

            if (worlds.Length == 0)
            {
                player.Message("There are no {0}.", listName);

            }
            else if (worlds.Length <= WorldNamesPerPage || player.IsSuper)
            {
                player.MessagePrefixed("&S  ", "&SThere are {0} {1}: {2}",
                                        worlds.Length, listName, worlds.JoinToClassyString());

            }
            else
            {
                if (offset >= worlds.Length)
                {
                    offset = Math.Max(0, worlds.Length - WorldNamesPerPage);
                }
                World[] worldsPart = worlds.Skip(offset).Take(WorldNamesPerPage).ToArray();
                player.MessagePrefixed("&S   ", "&S{0}: {1}",
                                        listName.UppercaseFirst(), worldsPart.JoinToClassyString());

                if (offset + worldsPart.Length < worlds.Length)
                {
                    player.Message("Showing {0}-{1} (out of {2}). Next: &H/Worlds {3}{1}",
                                    offset + 1, offset + worldsPart.Length, worlds.Length, extraParam);
                }
                else
                {
                    player.Message("Showing worlds {0}-{1} (out of {2}).",
                                    offset + 1, offset + worldsPart.Length, worlds.Length);
                }
//.........这里部分代码省略.........
开发者ID:Rhinovex,项目名称:LegendCraft,代码行数:101,代码来源:WorldCommands.cs

示例8: Generate

        internal static void Generate( Player player, Command cmd )
        {
            if( !player.Can( Permissions.ManageWorlds ) ) {
                player.NoAccessMessage( Permissions.ManageWorlds );
                return;
            }
            int wx, wy, height;
            if( !(cmd.NextInt( out wx ) && cmd.NextInt( out wy ) && cmd.NextInt( out height )) ) {
                if( player.world != null ) {
                    wx = player.world.map.widthX;
                    wy = player.world.map.widthY;
                    height = player.world.map.height;
                } else {
                    player.Message( "Usage: " + Color.Help + "/gen widthX widthY height type filename" );
                    return;
                }
                cmd.Rewind();
            }
            string mode = cmd.Next();
            string filename = cmd.Next();
            if( mode == null || filename == null ) {
                player.Message( "Usage: " + Color.Help + "/gen widthX widthY height type filename" );
                return;
            }
            filename += ".fcm";

            int seed;
            if( !cmd.NextInt( out seed ) ) {
                seed = new Random().Next();
            }
            Random rand = new Random( seed );
            //player.Message( "Seed: " + Convert.ToBase64String( BitConverter.GetBytes( seed ) ) );

            Map map = new Map( player.world, wx, wy, height );
            map.spawn.Set( map.widthX / 2 * 32 + 16, map.widthY / 2 * 32 + 16, map.height * 32, 0, 0 );

            DoGenerate( map, player, mode, filename, rand, false );
        }
开发者ID:asiekierka,项目名称:afCraft,代码行数:38,代码来源:MapCommands.cs

示例9: ListHandler

        internal static void ListHandler( Player player, Command cmd )
        {
            string Option = cmd.Next();
            if ( Option == null ) {
                CdList.PrintUsage( player );
                player.Message( "  Sections include: Staff, DisplayedNames, Idles, Portals, Rank, Top10, Emotes" );
                return;
            }
            switch ( Option.ToLower() ) {
                default:
                    CdList.PrintUsage( player );
                    player.Message( "  Sections include: Staff, DisplayedNames, Idles, Portals, Rank, Top10, Emotes" );
                    break;
                case "emotes":
                    string Usage = "Shows a list of all available emotes and their keywords. " +
                   "There are 31 emotes, spanning 3 pages. Use &h/List emotes 2&s and &h/List emotes 3&s to see pages 2 and 3.";
                    int page = 1;
                    if ( cmd.HasNext ) {
                        if ( !cmd.NextInt( out page ) ) {
                            player.Message( Usage );
                            return;
                        }
                    }
                    if ( page < 1 || page > 3 ) {
                        player.Message( Usage );
                        return;
                    }

                    var emoteChars = Chat.EmoteKeywords
                                         .Values
                                         .Distinct()
                                         .Skip( ( page - 1 ) * 11 )
                                         .Take( 11 );

                    player.Message( "List of emotes, page {0} of 3:", page );
                    foreach ( char ch in emoteChars ) {
                        char ch1 = ch;
                        string keywords = Chat.EmoteKeywords
                                              .Where( pair => pair.Value == ch1 )
                                              .Select( kvp => "{&F" + kvp.Key.UppercaseFirst() + "&7}" )
                                              .JoinToString( " " );
                        player.Message( "&F  {0} &7= {1}", ch, keywords );
                    }
                    if ( page < 3 )
                        player.Message( "Type /List Emotes {0} for the next page", page + 1 );

                    break;
                case "top10":
                    List<World> WorldNames = new List<World>( WorldManager.Worlds.Where( w => w.VisitCount > 0 )
                                         .OrderBy( c => c.VisitCount )
                                         .ToArray()
                                         .Reverse() );
                    string list = WorldNames.Take( 10 ).JoinToString( w => String.Format( "{0}&S: {1}", w.ClassyName, w.VisitCount ) );
                    if ( WorldNames.Count() < 1 ) {
                        player.Message( "&WNo results found" );
                        return;
                    }
                    player.Message( "&WShowing worlds with the most visits: " + list );
                    WorldNames.Clear();
                    break;
                case "idles":
                case "idle":
                    var Idles = Server.Players.Where( p => p.IdleTime.TotalMinutes > 5 ).ToArray();
                    var visiblePlayers = Idles.Where( player.CanSee );
                    if ( visiblePlayers.Count() > 0 )
                        player.Message( "Listing players idle for 5 mins or more: {0}",
                                        visiblePlayers.JoinToString( r => String.Format( "{0}&S (Idle {1}", r.ClassyName, r.IdleTime.ToMiniString() ) ) );
                    else player.Message( "No players have been idle for more than 5 minutes" );
                    break;
                case "portals":
                    if ( player.World == null ) {
                        player.Message( "/List portals cannot be used from Console" );
                        return;
                    }
                    if ( player.World.Map.Portals == null ||
                        player.World.Map.Portals.Count == 0 ) {
                        player.Message( "There are no portals in {0}&S.", player.World.ClassyName );
                    } else {
                        String[] portalNames = new String[player.World.Map.Portals.Count];
                        StringBuilder output = new StringBuilder( "There are " + player.World.Map.Portals.Count + " portals in " + player.World.ClassyName + "&S: " );

                        for ( int i = 0; i < player.World.Map.Portals.Count; i++ ) {
                            portalNames[i] = ( ( fCraft.Portals.Portal )player.World.Map.Portals[i] ).Name;
                        }
                        output.Append( portalNames.JoinToString( ", " ) );
                        player.Message( output.ToString() );
                    }
                    break;
                case "staff":
                    var StaffNames = PlayerDB.PlayerInfoList
                                         .Where( r => r.Rank.Can( Permission.ReadStaffChat ) &&
                                             r.Rank.Can( Permission.Ban ) &&
                                             r.Rank.Can( Permission.Promote ) )
                                             .OrderBy( p => p.Rank )
                                             .ToArray();
                    if ( StaffNames.Length < 1 ) {
                        player.Message( "&WNo results found" );
                        return;
                    }
                    if ( StaffNames.Length <= PlayersPerPage ) {
//.........这里部分代码省略.........
开发者ID:venofox,项目名称:AtomicCraft,代码行数:101,代码来源:InfoCommands.cs

示例10: TreeHandler

        static void TreeHandler( Player player, Command cmd )
        {
            string shapeName = cmd.Next();
            int height;
            Forester.TreeShape shape;

            // that's one ugly if statement... does the job though.
            if( shapeName == null ||
                !cmd.NextInt( out height ) ||
                !EnumUtil.TryParse( shapeName, out shape, true ) ||
                shape == Forester.TreeShape.Stickly ||
                shape == Forester.TreeShape.Procedural ) {

                CdTree.PrintUsage( player );
                return;
            }

            if( height < 2 || height > 1024 ) {
                player.Message( "Tree height must be between 2 and 1024 blocks." );
                return;
            }

            Map map = player.World.Map;

            ForesterArgs args = new ForesterArgs {
                Height = height,
                Shape = shape,
                Map = map,
                Rand = new Random()
            };

            player.SelectionStart( 1, TreeCallback, args, CdTree.Permissions );
        }
开发者ID:Desertive,项目名称:800craft,代码行数:33,代码来源:BuildingCommands.cs

示例11: Roll

        internal static void Roll( Player player, Command cmd ) {
            if( player.Info.IsMuted ) {
                player.MutedMessage();
                return;
            }

            Random rand = new Random();
            int min = 1, max = 100, t1;
            if( cmd.NextInt( out t1 ) ) {
                int t2;
                if( cmd.NextInt( out t2 ) ) {
                    if( t2 < t1 ) {
                        min = t2;
                        max = t1;
                    } else {
                        min = t1;
                        max = t2;
                    }
                } else if( t1 >= 1 ) {
                    max = t1;
                }
            }
            int num = rand.Next( min, max + 1 );
            Server.SendToAll( "{0}{1} rolled {2} ({3}...{4})",
                              player.GetClassyName(), Color.Silver, num, min, max );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:26,代码来源:ChatCommands.cs

示例12: ListHandler

        internal static void ListHandler(Player player, Command cmd)
        {
            string Option = cmd.Next();

            if (Option == null)
            {
                CdList.PrintUsage(player);
                return;
            }
            if (Option.ToLower() == "staff")
            {
                var StaffNames = PlayerDB.PlayerInfoList
                                     .Where(r => r.Rank.Can(Permission.ReadStaffChat) &&
                                         r.Rank.Can(Permission.Ban) &&
                                         r.Rank.Can(Permission.Promote))
                                         .ToArray();

                if (StaffNames.Length <= PlayersPerPage)
                {
                    player.MessageManyMatches("staff", StaffNames);
                }

                else
                {
                    int offset;

                    if (!cmd.NextInt(out offset)) offset = 0;

                    if (offset >= StaffNames.Length)
                        offset = Math.Max(0, StaffNames.Length - PlayersPerPage);

                    PlayerInfo[] StaffPart = StaffNames.Skip(offset).Take(PlayersPerPage).ToArray();
                    player.MessageManyMatches("staff", StaffPart);

                    if (offset + StaffPart.Length < StaffNames.Length)
                        player.Message("Showing {0}-{1} (out of {2}). Next: &H/List {3} {4}",
                                        offset + 1, offset + StaffPart.Length, StaffNames.Length,
                                        "staff", offset + StaffPart.Length);
                    else
                        player.Message("Showing matches {0}-{1} (out of {2}).",
                                        offset + 1, offset + StaffPart.Length, StaffNames.Length);
                }
            }

            if (Option.ToLower() == "displayednames" || Option.ToLower() == "displayedname" || Option.ToLower() == "dn")
            {

                var DisplayedNames = PlayerDB.PlayerInfoList
                                         .Where(r => r.DisplayedName != null).ToArray();
                if (DisplayedNames.Count() > 0)
                    player.Message("Listing all DisplayedNames: {0}",
                                    DisplayedNames.JoinToString(r => String.Format("{0}&S({1})", r.ClassyName, r.Name)));
                else player.Message("No players with DisplayedNames were found in the Player Database");
            }
        }
开发者ID:Desertive,项目名称:800craft,代码行数:55,代码来源:InfoCommands.cs

示例13: Roll

 void Roll( Player player, Command cmd ) {
     Random rand = new Random();
     int min = 1, max = 100, num, t1, t2;
     if( cmd.NextInt( out t1 ) ) {
         if( cmd.NextInt( out t2 ) ) {
             if( t2 >= t1 ) {
                 min = t1;
                 max = t2;
             }
         } else if( t1 >= 1 ){
             max = t1;
         }
     }
     num = rand.Next( min, max+1 );
     string msg = Color.Silver + player.name + " rolled " + num + " ("+min+"..."+max+")";
     world.log.LogConsole( msg );
     world.SendToAll( PacketWriter.MakeMessage( msg ), null );
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:18,代码来源:StandardCommands.cs

示例14: GenerateHollow

        void GenerateHollow( Player player, Command cmd ) {
            if( !player.Can( Permissions.SaveAndLoad ) ) {
                world.NoAccessMessage( player );
                return;
            }
            int wx, wy, height;
            if( !(cmd.NextInt( out wx ) && cmd.NextInt( out wy ) && cmd.NextInt( out height )) ) {
                player.Message( "Usage: " + Color.Help + "/genh widthX widthY height type filename" );
                return;
            }
            string mode = cmd.Next();
            string filename = cmd.Next();
            if( mode == null || filename == null ) {
                player.Message( "Usage: " + Color.Help + "/genh widthX widthY height type filename" );
                return;
            }
            filename += ".fcm";

            int seed;
            if( !cmd.NextInt( out seed ) ) {
                seed = new Random().Next();
            }
            Random rand = new Random( seed );
            player.Message( "Seed: " + Convert.ToBase64String( BitConverter.GetBytes( seed ) ) );

            Map map = new Map( world, wx, wy, height );
            map.spawn.Set( map.widthX / 2 * 32 + 16, map.widthY / 2 * 32 + 16, map.height * 32, 0, 0 );

            DoGenerate( map, player, mode, filename, rand, true );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:30,代码来源:MapCommands.cs

示例15: RealmCreate

        public static void RealmCreate(Player player, Command cmd, string themeName, string templateName)
        {
            MapGenTemplate template;
            MapGenTheme theme;

            int wx, wy, height = 128;
            if (!(cmd.NextInt(out wx) && cmd.NextInt(out wy) && cmd.NextInt(out height)))
            {
                if (player.World != null)
                {
                    wx = 128;
                    wy = 128;
                    height = 128;
                }
                else
                {
                    player.Message("When used from console, /gen requires map dimensions.");

                    return;
                }
                cmd.Rewind();
                cmd.Next();
                cmd.Next();
            }

            if (!Map.IsValidDimension(wx))
            {
                player.Message("Cannot make map with width {0}: dimensions must be multiples of 16.", wx);
                return;
            }
            else if (!Map.IsValidDimension(wy))
            {
                player.Message("Cannot make map with length {0}: dimensions must be multiples of 16.", wy);
                return;
            }
            else if (!Map.IsValidDimension(height))
            {
                player.Message("Cannot make map with height {0}: dimensions must be multiples of 16.", height);
                return;
            }

            string fileName = player.Name;
            string fullFileName = null;

            if (fileName == null)
            {
                if (player.World == null)
                {
                    player.Message("When used from console, /gen requires FileName.");

                    return;
                }
                if (!cmd.IsConfirmed)
                {
                    player.Confirm(cmd, "Replace this realm's map with a generated one?");
                    return;
                }
            }
            else
            {
                fileName = fileName.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
                if (!fileName.EndsWith(".fcm", StringComparison.OrdinalIgnoreCase))
                {
                    fileName += ".fcm";
                }
                fullFileName = Path.Combine(Paths.MapPath, fileName);
                if (!Paths.IsValidPath(fullFileName))
                {
                    player.Message("Invalid filename.");
                    return;
                }
                if (!Paths.Contains(Paths.MapPath, fullFileName))
                {
                    player.MessageUnsafePath();
                    return;
                }
                string dirName = fullFileName.Substring(0, fullFileName.LastIndexOf(Path.DirectorySeparatorChar));
                if (!Directory.Exists(dirName))
                {
                    Directory.CreateDirectory(dirName);
                }
                if (!cmd.IsConfirmed && File.Exists(fullFileName))
                {
                    player.Confirm(cmd, "The mapfile \"{0}\" already exists. Overwrite?", fileName);
                    return;
                }
            }

            bool noTrees;
            if (themeName.Equals("grass", StringComparison.OrdinalIgnoreCase))
            {
                theme = MapGenTheme.Forest;
                noTrees = true;
            }
            else
            {
                try
                {
                    theme = (MapGenTheme)Enum.Parse(typeof(MapGenTheme), themeName, true);
                    noTrees = (theme != MapGenTheme.Forest);
//.........这里部分代码省略.........
开发者ID:727021,项目名称:800craft,代码行数:101,代码来源:RealmHandler.cs


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