當前位置: 首頁>>代碼示例>>C#>>正文


C# World.GetClassyName方法代碼示例

本文整理匯總了C#中fCraft.World.GetClassyName方法的典型用法代碼示例。如果您正苦於以下問題:C# World.GetClassyName方法的具體用法?C# World.GetClassyName怎麽用?C# World.GetClassyName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fCraft.World的用法示例。


在下文中一共展示了World.GetClassyName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MakePlayerConnectedMessage

 public static string MakePlayerConnectedMessage( Player player, bool firstTime, World world ) {
     if( player == null ) throw new ArgumentNullException( "player" );
     if( world == null ) throw new ArgumentNullException( "world" );
     if( firstTime ) {
         return String.Format( "&S{0} ({1}&S) connected, joined {2}",
                               player.Name,
                               player.Info.Rank.GetClassyName(),
                               world.GetClassyName() );
     } else {
         return String.Format( "&S{0} ({1}&S) connected again, joined {2}",
                               player.Name,
                               player.Info.Rank.GetClassyName(),
                               world.GetClassyName() );
     }
 }
開發者ID:fragmer,項目名稱:fCraft,代碼行數:15,代碼來源:Server.cs

示例2: JoinWorldNow

        internal bool JoinWorldNow( World newWorld, bool firstTime, bool doUseWorldSpawn ) {
            if( newWorld == null ) throw new ArgumentNullException( "newWorld" );

            if( !Player.CanJoin( newWorld ) ) {
                Logger.Log( "Session.JoinWorldNow: Access limits prevented {0} from joining {1}.", LogType.Error,
                            Player.Name, newWorld.Name );
                return false;
            }

            if( !newWorld.FirePlayerTriedToJoinEvent( Player ) ) {
                Logger.Log( "Session.JoinWorldNow: FirePlayerTriedToJoinEvent prevented {0} from joining {1}", LogType.Warning,
                            Player.Name, newWorld.Name );
                return false;
            }

            World oldWorld = Player.World;

            // remove player from the old world
            if( oldWorld != null && oldWorld != newWorld ) {
                if( !oldWorld.ReleasePlayer( Player ) ) {
                    Logger.Log( "Session.JoinWorldNow: Player asked to be released from its world, " +
                                "but the world did not contain the player.", LogType.Error );
                }
            }

            ResetVisibleEntities();

            ClearBlockUpdateQueue();

            Map map;

            // try to join the new world
            if( oldWorld != newWorld ) {
                bool announce = !firstTime && (oldWorld.Name != newWorld.Name);
                map = newWorld.AcceptPlayer( Player, announce );
                if( map == null ) {
                    return false;
                }
            } else {
                map = oldWorld.EnsureMapLoaded();
            }
            Player.World = newWorld;

            // Set spawn point
            Position spawn;
            if( doUseWorldSpawn ) {
                spawn = map.Spawn;
            }else{
                spawn = postJoinPosition;
            }
            Player.Position = spawn;

            // Start sending over the level copy
            if( !firstTime ) {
                SendNow( PacketWriter.MakeHandshake( Player,
                                                     ConfigKey.ServerName.GetString(),
                                                     "Loading world " + newWorld.GetClassyName() ) );
            }

            writer.WriteLevelBegin();
            bytesSent++;

            // enable Nagle's algorithm (in case it was turned off by LowLatencyMode)
            // to avoid wasting bandwidth for map transfer
            client.NoDelay = false;

            // Fetch compressed map copy
            byte[] buffer = new byte[1024];
            int mapBytesSent = 0;
            byte[] blockData;
            using( MemoryStream stream = new MemoryStream() ) {
                map.GetCompressedCopy( stream, true );
                blockData = stream.ToArray();
            }
            Logger.Log( "Session.JoinWorldNow: Sending compressed level copy ({0} bytes) to {1}.", LogType.Debug,
                        blockData.Length, Player.Name );

            // Transfer the map copy
            while( mapBytesSent < blockData.Length ) {
                int chunkSize = blockData.Length - mapBytesSent;
                if( chunkSize > 1024 ) {
                    chunkSize = 1024;
                } else {
                    // CRC fix for ManicDigger
                    for( int i = 0; i < buffer.Length; i++ ) {
                        buffer[i] = 0;
                    }
                }
                Array.Copy( blockData, mapBytesSent, buffer, 0, chunkSize );
                byte progress = (byte)(100 * mapBytesSent / blockData.Length);

                // write in chunks of 1024 bytes or less
                writer.WriteLevelChunk( buffer, chunkSize, progress );
                bytesSent += 1028; 
                mapBytesSent += chunkSize;
            }

            // Done sending over level copy
            writer.WriteLevelEnd( map );
            bytesSent += 7;
//.........這裏部分代碼省略.........
開發者ID:fragmer,項目名稱:fCraft,代碼行數:101,代碼來源:Session.cs


注:本文中的fCraft.World.GetClassyName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。