本文整理汇总了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;
}
}
示例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
}
示例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
}
示例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." );
}