當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。