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


C# Player.GetBind方法代码示例

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


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

示例1: WaterHandler

        static void WaterHandler( Player player, CommandReader cmd ) {
            bool turnWaterOn = (player.GetBind( Block.Aqua ) != Block.Water ||
                                player.GetBind( Block.Cyan ) != Block.Water ||
                                player.GetBind( Block.Blue ) != Block.Water);

            if( cmd.HasNext && !cmd.NextOnOff( out turnWaterOn ) ) {
                CdWater.PrintUsage( player );
                return;
            }

            if( turnWaterOn ) {
                player.Bind( Block.Aqua, Block.Water );
                player.Bind( Block.Cyan, Block.Water );
                player.Bind( Block.Blue, Block.Water );
                player.Message( "Water: ON. Blue blocks are replaced with water." );
            } else {
                player.ResetBind( Block.Aqua, Block.Cyan, Block.Blue );
                player.Message( "Water: OFF" );
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:20,代码来源:BuildingCommands.cs

示例2: SolidHandler

        static void SolidHandler( Player player, CommandReader cmd ) {
            bool turnSolidOn = (player.GetBind( Block.Stone ) != Block.Admincrete);

            if( cmd.HasNext && !cmd.NextOnOff( out turnSolidOn ) ) {
                CdSolid.PrintUsage( player );
                return;
            }

            if( turnSolidOn ) {
                player.Bind( Block.Stone, Block.Admincrete );
                player.Message( "Solid: ON. Stone blocks are replaced with admincrete." );
            } else {
                player.ResetBind( Block.Stone );
                player.Message( "Solid: OFF" );
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:16,代码来源:BuildingCommands.cs

示例3: GrassHandler

        static void GrassHandler( Player player, CommandReader cmd ) {
            bool turnGrassOn = (player.GetBind( Block.Dirt ) != Block.Grass);

            if( cmd.HasNext && !cmd.NextOnOff( out turnGrassOn ) ) {
                CdGrass.PrintUsage( player );
                return;
            }

            if( turnGrassOn ) {
                player.Bind( Block.Dirt, Block.Grass );
                player.Message( "Grass: ON. Dirt blocks are replaced with grass." );
            } else {
                player.ResetBind( Block.Dirt );
                player.Message( "Grass: OFF" );
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:16,代码来源:BuildingCommands.cs

示例4: WaterHandler

 static void WaterHandler( Player player, CommandReader cmd ) {
     if( player.GetBind( Block.Aqua ) == Block.Water ||
         player.GetBind( Block.Cyan ) == Block.Water ||
         player.GetBind( Block.Blue ) == Block.Water ) {
         player.ResetBind( Block.Aqua, Block.Cyan, Block.Blue );
         player.Message( "Water: OFF" );
     } else {
         player.Bind( Block.Aqua, Block.Water );
         player.Bind( Block.Cyan, Block.Water );
         player.Bind( Block.Blue, Block.Water );
         player.Message( "Water: ON. Blue blocks are replaced with water." );
     }
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:13,代码来源:BuildingCommands.cs

示例5: LavaHandler

 static void LavaHandler( Player player, CommandReader cmd ) {
     if( player.GetBind( Block.Red ) == Block.Lava ) {
         player.ResetBind( Block.Red );
         player.Message( "Lava: OFF" );
     } else {
         player.Bind( Block.Red, Block.Lava );
         player.Message( "Lava: ON. Red blocks are replaced with lava." );
     }
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:9,代码来源:BuildingCommands.cs

示例6: EllipsoidHollowCallback

        /*
        internal static void EllipsoidHollowCallback( Player player, Position[] marks, object tag ) {
            byte drawBlock = (byte)tag;
            if( drawBlock == (byte)Block.Undefined ) {
                drawBlock = (byte)player.LastUsedBlockType;
            }

            // find start/end coordinates
            int sx = Math.Min( marks[0].X, marks[1].X );
            int ex = Math.Max( marks[0].X, marks[1].X );
            int sy = Math.Min( marks[0].Y, marks[1].Y );
            int ey = Math.Max( marks[0].Y, marks[1].Y );
            int sh = Math.Min( marks[0].H, marks[1].H );
            int eh = Math.Max( marks[0].H, marks[1].H );

            // find axis lengths
            double rx = (ex - sx + 1) / 2d;
            double ry = (ey - sy + 1) / 2d;
            double rh = (eh - sh + 1) / 2d;

            double rx2 = 1 / (rx * rx);
            double ry2 = 1 / (ry * ry);
            double rh2 = 1 / (rh * rh);

            // find center points
            double cx = (ex + sx) / 2d;
            double cy = (ey + sy) / 2d;
            double ch = (eh + sh) / 2d;

            // rougher estimation than the non-hollow form, a voxelized surface is a bit funky
            int volume = (int)(4 / 3d * Math.PI * ((rx + .5) * (ry + .5) * (rh + .5) - (rx - .5) * (ry - .5) * (rh - .5)) * 0.85);
            if( !player.CanDraw( volume ) ) {
                player.MessageNow( "You are only allowed to run draw commands that affect up to {0} blocks. This one would affect {1} blocks.",
                                   player.Info.Rank.DrawLimit,
                                   volume );
                return;
            }

            player.UndoBuffer.Clear();

            int blocks = 0, blocksDenied = 0;
            bool cannotUndo = false;

            for( int x = sx; x <= ex; x++ ) {
                for( int y = sy; y <= ey; y++ ) {
                    for( int h = sh; h <= eh; h++ ) {

                        double dx = (x - cx);
                        double dy = (y - cy);
                        double dh = (h - ch);

                        if( (dx * dx) * rx2 + (dy * dy) * ry2 + (dh * dh) * rh2 <= 1 ) {
                            // we touched the surface
                            // keep drilling until we hit an internal block
                            do {
                                DrawOneBlock( player, drawBlock, x, y, h, ref blocks, ref blocksDenied, ref cannotUndo );
                                DrawOneBlock( player, drawBlock, x, y, (int)(ch - dh), ref blocks, ref blocksDenied, ref cannotUndo );
                                dh = (++h - ch);
                            } while( h <= (int)ch &&
                                    ((dx + 1) * (dx + 1) * rx2 + (dy * dy) * ry2 + (dh * dh) * rh2 > 1 ||
                                     (dx - 1) * (dx - 1) * rx2 + (dy * dy) * ry2 + (dh * dh) * rh2 > 1 ||
                                     (dx * dx) * rx2 + (dy + 1) * (dy + 1) * ry2 + (dh * dh) * rh2 > 1 ||
                                     (dx * dx) * rx2 + (dy - 1) * (dy - 1) * ry2 + (dh * dh) * rh2 > 1 ||
                                     (dx * dx) * rx2 + (dy * dy) * ry2 + (dh + 1) * (dh + 1) * rh2 > 1 ||
                                     (dx * dx) * rx2 + (dy * dy) * ry2 + (dh - 1) * (dh - 1) * rh2 > 1) );
                            break;
                        }
                    }
                }
            }
            Logger.Log( "{0} drew a hollow ellipsoid containing {1} blocks of type {2} (on world {3})", LogType.UserActivity,
                        player.Name,
                        blocks,
                        (Block)drawBlock,
                        player.World.Name );
            DrawingFinished( player, "drawn", blocks, blocksDenied );
        }
        */

        internal static void EllipsoidHollowCallback( Player player, Position[] marks, object tag ) {

            HollowShapeArgs args = (HollowShapeArgs)tag;
            byte drawBlock = (byte)args.OuterBlock;
            if( drawBlock == (byte)Block.Undefined ) {
                drawBlock = (byte)player.GetBind( player.LastUsedBlockType );
            }

            // find start/end coordinates
            int sx = Math.Min( marks[0].X, marks[1].X );
            int ex = Math.Max( marks[0].X, marks[1].X );
            int sy = Math.Min( marks[0].Y, marks[1].Y );
            int ey = Math.Max( marks[0].Y, marks[1].Y );
            int sh = Math.Min( marks[0].H, marks[1].H );
            int eh = Math.Max( marks[0].H, marks[1].H );

            bool fillInner = (args.InnerBlock != Block.Undefined && (ex - sx) > 1 && (ey - sy) > 1 && (eh - sh) > 1);

            // find axis lengths
            double rx = (ex - sx + 1) / 2d;
            double ry = (ey - sy + 1) / 2d;
//.........这里部分代码省略.........
开发者ID:fragmer,项目名称:fCraft,代码行数:101,代码来源:BuildingCommands.cs

示例7: GrassHandler

 static void GrassHandler( Player player, CommandReader cmd ) {
     if( player.GetBind( Block.Dirt ) == Block.Grass ) {
         player.ResetBind( Block.Dirt );
         player.Message( "Grass: OFF" );
     } else {
         player.Bind( Block.Dirt, Block.Grass );
         player.Message( "Grass: ON. Dirt blocks are replaced with grass." );
     }
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:9,代码来源:BuildingCommands.cs

示例8: DoubleStairHandler

        static void DoubleStairHandler(Player player, Command cmd)
        {
            if (player.GetBind(Block.Stair) == Block.DoubleStair)
            {
                player.ResetBind(Block.Stair);
                player.Message("DoubleStair: OFF");
            }

            else
            {
                player.Bind(Block.Stair, Block.DoubleStair);
                player.Message("DoubleStair: ON. Stair blocks are replaced with DoubleStairs.");
            }
        }
开发者ID:Eeyle,项目名称:LegendCraftSource,代码行数:14,代码来源:BuildingCommands.cs

示例9: BindHandler

        static void BindHandler( Player player, Command cmd )
        {
            string originalBlockName = cmd.Next();
            if( originalBlockName == null ) {
                player.Message( "All bindings have been reset." );
                player.ResetAllBinds();
                return;
            }
            Block originalBlock = Map.GetBlockByName( originalBlockName );
            if( originalBlock == Block.Undefined ) {
                player.Message( "Bind: Unrecognized block name: {0}", originalBlockName );
                return;
            }

            string replacementBlockName = cmd.Next();
            if( replacementBlockName == null ) {
                if( player.GetBind( originalBlock ) != originalBlock ) {
                    player.Message( "{0} is no longer bound to {1}",
                                    originalBlock,
                                    player.GetBind( originalBlock ) );
                    player.ResetBind( originalBlock );
                } else {
                    player.Message( "{0} is not bound to anything.",
                                    originalBlock );
                }
                return;
            }

            if( cmd.HasNext ) {
                CdBind.PrintUsage( player );
                return;
            }

            Block replacementBlock = Map.GetBlockByName( replacementBlockName );
            if( replacementBlock == Block.Undefined ) {
                player.Message( "Bind: Unrecognized block name: {0}", replacementBlockName );
            } else {
                Permission permission = Permission.Build;
                switch( replacementBlock ) {
                    case Block.Grass:
                        permission = Permission.PlaceGrass;
                        break;
                    case Block.Admincrete:
                        permission = Permission.PlaceAdmincrete;
                        break;
                    case Block.Water:
                        permission = Permission.PlaceWater;
                        break;
                    case Block.Lava:
                        permission = Permission.PlaceLava;
                        break;
                }
                if( player.Can( permission ) ) {
                    player.Bind( originalBlock, replacementBlock );
                    player.Message( "{0} is now replaced with {1}", originalBlock, replacementBlock );
                } else {
                    player.Message( "&WYou do not have {0} permission.", permission );
                }
            }
        }
开发者ID:Eeyle,项目名称:LegendCraftSource,代码行数:60,代码来源:BuildingCommands.cs

示例10: Place

        static void Place(Player player, Command cmd)
        {
            Block block;
            if (player.LastUsedBlockType == Block.Undefined)
            {
                block = Block.Stone;
            }
            else
            {
                block = player.LastUsedBlockType;
            }
            Vector3I Pos = new Vector3I(player.Position.X / 32, player.Position.Y / 32, (player.Position.Z / 32) - 2);

            if (player.CanPlace(player.World.Map, Pos, player.GetBind(block), BlockChangeContext.Manual) != CanPlaceResult.Allowed)
            {
                player.Message("&WYou are not allowed to build here");
                return;
            }

            Player.RaisePlayerPlacedBlockEvent(player, player.WorldMap, Pos, player.WorldMap.GetBlock(Pos), block, BlockChangeContext.Manual);
            BlockUpdate blockUpdate = new BlockUpdate(null, Pos, block);
            player.World.Map.QueueUpdate(blockUpdate);
            player.Message("Block placed below your feet");
        }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:24,代码来源:BuildingCommands.cs

示例11: CenterCallback

        static void CenterCallback(Player player, Vector3I[] marks, object tag)
        {
            if (player.LastUsedBlockType != Block.Undefined)
            {
                int sx = Math.Min(marks[0].X, marks[1].X), ex = Math.Max(marks[0].X, marks[1].X),
                sy = Math.Min(marks[0].Y, marks[1].Y), ey = Math.Max(marks[0].Y, marks[1].Y),
                sz = Math.Min(marks[0].Z, marks[1].Z), ez = Math.Max(marks[0].Z, marks[1].Z);

                BoundingBox bounds = new BoundingBox(sx, sy, sz, ex, ey, ez);
                Vector3I cPos = new Vector3I((bounds.XMin + bounds.XMax) / 2,
                    (bounds.YMin + bounds.YMax) / 2,
                    (bounds.ZMin + bounds.ZMax) / 2);
                int blocksDrawn = 0,
                blocksSkipped = 0;
                UndoState undoState = player.DrawBegin(null);

                World playerWorld = player.World;
                if (playerWorld == null) PlayerOpException.ThrowNoWorld(player);
                Map map = player.WorldMap;
                DrawOneBlock(player, player.World.Map, player.GetBind(player.LastUsedBlockType), cPos,
                          BlockChangeContext.Drawn,
                          ref blocksDrawn, ref blocksSkipped, undoState);
                DrawingFinished(player, "Placed", blocksDrawn, blocksSkipped);
            }else{
                player.Message("&WCannot deduce desired block. Click a block or type out the block name.");
            }
        }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:27,代码来源:BuildingCommands.cs

示例12: CuboidWireframeCallback

        internal static void CuboidWireframeCallback( Player player, Position[] marks, object tag ) {
            byte drawBlock = (byte)tag;
            if( drawBlock == (byte)Block.Undefined ) {
                drawBlock = (byte)player.GetBind( player.LastUsedBlockType );
            }

            // find start/end coordinates
            int sx = Math.Min( marks[0].X, marks[1].X );
            int ex = Math.Max( marks[0].X, marks[1].X );
            int sy = Math.Min( marks[0].Y, marks[1].Y );
            int ey = Math.Max( marks[0].Y, marks[1].Y );
            int sh = Math.Min( marks[0].H, marks[1].H );
            int eh = Math.Max( marks[0].H, marks[1].H );

            // Calculate the upper limit on the volume
            int solidVolume = (ex - sx + 1) *  (ey - sy + 1) *  (eh - sh + 1);
            int hollowVolume = Math.Max( 0, ex - sx - 1 ) * Math.Max( 0, ey - sy - 1 ) * Math.Max( 0, eh - sh - 1 );
            int sideVolume = Math.Max( 0, ex - sx - 1 ) * Math.Max( 0, ey - sy - 1 ) * (ex != sx ? 2 : 1) +
                             Math.Max( 0, ey - sy - 1 ) * Math.Max( 0, eh - sh - 1 ) * (ey != sy ? 2 : 1) +
                             Math.Max( 0, eh - sh - 1 ) * Math.Max( 0, ex - sx - 1 ) * (eh != sh ? 2 : 1);
            int volume = solidVolume - hollowVolume - sideVolume;

            if( !player.CanDraw( volume ) ) {
                player.MessageNow( "You are only allowed to run draw commands that affect up to {0} blocks. This one would affect {1} blocks.",
                                   player.Info.Rank.DrawLimit,
                                   volume );
                return;
            }

            player.UndoBuffer.Clear();

            int blocks = 0, blocksDenied = 0;
            bool cannotUndo = false;

            // Draw cuboid vertices
            DrawOneBlock( player, drawBlock, sx, sy, sh, ref blocks, ref blocksDenied, ref cannotUndo );
            if( sx != ex ) DrawOneBlock( player, drawBlock, ex, sy, sh, ref blocks, ref blocksDenied, ref cannotUndo );
            if( sy != ey ) DrawOneBlock( player, drawBlock, sx, ey, sh, ref blocks, ref blocksDenied, ref cannotUndo );
            if( sx != ex && sy != ey ) DrawOneBlock( player, drawBlock, ex, ey, sh, ref blocks, ref blocksDenied, ref cannotUndo );
            if( sh != eh ) DrawOneBlock( player, drawBlock, sx, sy, eh, ref blocks, ref blocksDenied, ref cannotUndo );
            if( sx != ex && sh != eh ) DrawOneBlock( player, drawBlock, ex, sy, eh, ref blocks, ref blocksDenied, ref cannotUndo );
            if( sy != ey && sh != eh ) DrawOneBlock( player, drawBlock, sx, ey, eh, ref blocks, ref blocksDenied, ref cannotUndo );
            if( sx != ex && sy != ey && sh != eh ) DrawOneBlock( player, drawBlock, ex, ey, eh, ref blocks, ref blocksDenied, ref cannotUndo );

            // Draw edges along the X axis
            if( ex - sx > 1 ) {
                for( int x = sx + 1; x < ex; x++ ) {
                    DrawOneBlock( player, drawBlock, x, sy, sh, ref blocks, ref blocksDenied, ref cannotUndo );
                    if( sh != eh ) DrawOneBlock( player, drawBlock, x, sy, eh, ref blocks, ref blocksDenied, ref cannotUndo );
                    if( sy != ey ) {
                        DrawOneBlock( player, drawBlock, x, ey, sh, ref blocks, ref blocksDenied, ref cannotUndo );
                        if( sh != eh ) DrawOneBlock( player, drawBlock, x, ey, eh, ref blocks, ref blocksDenied, ref cannotUndo );
                    }
                }
            }

            // Draw edges along the Y axis
            if( ey - sy > 1 ) {
                for( int y = sy + 1; y < ey; y++ ) {
                    DrawOneBlock( player, drawBlock, sx, y, sh, ref blocks, ref blocksDenied, ref cannotUndo );
                    if( sh != eh ) DrawOneBlock( player, drawBlock, sx, y, eh, ref blocks, ref blocksDenied, ref cannotUndo );
                    if( sx != ex ) {
                        DrawOneBlock( player, drawBlock, ex, y, sh, ref blocks, ref blocksDenied, ref cannotUndo );
                        if( sh != eh ) DrawOneBlock( player, drawBlock, ex, y, eh, ref blocks, ref blocksDenied, ref cannotUndo );
                    }
                }
            }

            // Draw edges along the H axis
            if( eh - sh > 1 ) {
                for( int h = sh + 1; h < eh; h++ ) {
                    DrawOneBlock( player, drawBlock, sx, sy, h, ref blocks, ref blocksDenied, ref cannotUndo );
                    if( sy != ey ) DrawOneBlock( player, drawBlock, sx, ey, h, ref blocks, ref blocksDenied, ref cannotUndo );
                    if( sx != ex ) {
                        DrawOneBlock( player, drawBlock, ex, ey, h, ref blocks, ref blocksDenied, ref cannotUndo );
                        if( sy != ey ) DrawOneBlock( player, drawBlock, ex, sy, h, ref blocks, ref blocksDenied, ref cannotUndo );
                    }
                }
            }

            Logger.Log( "{0} drew a wireframe cuboid containing {1} blocks of type {2} (on world {3})", LogType.UserActivity,
                        player.Name,
                        blocks,
                        (Block)drawBlock,
                        player.World.Name );
            DrawingFinished( player, "drawn", blocks, blocksDenied );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:87,代码来源:BuildingCommands.cs

示例13: CuboidHollowCallback

        internal static void CuboidHollowCallback( Player player, Position[] marks, object tag ) {
            HollowShapeArgs args = (HollowShapeArgs)tag;
            byte drawBlock = (byte)args.OuterBlock;
            if( drawBlock == (byte)Block.Undefined ) {
                drawBlock = (byte)player.GetBind( player.LastUsedBlockType );
            }

            // find start/end coordinates
            int sx = Math.Min( marks[0].X, marks[1].X );
            int ex = Math.Max( marks[0].X, marks[1].X );
            int sy = Math.Min( marks[0].Y, marks[1].Y );
            int ey = Math.Max( marks[0].Y, marks[1].Y );
            int sh = Math.Min( marks[0].H, marks[1].H );
            int eh = Math.Max( marks[0].H, marks[1].H );

            bool fillInner = (args.InnerBlock != Block.Undefined && (ex - sx) > 1 && (ey - sy) > 1 && (eh - sh) > 1);


            int volume = (ex - sx + 1) * (ey - sy + 1) * (eh - sh + 1);
            if( !fillInner ) {
                volume -= (ex - sx - 1) * (ey - sy - 1) * (eh - sh - 1);
            }

            if( !player.CanDraw( volume ) ) {
                player.MessageNow( "You are only allowed to run draw commands that affect up to {0} blocks. This one would affect {1} blocks.",
                                   player.Info.Rank.DrawLimit,
                                   volume );
                return;
            }

            player.UndoBuffer.Clear();

            int blocks = 0, blocksDenied = 0;
            bool cannotUndo = false;

            for( int x = sx; x <= ex; x++ ) {
                for( int y = sy; y <= ey; y++ ) {
                    DrawOneBlock( player, drawBlock, x, y, sh, ref blocks, ref blocksDenied, ref cannotUndo );
                    DrawOneBlock( player, drawBlock, x, y, eh, ref blocks, ref blocksDenied, ref cannotUndo );
                }
            }
            for( int x = sx; x <= ex; x++ ) {
                for( int h = sh; h <= eh; h++ ) {
                    DrawOneBlock( player, drawBlock, x, sy, h, ref blocks, ref blocksDenied, ref cannotUndo );
                    DrawOneBlock( player, drawBlock, x, ey, h, ref blocks, ref blocksDenied, ref cannotUndo );
                }
            }
            for( int y = sy; y <= ey; y++ ) {
                for( int h = sh; h <= eh; h++ ) {
                    DrawOneBlock( player, drawBlock, sx, y, h, ref blocks, ref blocksDenied, ref cannotUndo );
                    DrawOneBlock( player, drawBlock, ex, y, h, ref blocks, ref blocksDenied, ref cannotUndo );
                }
            }

            if( fillInner ) {
                for( int x = sx + 1; x < ex; x += DrawStride ) {
                    for( int y = sy + 1; y < ey; y += DrawStride ) {
                        for( int h = sh + 1; h < eh; h++ ) {
                            for( int y3 = 0; y3 < DrawStride && y + y3 < ey; y3++ ) {
                                for( int x3 = 0; x3 < DrawStride && x + x3 < ex; x3++ ) {
                                    DrawOneBlock( player, (byte)args.InnerBlock, x + x3, y + y3, h, ref blocks, ref blocksDenied, ref cannotUndo );
                                }
                            }
                        }
                    }
                }
            }

            Logger.Log( "{0} drew a hollow cuboid containing {1} blocks of type {2} (on world {3})", LogType.UserActivity,
                        player.Name,
                        blocks,
                        (Block)drawBlock,
                        player.World.Name );
            DrawingFinished( player, "drawn", blocks, blocksDenied );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:75,代码来源:BuildingCommands.cs

示例14: LineCallback

        internal static void LineCallback( Player player, Position[] marks, object tag ) {
            byte drawBlock = (byte)tag;
            if( drawBlock == (byte)Block.Undefined ) {
                drawBlock = (byte)player.GetBind( player.LastUsedBlockType );
            }

            player.UndoBuffer.Clear();

            int blocks = 0, blocksDenied = 0;
            bool cannotUndo = false;

            // LINE CODE

            int x1 = marks[0].X,
                y1 = marks[0].Y,
                z1 = marks[0].H,
                x2 = marks[1].X,
                y2 = marks[1].Y,
                z2 = marks[1].H;
            int i, err1, err2;
            int[] pixel = new int[3];
            pixel[0] = x1;
            pixel[1] = y1;
            pixel[2] = z1;
            int dx = x2 - x1;
            int dy = y2 - y1;
            int dz = z2 - z1;
            int xInc = (dx < 0) ? -1 : 1;
            int l = Math.Abs( dx );
            int yInc = (dy < 0) ? -1 : 1;
            int m = Math.Abs( dy );
            int zInc = (dz < 0) ? -1 : 1;
            int n = Math.Abs( dz );
            int dx2 = l << 1;
            int dy2 = m << 1;
            int dz2 = n << 1;

            DrawOneBlock( player, drawBlock, x2, y2, z2, ref blocks, ref blocksDenied, ref cannotUndo );

            if( (l >= m) && (l >= n) ) {

                err1 = dy2 - l;
                err2 = dz2 - l;
                for( i = 0; i < l; i++ ) {
                    DrawOneBlock( player, drawBlock, pixel[0], pixel[1], pixel[2], ref blocks, ref blocksDenied, ref cannotUndo );
                    if( err1 > 0 ) {
                        pixel[1] += yInc;
                        err1 -= dx2;
                    }
                    if( err2 > 0 ) {
                        pixel[2] += zInc;
                        err2 -= dx2;
                    }
                    err1 += dy2;
                    err2 += dz2;
                    pixel[0] += xInc;
                }
            } else if( (m >= l) && (m >= n) ) {
                err1 = dx2 - m;
                err2 = dz2 - m;
                for( i = 0; i < m; i++ ) {
                    DrawOneBlock( player, drawBlock, pixel[0], pixel[1], pixel[2], ref blocks, ref blocksDenied, ref cannotUndo );
                    if( err1 > 0 ) {
                        pixel[0] += xInc;
                        err1 -= dy2;
                    }
                    if( err2 > 0 ) {
                        pixel[2] += zInc;
                        err2 -= dy2;
                    }
                    err1 += dx2;
                    err2 += dz2;
                    pixel[1] += yInc;
                }
            } else {
                err1 = dy2 - n;
                err2 = dx2 - n;
                for( i = 0; i < n; i++ ) {
                    DrawOneBlock( player, drawBlock, pixel[0], pixel[1], pixel[2], ref blocks, ref blocksDenied, ref cannotUndo );
                    if( err1 > 0 ) {
                        pixel[1] += yInc;
                        err1 -= dz2;
                    }
                    if( err2 > 0 ) {
                        pixel[0] += xInc;
                        err2 -= dz2;
                    }
                    err1 += dy2;
                    err2 += dx2;
                    pixel[2] += zInc;
                }
            }

            // END LINE CODE
            Logger.Log( "{0} drew a line containing {1} blocks of type {2} (on world {3})", LogType.UserActivity,
                        player.Name,
                        blocks,
                        (Block)drawBlock,
                        player.World.Name );
            DrawingFinished( player, "drawn", blocks, blocksDenied );
//.........这里部分代码省略.........
开发者ID:fragmer,项目名称:fCraft,代码行数:101,代码来源:BuildingCommands.cs

示例15: LavaHandler

        static void LavaHandler( Player player, CommandReader cmd ) {
            bool turnLavaOn = (player.GetBind( Block.Red ) != Block.Lava);

            if( cmd.HasNext && !cmd.NextOnOff( out turnLavaOn ) ) {
                CdLava.PrintUsage( player );
                return;
            }

            if( turnLavaOn ) {
                player.Bind( Block.Red, Block.Lava );
                player.Message( "Lava: ON. Red blocks are replaced with lava." );
            } else {
                player.ResetBind( Block.Red );
                player.Message( "Lava: OFF" );
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:16,代码来源:BuildingCommands.cs


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