本文整理汇总了C#中Player.Message方法的典型用法代码示例。如果您正苦于以下问题:C# Player.Message方法的具体用法?C# Player.Message怎么用?C# Player.Message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player.Message方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeBrush
public IBrush MakeBrush( Player player, CommandReader cmd ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( cmd == null ) throw new ArgumentNullException( "cmd" );
if( !cmd.HasNext ) {
player.Message( "ReplaceBrush usage: &H/Brush rb <Block> <BrushName>" );
return null;
}
Block block;
if( !cmd.NextBlock( player, false, out block ) ) return null;
string brushName = cmd.Next();
if( brushName == null || !CommandManager.IsValidCommandName( brushName ) ) {
player.Message( "ReplaceBrush usage: &H/Brush rb <Block> <BrushName>" );
return null;
}
IBrushFactory brushFactory = BrushManager.GetBrushFactory( brushName );
if( brushFactory == null ) {
player.Message( "Unrecognized brush \"{0}\"", brushName );
return null;
}
IBrush newBrush = brushFactory.MakeBrush( player, cmd );
if( newBrush == null ) {
return null;
}
return new ReplaceBrushBrush( block, newBrush );
}
示例2: MakeBrush
public IBrush MakeBrush(Player player, CommandReader cmd) {
if (player == null) throw new ArgumentNullException("player");
if (cmd == null) throw new ArgumentNullException("cmd");
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 > RandomBrush.MaxRatio) {
player.Message("RandomBrush: Invalid block ratio ({0}). Must be between 1 and {1}.",
ratio,
RandomBrush.MaxRatio);
return null;
}
blocks.Add(block);
blockRatios.Add(ratio);
}
switch (blocks.Count) {
case 0:
player.Message("{0} brush: Please specify at least one block.", Name);
return null;
case 1:
return new RandomBrush(blocks[0], blockRatios[0]);
default:
return new RandomBrush(blocks.ToArray(), blockRatios.ToArray());
}
}
示例3: MakeBrush
public IBrush MakeBrush(Player player, CommandReader cmd) {
if (player == null) throw new ArgumentNullException("player");
if (cmd == null) throw new ArgumentNullException("cmd");
// read the block filter list
HashSet<Block> blocks = new HashSet<Block>();
while (cmd.HasNext) {
Block block;
if (!cmd.NextBlock(player, false, out block)) {
return null;
}
if (!blocks.Add(block)) {
// just a warning -- don't abort
player.Message("{0}: {1} was specified twice!", Name, block);
}
}
// create a brush
if (blocks.Count > 0) {
return new PasteBrush(blocks.ToArray(), Not);
} else if (Not) {
player.Message("PasteNot brush requires at least 1 block.");
return null;
} else {
return new PasteBrush();
}
}
示例4: MakeBrush
public IBrush MakeBrush(Player player, CommandReader cmd) {
if (player == null)
throw new ArgumentNullException("player");
if (cmd == null)
throw new ArgumentNullException("cmd");
Stack<Block> blocks = new Stack<Block>();
while (cmd.HasNext) {
Block block;
if (!cmd.NextBlock(player, false, out block))
return null;
blocks.Push(block);
}
switch (blocks.Count) {
case 0:
player.Message("{0} brush: Please specify the replacement block type.", Name);
return null;
case 1:
return new ReplaceNotBrush(blocks.ToArray(), Block.None);
default: {
Block replacement = blocks.Pop();
return new ReplaceNotBrush(blocks.ToArray(), replacement);
}
}
}
示例5: MakeBrush
public IBrush MakeBrush( Player player, CommandReader cmd ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( cmd == null ) throw new ArgumentNullException( "cmd" );
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( block == Block.None ) return null;
if( ratio < 0 || ratio > 1000 ) {
player.Message( "{0} brush: Invalid block ratio ({1}). Must be between 1 and 1000.",
Name, ratio );
return null;
}
blocks.Add( block );
blockRatios.Add( ratio );
}
switch( blocks.Count ) {
case 0:
return new MarbledBrush();
case 1:
return new MarbledBrush( blocks[0], blockRatios[0] );
default:
return new MarbledBrush( blocks.ToArray(), blockRatios.ToArray() );
}
}
示例6: MakeBrush
public IBrush MakeBrush( Player player, CommandReader cmd ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( cmd == null ) throw new ArgumentNullException( "cmd" );
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 > RandomBrush.MaxRatio ) {
player.Message( "Random brush: Invalid block ratio ({0}). Must be between 1 and {1}.",
ratio, RandomBrush.MaxRatio );
return null;
}
blocks.Add( block );
blockRatios.Add( ratio );
}
if( blocks.Count == 0 ) {
return new RandomBrush();
} else if( blocks.Count == 1 ) {
return new RandomBrush( blocks[0], blockRatios[0] );
} else {
return new RandomBrush( blocks.ToArray(), blockRatios.ToArray() );
}
}
示例7: BrushHandler
static void BrushHandler( Player player, Command cmd ) {
string brushName = cmd.Next();
if( brushName == null ) {
player.Message( player.Brush.Description );
} else {
IBrushFactory brushFactory = GetBrushFactory( brushName );
if( brushFactory == null ) {
player.Message( "Unrecognized brush \"{0}\"", brushName );
} else {
IBrush newBrush = brushFactory.MakeBrush( player, cmd );
if( newBrush != null ) {
player.Brush = newBrush;
player.Message( "Brush set to {0}", player.Brush.Description );
}
}
}
}
示例8: CreateParameters
public override MapGeneratorParameters CreateParameters( Player player, CommandReader cmd ) {
string themeName = cmd.Next();
if( themeName == null ) {
return CreateDefaultParameters();
}
MapGenTheme theme;
RealisticMapGenTerrainType terrainType;
string templateName = cmd.Next();
if( templateName == null ) {
player.Message( "SetGen: Realistic MapGen requires both a theme and a terrainType. " +
"See &H/Help SetGen Realistic&S or check wiki.fCraft.net for details" );
return null;
}
// parse theme
bool swapThemeAndTemplate;
if( EnumUtil.TryParse( themeName, out theme, true ) ) {
swapThemeAndTemplate = false;
} else if( EnumUtil.TryParse( templateName, out theme, true ) ) {
swapThemeAndTemplate = true;
} else {
player.Message( "SetGen: Unrecognized theme \"{0}\". Available themes are: {1}",
themeName,
Enum.GetNames( typeof( MapGenTheme ) ).JoinToString() );
return null;
}
// parse terrainType
if( swapThemeAndTemplate && !EnumUtil.TryParse( themeName, out terrainType, true ) ) {
MessageTemplateList( themeName, player );
return null;
} else if( !EnumUtil.TryParse( templateName, out terrainType, true ) ) {
MessageTemplateList( templateName, player );
return null;
}
// TODO: optional parameters for preset customization
return CreateParameters( terrainType, theme );
}
示例9: CreateParameters
public override MapGeneratorParameters CreateParameters( Player player, CommandReader cmd ) {
string themeName = cmd.Next();
MapGeneratorParameters newParams;
if( themeName != null ) {
newParams = CreateParameters( themeName );
if( newParams == null ) {
player.Message( "SetGen: \"{0}\" is not a recognized flat theme name. Available themes are: {1}",
themeName, Presets.JoinToString() );
return null;
}
} else {
newParams = CreateDefaultParameters();
}
return newParams;
}
示例10: 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;
}
示例11: MakeBrush
public IBrush MakeBrush(Player player, CommandReader cmd) {
if (player == null) throw new ArgumentNullException("player");
if (cmd == null) throw new ArgumentNullException("cmd");
Block block, altBlock;
// first block type is required
if (!cmd.NextBlock(player, true, out block)) {
player.Message("{0}: Please specify at least one block type.", Name);
return null;
}
// second block type is optional
if (cmd.HasNext) {
if (!cmd.NextBlock(player, true, out altBlock)) return null;
} else {
altBlock = Block.None;
}
return new CheckeredBrush(block, altBlock);
}
示例12: 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() );
}
}
示例13: 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" );
Stack<Block> blocks = new Stack<Block>();
while( cmd.HasNext ) {
Block block;
if( !cmd.NextBlock( player, false, out block ) ) return null;
blocks.Push( block );
}
if( blocks.Count == 0 && Blocks == null ) {
player.Message( "ReplaceNot brush requires at least 1 block." );
return null;
}
if( blocks.Count > 0 ) {
if( blocks.Count > 1 ) Replacement = blocks.Pop();
Blocks = blocks.ToArray();
}
return new ReplaceNotBrush( this );
}
示例14: MakeBrush
public IBrush MakeBrush( Player player, CommandReader cmd ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( cmd == null ) throw new ArgumentNullException( "cmd" );
List<Block> blocks = new List<Block>();
List<int> blockRatios = new List<int>();
bool scaleSpecified = false,
turbulenceSpecified = false,
seedSpecified = false;
int scale = 100,
turbulence = 100;
UInt16 seed = CloudyBrush.NextSeed();
while( true ) {
int offset = cmd.Offset;
string rawNextParam = cmd.Next();
if( rawNextParam == null ) break;
if( rawNextParam.EndsWith( "%" ) ) {
string numPart = rawNextParam.Substring( 0, rawNextParam.Length - 1 );
int tempScale;
if( !Int32.TryParse( numPart, out tempScale ) ) {
player.Message( "Cloudy brush: To specify scale, write a number followed by a percentage (e.g. 100%)." );
return null;
}
if( scaleSpecified ) {
player.Message( "Cloudy brush: Scale has been specified twice." );
return null;
}
if( scale < 1 || tempScale > CloudyBrush.MaxScale ) {
player.Message( "Cloudy brush: Invalid scale ({0}). Must be between 1 and {1}",
scale, CloudyBrush.MaxScale );
return null;
}
scale = tempScale;
scaleSpecified = true;
continue;
} else if( rawNextParam.EndsWith( "T", StringComparison.OrdinalIgnoreCase ) ) {
string numPart = rawNextParam.Substring( 0, rawNextParam.Length - 1 );
int tempTurbulence;
if( Int32.TryParse( numPart, out tempTurbulence ) ) {
if( turbulenceSpecified ) {
player.Message( "Cloudy brush: Turbulence has been specified twice." );
return null;
}
if( turbulence < 1 || tempTurbulence > CloudyBrush.MaxScale ) {
player.Message( "Cloudy brush: Invalid turbulence ({0}). Must be between 1 and {1}",
turbulence, CloudyBrush.MaxScale );
return null;
}
turbulence = tempTurbulence;
turbulenceSpecified = true;
continue;
}
} else if( rawNextParam.EndsWith( "S", StringComparison.OrdinalIgnoreCase ) ) {
string numPart = rawNextParam.Substring( 0, rawNextParam.Length - 1 );
try {
seed = UInt16.Parse( numPart, System.Globalization.NumberStyles.HexNumber );
if( seedSpecified ) {
player.Message( "Cloudy brush: Seed has been specified twice." );
return null;
}
seedSpecified = true;
continue;
} catch {
seed = CloudyBrush.NextSeed();
}
}
cmd.Offset = offset;
int ratio;
Block block;
if( !cmd.NextBlockWithParam( player, true, out block, out ratio ) ) return null;
if( ratio < 1 || ratio > CloudyBrush.MaxRatio ) {
player.Message( "Cloudy brush: Invalid block ratio ({0}). Must be between 1 and {1}.",
ratio, CloudyBrush.MaxRatio );
return null;
}
blocks.Add( block );
blockRatios.Add( ratio );
}
CloudyBrush madeBrush;
if( blocks.Count == 0 ) {
madeBrush = new CloudyBrush();
} else if( blocks.Count == 1 ) {
madeBrush = new CloudyBrush( blocks[0], blockRatios[0] );
} else {
madeBrush = new CloudyBrush( blocks.ToArray(), blockRatios.ToArray() );
}
madeBrush.Frequency /= ( scale / 100f );
madeBrush.Persistence *= ( turbulence / 100f );
madeBrush.Seed = seed;
return madeBrush;
}
示例15: CreateParameters
public override MapGeneratorParameters CreateParameters( Player player, CommandReader cmd ) {
if( cmd.HasNext ) {
player.Message( "Vanilla map generator does not take any parameters; using defaults." );
}
return new VanillaMapGenParameters();
}