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


C# DrawMode.ToString方法代码示例

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


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

示例1: Draw

        void Draw( Player player, Command command, DrawMode mode ) {
            if( !player.Can( Permissions.Draw ) ) {
                world.NoAccessMessage( player );
                return;
            }
            if( player.drawingInProgress ) {
                player.Message( "Another draw command is already in progress. Please wait." );
                return;
            }
            string blockName = command.Next();
            Block block;
            if( blockName == null || blockName == "" ) {
                if( mode == DrawMode.Cuboid ) {
                    player.Message( "Usage: " + Color.Help + "/cuboid blockName" + Color.Sys + " or " + Color.Help + "/cub blockName" );
                } else {
                    player.Message( "Usage: " + Color.Help + "/ellipsoid blockName" + Color.Sys + " or " + Color.Help + "/ell blockName" );
                }
                return;
            }
            try {
                block = Map.GetBlockByName( blockName );
            } catch( Exception ) {
                player.Message( "Unknown block name: " + blockName );
                return;
            }
            player.tag = block;

            Permissions permission = Permissions.Build;
            switch( block ) {
                case Block.Admincrete: permission = Permissions.PlaceAdmincrete; break;
                case Block.Air: permission = Permissions.Delete; break;
                case Block.Water:
                case Block.StillWater: permission = Permissions.PlaceWater; break;
                case Block.Lava:
                case Block.StillLava: permission = Permissions.PlaceLava; break;
            }
            if( !player.Can( permission ) ) {
                player.Message( "You are not allowed to draw with this block." );
                return;
            }

            player.marksExpected = 2;
            player.markCount = 0;
            player.marks.Clear();
            player.Message( mode.ToString() + ": Place a block or type /mark to use your location." );

            if( mode == DrawMode.Cuboid ) {
                player.selectionCallback = DrawCuboid;
            } else {
                player.selectionCallback = DrawEllipsoid;
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:52,代码来源:DrawCommands.cs

示例2: DrawSolidBall

        /// <summary>
        /// The opacity passed in will be applied after figuring out the opacity of mode (if mode says 128, and opacity is .5, then
        /// the final opacity is 64)
        /// </summary>
        public void DrawSolidBall(SolidBall ball, DrawMode mode, CollisionStyle collisionStyle, bool drawRed, double opacity)
        {
            Color color;
            #region Figure out the color

            if (drawRed)
            {
                color = REDCOLOR;
            }
            else
            {
                color = Color.RoyalBlue;
            }

            #endregion

            int finalOpacity;
            #region Figure out the opacity

            switch (mode)
            {
                case DrawMode.Building:
                    finalOpacity = BUILDINGBALLFILLOPACTIY;
                    break;

                case DrawMode.Selected:
                case DrawMode.Standard:
                    finalOpacity = STANDARDBALLFILLOPACTIY;
                    break;

                default:
                    throw new ApplicationException("Unknown DrawMode: " + mode.ToString());
            }

            finalOpacity = Convert.ToInt32(finalOpacity * opacity);
            if (finalOpacity < 0)
            {
                finalOpacity = 0;
            }
            else if (finalOpacity > 255)
            {
                finalOpacity = 255;
            }

            #endregion

            MyVector dirFacing;
            #region Figure out direction facing

            dirFacing = ball.DirectionFacing.Standard.Clone();
            dirFacing.BecomeUnitVector();
            dirFacing.Multiply(ball.Radius);
            dirFacing.Add(ball.Position);

            #endregion

            // Collision Style
            DrawCollisionStyle(ball.Position, ball.Radius, collisionStyle);

            // Fill the circle
            using (Brush brush = new SolidBrush(Color.FromArgb(finalOpacity, color)))
            {
                _viewer.FillCircle(brush, ball.Position, ball.Radius);
            }

            // Draw direction facing
            _viewer.DrawLine(Color.FromArgb(finalOpacity, Color.White), 2d, ball.Position, dirFacing);

            #region Draw the edge

            switch (mode)
            {
                case DrawMode.Building:
                    _viewer.DrawCircle(Color.FromArgb(finalOpacity, _buildingPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius);
                    break;

                case DrawMode.Standard:
                    _viewer.DrawCircle(Color.FromArgb(finalOpacity, _standardPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius);
                    break;

                case DrawMode.Selected:
                    _viewer.DrawCircle_Selected(ball.Position, ball.Radius);
                    break;
            }

            #endregion

            //TODO:  Show Stats
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:93,代码来源:ObjectRenderer.cs

示例3: DrawBall

        /// <summary>
        /// The opacity passed in will be applied after figuring out the opacity of mode (if mode says 128, and opacity is .5, then
        /// the final opacity is 64)
        /// </summary>
        public void DrawBall(Ball ball, DrawMode mode, CollisionStyle collisionStyle, bool drawRed, double opacity)
        {
            Color color;
            #region Figure out the color

            if (drawRed)
            {
                color = REDCOLOR;
            }
            else
            {
                color = Color.Gold;
            }

            #endregion

            int finalOpacity;
            #region Figure out the opacity

            switch (mode)
            {
                case DrawMode.Building:
                    finalOpacity = BUILDINGBALLFILLOPACTIY;
                    break;

                case DrawMode.Selected:
                case DrawMode.Standard:
                    finalOpacity = STANDARDBALLFILLOPACTIY;
                    break;

                default:
                    throw new ApplicationException("Unknown DrawMode: " + mode.ToString());
            }

            finalOpacity = Convert.ToInt32(finalOpacity * opacity);
            if (finalOpacity < 0)
            {
                finalOpacity = 0;
            }
            else if (finalOpacity > 255)
            {
                finalOpacity = 255;
            }

            #endregion

            // Collision Style
            DrawCollisionStyle(ball.Position, ball.Radius, collisionStyle);

            // Fill the circle
            using (Brush brush = new SolidBrush(Color.FromArgb(finalOpacity, color)))
            {
                _viewer.FillCircle(brush, ball.Position, ball.Radius);
            }

            #region Draw the edge

            switch (mode)
            {
                case DrawMode.Building:
                    _viewer.DrawCircle(Color.FromArgb(finalOpacity, _buildingPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius);
                    break;

                case DrawMode.Standard:
                    _viewer.DrawCircle(Color.FromArgb(finalOpacity, _standardPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius);
                    break;

                case DrawMode.Selected:
                    _viewer.DrawCircle_Selected(ball.Position, ball.Radius);
                    break;
            }

            #endregion

            //TODO:  Show Stats
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:80,代码来源:ObjectRenderer.cs

示例4: Draw


//.........这里部分代码省略.........

            // if a type is specified in chat, try to parse it
            if( blockName != null ) {
                Block block;
                try {
                    block = Map.GetBlockByName( blockName );
                } catch( Exception ) {
                    try
                    {
                        block = (Block)Convert.ToByte(blockName);
                    }
                    catch (Exception)
                    {
                        player.Message("Unknown block name: " + blockName);
                        return;
                    }
                }
                if ((int)block < 0 || (int)block > 49)
                {
                    player.Message("Invalid block ID!");
                    return;
                }
                switch( block ) {
                    case Block.Admincrete: permission = Permissions.PlaceAdmincrete; break;
                    case Block.Air: permission = Permissions.Delete; break;
                    case Block.Water: permission = Permissions.PlaceRealWater; break;
                    case Block.StillWater: permission = Permissions.PlaceWater; break;
                    case Block.Lava: permission = Permissions.PlaceRealLava; break;
                    case Block.StillLava: permission = Permissions.PlaceLava; break;
                }

                blockTypeTag = block;
            }
            else if (mode == DrawMode.Replace)
            {
                player.Message("Not enough parameters!");
                return;
            }

            Block block2 = Block.Undefined;
            if (blockName2 != null && mode == DrawMode.Replace)
            {
                try
                {
                    block2 = Map.GetBlockByName(blockName2);
                }
                catch (Exception)
                {
                    try
                    {
                        block2 = (Block)Convert.ToByte(blockName2);
                    }
                    catch (Exception)
                    {
                        player.Message("Unknown block name: " + blockName2);
                        return;
                    }
                }
                if ((int)block2 < 0 || (int)block2 > 49)
                {
                    player.Message("Invalid block ID!");
                    return;
                }
            }
            else if (mode == DrawMode.Replace && blockName2 == null)
            {
                player.Message("Not enough parameters!");
                return;
            }
            // otherwise, use the last-used-block

            if( !player.Can( permission ) ) {
                player.Message( "You are not allowed to draw with this block." );
                return;
            }

            player.tag = blockTypeTag;
            if(mode == DrawMode.Replace) player.bl2 = block2;
            switch( mode ) {
                case DrawMode.Cuboid:
                    player.selectionCallback = DrawCuboid;
                    player.marksExpected = 2;
                    break;
                case DrawMode.Ellipsoid:
                    player.selectionCallback = DrawEllipsoid;
                    player.marksExpected = 2;
                    break;
                case DrawMode.Fill:
                    player.selectionCallback = DoFill;
                    player.marksExpected = 1;
                    break;
                case DrawMode.Replace:
                    player.selectionCallback = DoReplace;
                    player.marksExpected = 2;
                    break;
            }
            player.markCount = 0;
            player.marks.Clear();
            player.Message( mode.ToString() + ": Place a block or type /mark to use your location." );
        }
开发者ID:asiekierka,项目名称:afCraft,代码行数:101,代码来源:DrawCommands.cs


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