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


C# World.LoadMap方法代碼示例

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


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

示例1: Main

        static void Main( string[] args ) {
            World world = new World( "" );
            world.OnLog += Log;
            world.OnURLChange += SetURL;

            if( world.Init() ) {
                if( args.Length == 1 ) {
                    world.LoadMap( args[0] );
                } else {
                    world.LoadMap( Map.DefaultFileName );
                }

                UpdaterResult update = Updater.CheckForUpdates( world );
                if( update.UpdateAvailable ) {
                    Console.WriteLine( "** A new version of fCraft is available: v{0:0.000}, released {1:0} day(s) ago. **",
                                       Decimal.Divide( update.NewVersionNumber, 1000 ),
                                       DateTime.Now.Subtract( update.ReleaseDate ).TotalDays );
                }

                System.Diagnostics.Process.GetCurrentProcess().PriorityClass = world.config.GetBasePriority();

                if( world.Start() ) {
                    Console.Title = "fCraft " + Updater.GetVersionString() + " - " + world.config.GetString( "ServerName" );
                    string input = "";
                    Console.WriteLine( "** To shut down the server, type /exit **" );
                    while( (input = Console.ReadLine()) != "/exit" ) {
                        Player.Console.ParseMessage( input, true );
                    }
                    world.ShutDown();
                } else {
                    Console.WriteLine( "** Failed to start the server **" );
                    world.ShutDown();
                    Console.ReadLine();
                }
            } else {
                Console.WriteLine( "** Failed to initialize the server **" );
                world.ShutDown();
                Console.ReadLine();
            }
        }
開發者ID:fragmer,項目名稱:fCraft,代碼行數:40,代碼來源:Program.cs

示例2: AddWorld

        public static World AddWorld( string name, Map map, bool neverUnload )
        {
            lock( worldListLock ) {
                if( worlds.ContainsKey( name ) ) return null;
                if( !Player.IsValidName( name ) ) return null;
                World newWorld = new World( name );
                newWorld.neverUnload = neverUnload;

                if( map != null ) {
                    // if a map is given
                    newWorld.map = map;
                    if( !neverUnload ) {
                        newWorld.UnloadMap();// UnloadMap also saves the map
                    } else {
                        newWorld.SaveMap( null );
                    }

                } else {
                    // generate default map
                    if( neverUnload ) newWorld.LoadMap();
                }
                worlds.Add( name, newWorld );

                newWorld.updateTaskId = AddTask( UpdateBlocks, Config.GetInt( ConfigKey.TickInterval ), newWorld );

                if( Config.GetInt( ConfigKey.SaveInterval ) > 0 ) {
                    int saveInterval = Config.GetInt( ConfigKey.SaveInterval ) * 1000;
                    newWorld.saveTaskId = AddTask( SaveMap, saveInterval, newWorld, saveInterval );
                }

                if( Config.GetInt( ConfigKey.BackupInterval ) > 0 ) {
                    int backupInterval = Config.GetInt( ConfigKey.BackupInterval ) * 1000 * 60;
                    newWorld.backupTaskId = AddTask( AutoBackup, backupInterval, newWorld, (Config.GetBool( ConfigKey.BackupOnStartup ) ? 0 : backupInterval) );
                }

                newWorld.UpdatePlayerList();

                return newWorld;
            }
        }
開發者ID:asiekierka,項目名稱:afCraft,代碼行數:40,代碼來源:Server.cs

示例3: Start

 public static void Start( Player player )
 {
     Map map = MapGeneratorOld.GenerateEmpty( 64, 128, 16 );
     map.Save( "maps/minefield.fcm" );
     if ( _world != null ) {
         WorldManager.RemoveWorld( _world );
     }
     WorldManager.AddWorld( Player.Console, "Minefield", map, true );
     _map = map;
     _world = WorldManager.FindWorldExact( "Minefield" );
     SetUpRed();
     SetUpMiddleWater();
     SetUpGreen();
     SetUpMines();
     _map.Spawn = new Position( _map.Width / 2, 5, _ground + 3 ).ToVector3I().ToPlayerCoords();
     _world.LoadMap();
     _world.gameMode = GameMode.MineField;
     _world.EnableTNTPhysics( Player.Console, false );
     Server.Message( "{0}&S started a game of MineField on world Minefield!", player.ClassyName );
     WorldManager.SaveWorldList();
     Server.RequestGC();
 }
開發者ID:GlennMR,項目名稱:800craft,代碼行數:22,代碼來源:MineField.cs

示例4: AddWorld

        public static World AddWorld( Player player, string name, Map map, bool neverUnload ) {
            if( name == null ) throw new ArgumentNullException( "name" );

            if( !World.IsValidName( name ) ) {
                throw new WorldOpException( name, WorldOpExceptionCode.InvalidWorldName );
            }

            lock( WorldListLock ) {
                if( Worlds.ContainsKey( name.ToLower() ) ) {
                    throw new WorldOpException( name, WorldOpExceptionCode.DuplicateWorldName );
                }

                if( RaiseWorldCreatingEvent( player, name, map ) ) {
                    throw new WorldOpException( name, WorldOpExceptionCode.PluginDenied );
                }

                World newWorld = new World( name, neverUnload );

                if( map != null ) {
                    newWorld.Map = map;
                    map.World = newWorld;

                    /*
                    string accessSecurityString = map.GetMeta( "security", "access" );
                    if( accessSecurityString != null ) {
                        try {
                            newWorld.AccessSecurity = new SecurityController( XElement.Parse( accessSecurityString ) );
                        } catch( XmlException ex ) {
                            Logger.Log( "WorldManager.AddWorld: Error loading stored access permissions: {0}", LogType.Error, ex );
                        }
                    }

                    string buildSecurityString = map.GetMeta( "security", "build" );
                    if( buildSecurityString != null ) {
                        try {
                            newWorld.BuildSecurity = new SecurityController( XElement.Parse( buildSecurityString ) );
                        } catch( XmlException ex ) {
                            Logger.Log( "WorldManager.AddWorld: Error loading stored build permissions: {0}", LogType.Error, ex );
                        }
                    }
                    */

                    // if a map is given
                    if( neverUnload ) {
                        newWorld.StartTasks();
                    }else{
                        newWorld.UnloadMap( false );
                    }

                } else if( neverUnload ){
                    newWorld.LoadMap();
                    map = newWorld.Map;
                }

                Worlds.Add( name.ToLower(), newWorld );
                UpdateWorldList();

                RaiseWorldCreatedEvent( player, newWorld );

                return newWorld;
            }
        }
開發者ID:fragmer,項目名稱:fCraft,代碼行數:62,代碼來源:WorldManager.cs

示例5: Init

		static void Init(Player player) {
			world = player.World;
			if (!GameRunning)
				return;
			
			//bool foundBackup = true; //not used
			try {
				Map backupMap = MapConversion.MapUtility.Load("./maps/CTFBackup.fcm");
				world.MapChangedBy = player.Name;
				world = world.ChangeMap(backupMap);
			} catch (Exception ex) {
				player.Message( "Could not load CTF backup map.");
				Logger.Log(LogType.Error,
				           "Error loading CTF backup map: {0}", ex.Message);
				//foundBackup = false;
				map = world.LoadMap();
			}
			
			InitProperties();
			Player.PlacingBlock += PlayerPlacing;
			Player.JoinedWorld += PlayerChangedWorld;
			Player.Moved += PlayerMoved;
			RedTeam.RoundsWon = 0;
			BlueTeam.RoundsWon = 0;
			InitZones();
		}
開發者ID:Magi1053,項目名稱:ProCraft,代碼行數:26,代碼來源:CtfGame.cs


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