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


C# Drawing.DrawOperation类代码示例

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


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

示例1:

 IBrushInstance IBrush.MakeInstance( Player player, CommandReader cmd, DrawOperation op ) {
     if( ReadParams( cmd ) ) {
         return this;
     } else {
         return null;
     }
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:7,代码来源:DrawOpWithBrush.cs

示例2: NextBlock

 public override Block NextBlock(DrawOperation op) {
     if (op == null) throw new ArgumentNullException("op");
     Block block = op.Map.GetBlock(op.Coords);
     for (int i = 0; i < Blocks.Length; i++) {
         if (block == Blocks[i]) {
             return Block.None;
         }
     }
     return Replacement;
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:10,代码来源:ReplaceNotBrush.cs

示例3: Begin

 public bool Begin(Player player, DrawOperation state) {
     if (player == null) throw new ArgumentNullException("player");
     if (state == null) throw new ArgumentNullException("state");
     if (Blocks == null || Blocks.Length == 0) {
         if (player.LastUsedBlockType == Block.None) {
             player.Message("Cannot deduce desired block. Click a block or type out the block name.");
             return false;
         } else {
             Blocks = new[] {
                 player.GetBind(player.LastUsedBlockType)
             };
         }
     }
     return true;
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:15,代码来源:NormalBrush.cs

示例4: MakeInstance

        public IBrushInstance MakeInstance( Player player, CommandReader cmd, DrawOperation state ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( cmd == null ) throw new ArgumentNullException( "cmd" );
            if( state == null ) throw new ArgumentNullException( "state" );
            List<Block> blocks = new List<Block>();

            while( cmd.HasNext ) {
                Block block;
                if( !cmd.NextBlock( player, true, out block ) ) {
                    return null;
                }
                blocks.Add( block );
            }

            return new NormalBrush( blocks.ToArray() );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:16,代码来源:NormalBrush.cs

示例5: Begin

        public virtual bool Begin( Player player, DrawOperation op ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( op == null ) throw new ArgumentNullException( "op" );

            if( op.Bounds.Volume > 32 * 32 * 32 ) {
                player.Message( "{0} brush: Preparing, please wait...", Brush.Factory.Name );
            }

            noise3D = new PerlinNoise3D( new Random( Seed ) ) {
                Amplitude = 1,
                Frequency = Frequency,
                Octaves = Octaves,
                Persistence = Persistence
            };

            // generate and normalize the raw (float) data
            float[, ,] rawData = new float[op.Bounds.Width, op.Bounds.Length, op.Bounds.Height];
            for( int x = 0; x < op.Bounds.Width; x++ ) {
                for( int y = 0; y < op.Bounds.Length; y++ ) {
                    for( int z = 0; z < op.Bounds.Height; z++ ) {
                        rawData[x, y, z] = noise3D.Compute( x, y, z );
                    }
                }
            }
            Noise.Normalize( rawData, out normMultiplier, out normConstant );
            if( MapAllValues( rawData ) ) {
                Noise.Normalize( rawData, out normMultiplier, out normConstant );
            }

            // create a mapping of raw data to blocks
            int totalBlocks = BlockRatios.Sum();
            int blocksSoFar = BlockRatios[0];
            computedThresholds = new float[Blocks.Length];
            computedThresholds[0] = 0;
            for( int i = 1; i < Blocks.Length; i++ ) {
                float desiredCoverage = blocksSoFar / (float)totalBlocks;
                computedThresholds[i] = Noise.FindThreshold( rawData, desiredCoverage );
                blocksSoFar += BlockRatios[i];
            }
            return true;
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:41,代码来源:AbstractPerlinNoiseBrush.cs

示例6: MakeInstance

        public IBrushInstance MakeInstance( Player player, CommandReader cmd, DrawOperation op ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( cmd == null ) throw new ArgumentNullException( "cmd" );
            if( op == null ) throw new ArgumentNullException( "op" );

            if( cmd.HasNext ) {
                Block block, altBlock;
                if( !cmd.NextBlock( player, true, out block ) ) return null;
                if( cmd.HasNext ) {
                    if( !cmd.NextBlock( player, true, out altBlock ) ) return null;
                } else {
                    altBlock = Block.None;
                }
                Block1 = block;
                Block2 = altBlock;

            } else if( Block1 == Block.None ) {
                player.Message( "{0}: Please specify one or two blocks.", Factory.Name );
                return null;
            }

            return new CheckeredBrush( this );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:23,代码来源:CheckeredBrush.cs

示例7: RaiseEndedEvent

 protected static void RaiseEndedEvent( DrawOperation op ) {
     var h = Ended;
     if( h != null ) h( null, new DrawOperationEventArgs( op ) );
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:4,代码来源:DrawOperation.cs

示例8: RaiseBeganEvent

 protected static void RaiseBeganEvent( DrawOperation op ) {
     var h = Began;
     if( h != null ) h( null, new DrawOperationEventArgs( op ) );
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:4,代码来源:DrawOperation.cs

示例9: RaiseBeginningEvent

 // Returns false if cancelled
 protected static bool RaiseBeginningEvent( DrawOperation op ) {
     var h = Beginning;
     if( h == null ) return true;
     var e = new DrawOperationBeginningEventArgs( op );
     h( null, e );
     return !e.Cancel;
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:8,代码来源:DrawOperation.cs

示例10: MakeInstance

        public IBrushInstance MakeInstance( Player player, CommandReader cmd, DrawOperation state ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( cmd == null ) throw new ArgumentNullException( "cmd" );
            if( state == null ) throw new ArgumentNullException( "state" );

            List<Block> blocks = new List<Block>();
            List<int> blockRatios = new List<int>();
            while( cmd.HasNext ) {
                int ratio;
                Block block;
                if( !cmd.NextBlockWithParam( player, true, out block, out ratio ) ) return null;
                if( ratio < 1 || ratio > MaxRatio ) {
                    player.Message( "Cloudy brush: Invalid block ratio ({0}). Must be between 1 and {1}.",
                                    ratio, MaxRatio );
                    return null;
                }
                blocks.Add( block );
                blockRatios.Add( ratio );
            }

            if( blocks.Count == 0 ) {
                if( Blocks.Length == 0 ) {
                    player.Message( "{0} brush: Please specify at least one block.", Factory.Name );
                    return null;
                } else {
                    return new CloudyBrush( this );
                }
            } else if( blocks.Count == 1 ) {
                return new CloudyBrush( blocks[0], blockRatios[0] );
            } else {
                return new CloudyBrush( blocks.ToArray(), blockRatios.ToArray() );
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:33,代码来源:CloudyBrush.cs

示例11: Begin

 public bool Begin( Player player, DrawOperation op ) {
     if( player == null ) throw new ArgumentNullException( "player" );
     if( op == null ) throw new ArgumentNullException( "op" );
     op.Context |= BlockChangeContext.Replaced;
     return ReplacementInstance.Begin( player, op );
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:6,代码来源:ReplaceBrushBrush.cs

示例12:

 bool IBrushInstance.Begin( Player player, DrawOperation op )
 {
     return true;
 }
开发者ID:GlennMR,项目名称:800craft,代码行数:4,代码来源:DrawOpWithBrush.cs

示例13: Begin

 public bool Begin(Player player, DrawOperation op) {
     if (player == null)
         throw new ArgumentNullException("player");
     if (op == null)
         throw new ArgumentNullException("op");
     if (Blocks == null || Blocks.Length == 0) {
         throw new InvalidOperationException("No blocks given.");
     }
     if (Replacement == Block.None) {
         if (player.LastUsedBlockType == Block.None) {
             player.Message("Cannot deduce desired replacement block. Click a block or type out the block name.");
             return false;
         } else {
             Replacement = player.GetBind(player.LastUsedBlockType);
         }
     }
     op.Context |= BlockChangeContext.Replaced;
     return true;
 }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:19,代码来源:ReplaceBrush.cs

示例14: Begin

 public bool Begin( Player player, DrawOperation op ) {
     if( player == null ) throw new ArgumentNullException( "player" );
     if( op == null ) throw new ArgumentNullException( "op" );
     if( Blocks == null || Blocks.Length == 0 ) {
         throw new InvalidOperationException( "No blocks given." );
     }
     return true;
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:8,代码来源:RandomBrush.cs

示例15: NextBlock

 public Block NextBlock(DrawOperation state) {
     if (state == null) throw new ArgumentNullException("state");
     if (state.AlternateBlockIndex < Blocks.Length) {
         return Blocks[state.AlternateBlockIndex];
     } else {
         return Block.None;
     }
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:8,代码来源:NormalBrush.cs


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