本文整理汇总了C#中Block.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Block.ToString方法的具体用法?C# Block.ToString怎么用?C# Block.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block
的用法示例。
在下文中一共展示了Block.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RotateAntiClockwise
public void RotateAntiClockwise()
{
var resolver = new TestResolver();
var block = new Block(resolver.Resolve<BlocksContent>(),
new FixedRandom(new[] { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.9f }), new Point(8, 1));
Assert.AreEqual("O.../OOO./..../....", block.ToString());
block.RotateAntiClockwise();
Assert.AreEqual(".O../.O../OO../....", block.ToString());
}
示例2: CheckIBlockAppearsATenthOfTheTime
public void CheckIBlockAppearsATenthOfTheTime()
{
int count = 0;
for (int i = 0; i < 1000; i++)
{
var block = new Block(displayMode, content, Vector2D.Zero);
if (block.ToString() == "OOOO/..../..../...." || block.ToString() == "O.../O.../O.../O...")
count++;
}
Assert.AreEqual(100, count, 50);
}
示例3: CheckIBlockAppearsATenthOfTheTime
public void CheckIBlockAppearsATenthOfTheTime(Type resolver)
{
Start(resolver, (BlocksContent content) =>
{
int count = 0;
var random = new PseudoRandom();
for (int i = 0; i < 10000; i++)
{
var block = new Block(content, random, Point.Zero);
if (block.ToString() == "OOOO/..../..../...." || block.ToString() == "O.../O.../O.../O...")
count++;
}
Assert.AreEqual(1000, count, 70);
});
}
示例4: It_has_a_useful_ToString_method
public void It_has_a_useful_ToString_method()
{
var a = new Block("a");
Assert.AreEqual("Block(\"a\")", a.ToString());
}
示例5: WriteCallback
static void WriteCallback( Player player, Vector3I[] marks, object tag )
{
Block block = new Block();
string sentence = ( string )tag;
//block bugfix kinda
if ( player.LastUsedBlockType == Block.Undefined ) {
block = Block.Stone;
} else {
block = player.LastUsedBlockType;
}
Direction direction = DirectionFinder.GetDirection( marks );
try {
FontHandler render = new FontHandler( block, marks, player, direction ); //create new instance
render.CreateGraphicsAndDraw( sentence ); //render the sentence
if ( render.blockCount > 0 ) {
player.Message( "/Write (Size {0}, {1}: Writing '{2}' using {3} blocks of {4}",
player.font.Size,
player.font.FontFamily.Name,
sentence, render.blockCount,
block.ToString() );
} else {
player.Message( "&WNo direction was set" );
}
render = null; //get lost
} catch ( Exception e ) {
player.Message( e.Message );
Logger.Log( LogType.Error, "WriteCommand: " + e );
}
}
示例6: Draw2DCallback
static void Draw2DCallback( Player player, Vector3I[] marks, object tag )
{
Block block = new Block();
Draw2DData data = ( Draw2DData )tag;
int radius = data.Radius;
int Points = data.Points;
bool fill = data.Fill;
string Shape = data.Shape;
if ( player.LastUsedBlockType == Block.Undefined ) {
block = Block.Stone;
} else {
block = player.LastUsedBlockType;
}
Direction direction = DirectionFinder.GetDirection( marks );
try {
ShapesLib lib = new ShapesLib( block, marks, player, radius, direction );
switch ( Shape.ToLower() ) {
case "polygon":
lib.DrawRegularPolygon( Points, 18, fill );
break;
case "star":
lib.DrawStar( Points, radius, fill );
break;
case "spiral":
lib.DrawSpiral();
break;
default:
player.Message( "&WUnknown shape" );
CdDraw2D.PrintUsage( player );
lib = null;
return;
}
if ( lib.blockCount > 0 ) {
player.Message( "/Draw2D: Drawing {0} with a size of '{1}' using {2} blocks of {3}",
Shape,
radius,
lib.blockCount,
block.ToString() );
} else {
player.Message( "&WNo direction was set" );
}
lib = null; //get lost
} catch ( Exception e ) {
player.Message( e.Message );
}
}
示例7: ParseStatement
//.........这里部分代码省略.........
}
case JSToken.ConditionalCompilationEnd:
{
ConditionalCompilationEnd endStatement = new ConditionalCompilationEnd(m_currentToken.Clone(), this);
GetNextToken();
return endStatement;
}
case JSToken.AspNetBlock:
return ParseAspNetBlock(consumeSemicolonIfPossible: true);
default:
m_noSkipTokenSet.Add(NoSkipTokenSet.s_EndOfStatementNoSkipTokenSet);
bool exprError = false;
try
{
bool bAssign;
// if this statement starts with a function within parens, we want to know now
bool parenFunction = (m_currentToken.Token == JSToken.LeftParenthesis && m_scanner.PeekToken() == JSToken.Function);
statement = ParseUnaryExpression(out bAssign, false);
if (statement != null && parenFunction)
{
FunctionObject functionObject = statement.LeftHandSide as FunctionObject;
if (functionObject != null)
{
functionObject.LeftHandFunctionExpression = true;
}
}
// look for labels
if (statement is Lookup && JSToken.Colon == m_currentToken.Token)
{
// can be a label
id = statement.ToString();
if (m_labelTable.ContainsKey(id))
{
// there is already a label with that name. Ignore the current label
ReportError(JSError.BadLabel, statement.Context.Clone(), true);
id = null;
GetNextToken(); // skip over ':'
return new Block(CurrentPositionContext(), this);
}
else
{
GetNextToken();
int labelNestCount = m_labelTable.Count + 1;
m_labelTable.Add(id, new LabelInfo(m_blockType.Count, labelNestCount));
if (JSToken.EndOfFile != m_currentToken.Token)
{
statement = new LabeledStatement(
statement.Context.Clone(),
this,
id,
labelNestCount,
ParseStatement(fSourceElement)
);
}
else
{
// end of the file!
//just pass null for the labeled statement
statement = new LabeledStatement(
statement.Context.Clone(),
this,
id,
labelNestCount,
示例8: ValidateDefinition
protected void ValidateDefinition(string expStr, int expVariations, int expChildCount, Block org)
{
var tp = org.GetType().Name;
var name = tp.Substring(5, 1);
var rot = tp.Substring(6);
Block.RotationType rotation = Block.RotationType.None;
if (!String.IsNullOrEmpty(rot) && !Enum.TryParse<Block.RotationType>(rot, out rotation))
{
Assert.Fail("Type '{0}', name does not fit into contract.", tp);
}
Assert.AreEqual(name, org.Name, "Name");
Assert.AreEqual(rotation, org.Rotation, "Rotation");
Assert.AreEqual(expStr, org.ToString(), "ToString().");
Assert.AreEqual(4, org.Count, "Count should be 4.");
Assert.AreEqual(expVariations, org.Variations.Length, "Variations.Length");
Assert.AreEqual(expChildCount, org.ChildCount, "ChildCount");
}
示例9: PlaceRandomBlock
/// <summary>
/// Places a random block on the map
/// </summary>
/// <param name="block">Blocktype to place</param>
/// <param name="map">Map to place block in</param>
/// <returns>Updated map</returns>
public void PlaceRandomBlock(Block block, Map map)
{
var randX = _rand.Next(1, map.MapWidth);
var randY = _rand.Next(1, map.MapHeight);
while (IsWall(randX, randY, map))
{
randX = _rand.Next(1, map.MapWidth);
randY = _rand.Next(1, map.MapHeight);
}
map.MapBlocks[randX, randY] = block;
Palettes palette;
Enum.TryParse(block.ToString(), out palette);
map.ActionBlocks.Add(new BlockTile
{
Block = block,
Coordinate = new Coordinate { X = randX, Y = randY },
Palette = palette
});
}
示例10: getBlockName
/// <summary> Get the name of the block, used when blockdefinition blocks should show their Name instead of ID .</summary>
public static string getBlockName(Block block) {
Block outBlock;
if (GetBlockByName(block.ToString(), false, out outBlock)) {
if (outBlock > MaxCustomBlockType) {
return BlockDefinition.GlobalDefinitions[(int)outBlock].Name;
}
return outBlock.ToString();
} else {
return Block.None.ToString();
}
}
示例11: SetBlockOnTheRoad
public void SetBlockOnTheRoad(Block area)
{
Debug.Log(area.ToString() + "通路に設定");
NextToAreaList.Add(area);
area.NextToAreaList.Add(this);
area.SetBlockType(BlockType.Road);
area.ConnectRoomList.AddRange(ConnectRoomList);
area.PreRoom = this;
}
示例12: SetBlockNextToRoom
public void SetBlockNextToRoom(Block block)
{
Debug.Log("今の部屋:" + this.ToString());
Debug.Log("隣の部屋:" + block.ToString());
NextToAreaList.Add(block);
block.NextToAreaList.Add(this);
copyconnRoomList(block);
block.copyconnRoomList(this);
}
示例13: SetCell
public void SetCell(int x, int y, Block type)
{
if (type == Block.Player1 || type == Block.Player2 || type == Block.Base)
{
var block = FindBlock(type);
if (block != null)
{
Destroy(_blocks[block.X, block.Y].gameObject);
_blocks[block.X, block.Y] = null;
}
}
if (_blocks[x, y] != null)
{
Destroy(_blocks[x, y].gameObject);
_blocks[x, y] = null;
}
var prefab = type.GetPrefab();
if (prefab == null)
return;
var item = Instantiate(prefab);
item.name = type.ToString();
item.transform.SetParent(transform);
var pos = prefab.transform.position;
pos.x = x;
pos.y = y;
item.transform.position = pos;
if (item is ISpawn)
(item as ISpawn).SpawnPoint = pos;
item.EditorMode = EditorMode;
item.X = x;
item.Y = y;
_blocks[x, y] = item;
}
示例14: ParsePageSelector
private bool ParsePageSelector(Block token)
{
if (token.GrammarSegment == GrammarSegment.Colon || token.GrammarSegment == GrammarSegment.Whitespace)
{
return true;
}
if (token.GrammarSegment == GrammarSegment.Ident)
{
CastRuleSet<PageRule>().Selector = new SimpleSelector(token.ToString());
return true;
}
if (token.GrammarSegment == GrammarSegment.CurlyBraceOpen)
{
SetParsingContext(ParsingContext.InDeclaration);
return true;
}
return false;
}
示例15: ParseKeyframeText
private bool ParseKeyframeText(Block token)
{
if (token.GrammarSegment == GrammarSegment.CurlyBraceOpen)
{
_frame = null;
SetParsingContext(ParsingContext.InDeclaration);
return true;
}
if (token.GrammarSegment == GrammarSegment.CurlyBracketClose)
{
ParseKeyframesData(token);
return false;
}
if (token.GrammarSegment == GrammarSegment.Comma)
{
return true;
}
if (_frame == null)
{
_frame = new KeyframeRule();
_frame.AddValue(token.ToString());
CastRuleSet<KeyframesRule>().Declarations.Add(_frame);
_activeRuleSets.Push(_frame);
}
else
{
_frame.AddValue(token.ToString());
}
return true;
}