• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# fCraft.Map类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Map类属于fCraft命名空间,在下文中一共展示了Map类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: WriteLevelEnd

 internal void WriteLevelEnd( Map map ) {
     if( map == null ) throw new ArgumentNullException( "map" );
     Write( OpCode.MapEnd );
     Write( (short)map.WidthX );
     Write( (short)map.Height );
     Write( (short)map.WidthY );
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:7,代码来源:PacketWriter.cs


示例2: LoadMap

        public void LoadMap() {
            lock( WorldLock ) {
                if( Map != null ) return;

                    try {
                        Map = MapUtility.Load( GetMapName() );
                    } catch( Exception ex ) {
                        Logger.Log( "World.LoadMap: Failed to load map ({0}): {1}", LogType.Error,
                                    GetMapName(), ex );
                    }

                // or generate a default one
                if( Map != null ) {
                    Map.World = this;
                } else {
                    Logger.Log( "World.LoadMap: Generating default flatgrass level.", LogType.SystemActivity );
                    Map = new Map( this, 64, 64, 64, true );

                    MapGenerator.GenerateFlatgrass( Map );
                    Map.ResetSpawn();
                }
                StartTasks();

                if( OnLoaded != null ) OnLoaded();
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:26,代码来源:World.cs


示例3: GenerateFlatgrass

 public static Map GenerateFlatgrass( int width, int length, int height ) {
     Map map = new Map( null, width, length, height, true );
     map.Blocks.MemSet( (byte)Block.Stone, 0, width * length * (height / 2 - FlatgrassDirtLevel) );
     map.Blocks.MemSet( (byte)Block.Dirt, width * length * (height / 2 - FlatgrassDirtLevel), width * length * (FlatgrassDirtLevel - 1) );
     map.Blocks.MemSet( (byte)Block.Grass, width * length * (height / 2 - 1), width * length );
     return map;
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:7,代码来源:MapGenerator.cs


示例4: Deserialize

 public void Deserialize( string group, string key, string value, Map map )
 {
     try {
         WorldVariableLoader data = World.Deserialize( key, value, map );
         data.LoadWorldVariables( map.World );
     } catch ( Exception ex ) {
         Logger.Log( LogType.Error, "WorldV.Deserialize: Error deserializing key {0}: {1}", key, ex );
     }
 }
开发者ID:Jonty800,项目名称:800Craft-SMP,代码行数:9,代码来源:WorldVariableLoader.cs


示例5: Serialize

 public int Serialize( Map map, Stream stream, IMapConverterEx converter )
 {
     BinaryWriter writer = new BinaryWriter( stream );
     int count = 0;
     foreach ( World world in WorldManager.Worlds ) {
         converter.WriteMetadataEntry( _group[0], world.Name, world.Serialize(), writer );
         ++count;
     }
     return count;
 }
开发者ID:Jonty800,项目名称:800Craft-SMP,代码行数:10,代码来源:WorldVariableLoader.cs


示例6: MapGenerator

 public MapGenerator( Random _rand, Map _map, Player _player, string _filename, double _roughness, double _smoothingOver, double _smoothingUnder, double _water, double _midpoint, double _sides, bool _hollow ) {
     rand = _rand;
     map = _map;
     player = _player;
     filename = _filename;
     roughness = _roughness;
     smoothingOver = _smoothingOver;
     smoothingUnder = _smoothingUnder;
     midpoint = _midpoint;
     sides = _sides;
     water = _water;
     hollow = _hollow;
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:13,代码来源:MapGenerator.cs


示例7: Serialize

 public int Serialize( Map map, Stream stream, IMapConverterEx converter )
 {
     BinaryWriter writer = new BinaryWriter( stream );
     int count = 0;
     if ( map.MessageBlocks != null ) {
         if ( map.MessageBlocks.Count >= 1 ) {
             foreach ( MessageBlock MessageBlock in map.MessageBlocks ) {
                 converter.WriteMetadataEntry( _group[0], MessageBlock.Name, MessageBlock.Serialize(), writer );
                 ++count;
             }
         }
     }
     return count;
 }
开发者ID:Jonty800,项目名称:800Craft-SMP,代码行数:14,代码来源:MessageBlockSerialization.cs


示例8: Deserialize

 public void Deserialize( string group, string key, string value, Map map )
 {
     try {
         MessageBlock MessageBlock = MessageBlock.Deserialize( key, value, map );
         if ( map.MessageBlocks == null ) map.MessageBlocks = new ArrayList();
         if ( map.MessageBlocks.Count >= 1 ) {
             if ( map.MessageBlocks.Contains( key ) ) {
                 Logger.Log( LogType.Error, "Map loading warning: duplicate MessageBlock name found: " + key + ", ignored" );
                 return;
             }
         }
         map.MessageBlocks.Add( MessageBlock );
     } catch ( Exception ex ) {
         Logger.Log( LogType.Error, "MessageBlock.Deserialize: Error deserializing MessageBlock {0}: {1}", key, ex );
     }
 }
开发者ID:Jonty800,项目名称:800Craft-SMP,代码行数:16,代码来源:MessageBlockSerialization.cs


示例9: Deserialize

 public void Deserialize(string group, string key, string value, Map map)
 {
     try
     {
         Life2DZone life = Life2DZone.Deserialize(key, value, map);
         if (map.LifeZones.ContainsKey(key.ToLower()))
         {
             Logger.Log(LogType.Error, "Map loading warning: duplicate life name found: " + key+", ignored");
             return;
         }
         map.LifeZones.Add(key.ToLower(), life);
     }
     catch (Exception ex)
     {
         Logger.Log(LogType.Error, "LifeSerialization.Deserialize: Error deserializing life {0}: {1}", key, ex);
     }
 }
开发者ID:Eeyle,项目名称:LegendCraftSource,代码行数:17,代码来源:LifeSerialization.cs


示例10: Serialize

        public int Serialize(Map map, Stream stream, IMapConverterEx converter)
        {
            BinaryWriter writer = new BinaryWriter(stream);
            int count = 0;
            World w = map.World;
            Object lockObj = null == w ? new object() : w.SyncRoot;

            IEnumerable<Life2DZone> lifes;
            lock (lockObj)
            {
                lifes = map.LifeZones.Values.ToList(); //copies the current life list under a lock
            }
            foreach (Life2DZone life in lifes)
            {
                converter.WriteMetadataEntry(_group[0], life.Name, life.Serialize(), writer);
                ++count;
            }
            return count;
        }
开发者ID:Eeyle,项目名称:LegendCraftSource,代码行数:19,代码来源:LifeSerialization.cs


示例11: SealLiquids

 static void SealLiquids(Map map, byte sealantType)
 {
     for (int x = 1; x < map.Width - 1; x++)
     {
         for (int z = 1; z < map.Height; z++)
         {
             for (int y = 1; y < map.Length - 1; y++)
             {
                 int index = map.Index(x, y, z);
                 if ((map.Blocks[index] == 10 || map.Blocks[index] == 11 || map.Blocks[index] == 8 || map.Blocks[index] == 9) &&
                     (map.GetBlock(x - 1, y, z) == Block.Air || map.GetBlock(x + 1, y, z) == Block.Air ||
                     map.GetBlock(x, y - 1, z) == Block.Air || map.GetBlock(x, y + 1, z) == Block.Air ||
                     map.GetBlock(x, y, z - 1) == Block.Air))
                 {
                     map.Blocks[index] = sealantType;
                 }
             }
         }
     }
 }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:20,代码来源:MapGenerator.cs


示例12: AddSingleVein

        static void AddSingleVein(Random rand, Map map, byte bedrockType, byte fillingType, int k, double maxDiameter, int l, int i1)
        {
            int j1 = rand.Next(0, map.Width);
            int k1 = rand.Next(0, map.Height);
            int l1 = rand.Next(0, map.Length);

            double thirteenOverK = 1 / (double)k;

            for (int i2 = 0; i2 < i1; i2++)
            {
                int j2 = j1 + (int)(.5 * (rand.NextDouble() - .5) * map.Width);
                int k2 = k1 + (int)(.5 * (rand.NextDouble() - .5) * map.Height);
                int l2 = l1 + (int)(.5 * (rand.NextDouble() - .5) * map.Length);
                for (int l3 = 0; l3 < k; l3++)
                {
                    int diameter = (int)(maxDiameter * rand.NextDouble() * map.Width);
                    if (diameter < 1) diameter = 2;
                    int radius = diameter / 2;
                    if (radius == 0) radius = 1;
                    int i3 = (int)((1 - thirteenOverK) * j1 + thirteenOverK * j2 + (l * radius) * (rand.NextDouble() - .5));
                    int j3 = (int)((1 - thirteenOverK) * k1 + thirteenOverK * k2 + (l * radius) * (rand.NextDouble() - .5));
                    int k3 = (int)((1 - thirteenOverK) * l1 + thirteenOverK * l2 + (l * radius) * (rand.NextDouble() - .5));
                    for (int k4 = 0; k4 < diameter; k4++)
                    {
                        for (int l4 = 0; l4 < diameter; l4++)
                        {
                            for (int i5 = 0; i5 < diameter; i5++)
                            {
                                if ((k4 - radius) * (k4 - radius) + (l4 - radius) * (l4 - radius) + (i5 - radius) * (i5 - radius) < radius * radius &&
                                    i3 + k4 < map.Width && j3 + l4 < map.Height && k3 + i5 < map.Length &&
                                    i3 + k4 >= 0 && j3 + l4 >= 0 && k3 + i5 >= 0)
                                {

                                    int index = i3 + k4 + map.Width * map.Length * (map.Height - 1 - (j3 + l4)) + map.Width * (k3 + i5);

                                    if (map.Blocks[index] == bedrockType)
                                    {
                                        map.Blocks[index] = fillingType;
                                    }
                                }
                            }
                        }
                    }
                }
                j1 = j2;
                k1 = k2;
                l1 = l2;
            }
        }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:49,代码来源:MapGenerator.cs


示例13: removal

 public static void removal(ConcurrentDictionary<String, Vector3I> bullets, Map map)
 {
     foreach (Vector3I bp in bullets.Values)
     {
         map.QueueUpdate(new BlockUpdate(null,
             (short)bp.X,
             (short)bp.Y,
             (short)bp.Z,
             Block.Air));
         Vector3I removed;
         bullets.TryRemove(bp.ToString(), out removed);
     }
 }
开发者ID:Rhinovex,项目名称:LegendCraft,代码行数:13,代码来源:GunHandler.cs


示例14: 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


示例15: RaisePlayerPlacedBlockEvent

 internal static void RaisePlayerPlacedBlockEvent( Player player, Map map, Vector3I coords,
                                                   Block oldBlock, Block newBlock, BlockChangeContext context ) {
     var handler = PlacedBlock;
     if( handler != null ) {
         handler( null, new PlayerPlacedBlockEventArgs( player, map, coords, oldBlock, newBlock, context ) );
     }
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:7,代码来源:Player.Events.cs


示例16: MakeLevelEnd

 internal static Packet MakeLevelEnd( Map map ) {
     Packet packet = new Packet( 7 );
     packet.data[0] = (byte)OutputCodes.LevelEnd;
     ToNetOrder( (short)map.widthX, packet.data, 1 );
     ToNetOrder( (short)map.height, packet.data, 3 );
     ToNetOrder( (short)map.widthY, packet.data, 5 );
     return packet;
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:8,代码来源:PacketWriter.cs


示例17: PlantGiantTrees

 void PlantGiantTrees() {
     if( genParams.GiantTreeDensity <= 0 ) return;
     Map outMap = new Map( null, map.Width, map.Length, map.Height, false ) {
         Blocks = (byte[])map.Blocks.Clone()
     };
     int plantableBlocks = ComputeSurfaceCoverage( Block.Grass );
     var foresterArgs = new ForesterArgs {
         Map = map,
         Rand = rand,
         TreeCount = (int)(plantableBlocks*genParams.GiantTreeDensity/BaseGiantTreeDensity),
         Operation = Forester.ForesterOperation.Add,
         PlantOn = Block.Grass
     };
     foresterArgs.BlockPlacing += ( sender, e ) => outMap.SetBlock( e.Coordinate, e.Block );
     Forester.Generate( foresterArgs );
     map = outMap;
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:17,代码来源:FloatingIslandMapGen.cs


示例18: Generate

        public override Map Generate() {
            if( Finished ) return Result;
            try {
                StatusString = "Generating";
                FlatMapGenParameters p = (FlatMapGenParameters)Parameters;

                int layer = Parameters.MapWidth*Parameters.MapLength;

                Map map = new Map( null, Parameters.MapWidth, Parameters.MapLength, Parameters.MapHeight, true );

                int offset = 0;
                if( p.BedrockThickness > 0 ) {
                    int bedrockBlocks = layer*p.BedrockThickness;
                    map.Blocks.MemSet( (byte)p.BedrockBlock, 0, bedrockBlocks );
                    offset += bedrockBlocks;
                }

                int rockBlocks = layer*(Parameters.MapHeight/2 + p.GroundLevelOffset -
                                        p.BedrockThickness - p.SoilThickness - p.SurfaceThickness);
                map.Blocks.MemSet( (byte)p.DeepBlock, offset, rockBlocks );
                offset += rockBlocks;

                if( p.SoilThickness > 0 ) {
                    int soilBlocks = layer*p.SoilThickness;
                    map.Blocks.MemSet( (byte)p.ShallowBlock, offset, soilBlocks );
                    offset += soilBlocks;
                }

                if( p.SurfaceThickness > 0 ) {
                    int surfaceBlocks = layer*p.SurfaceThickness;
                    map.Blocks.MemSet( (byte)p.SurfaceBlock, offset, surfaceBlocks );
                    offset += surfaceBlocks;
                }

                if( p.AirBlock != Block.Air ) {
                    map.Blocks.MemSet( (byte)p.AirBlock, offset, map.Blocks.Length - offset );
                }

                Result = map;
                StatusString = "Done";
                return map;
            } finally {
                Finished = true;
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:45,代码来源:FlatMapGen.cs


示例19: 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


示例20: GenerateOcean

 public static Map GenerateOcean(int width, int length, int height)
 {
     Map map = new Map(null, width, length, height, true);
     map.Blocks.MemSet((byte)Block.Sand, 0, width * length);
     map.Blocks.MemSet((byte)Block.Water, width * length, width * length * (height / 2 - 1));
     return map;
 }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:7,代码来源:MapGenerator.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# fCraft.Packet类代码示例发布时间:2022-05-26
下一篇:
C# fCraft.CommandReader类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap