本文整理汇总了C#中Block类的典型用法代码示例。如果您正苦于以下问题:C# Block类的具体用法?C# Block怎么用?C# Block使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Block类属于命名空间,在下文中一共展示了Block类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawSearchHighlight
private void DrawSearchHighlight(DrawingContext dc, Block block)
{
foreach (var pair in _curSearchMatches)
{
int txtOffset = 0;
double y = block.Y;
for (int i = 0; i < block.Text.Length; i++)
{
int start = Math.Max(txtOffset, pair.Item1);
int end = Math.Min(txtOffset + block.Text[i].Length, pair.Item2);
if (end > start)
{
double x1 = block.Text[i].GetDistanceFromCharacterHit(new CharacterHit(start, 0)) + block.TextX;
double x2 = block.Text[i].GetDistanceFromCharacterHit(new CharacterHit(end, 0)) + block.TextX;
dc.DrawRectangle(_searchBrush.Value, null,
new Rect(new Point(x1, y), new Point(x2, y + _lineHeight)));
}
y += _lineHeight;
txtOffset += block.Text[i].Length;
}
}
}
示例2: BlockUpdate
public BlockUpdate( Player origin, short x, short y, short z, Block blockType ) {
Origin = origin;
X = x;
Y = y;
Z = z;
BlockType = blockType;
}
示例3: recursiveBlockDivision
private void recursiveBlockDivision(Block block, ArrayList blocks, int loopsLeft) {
if (loopsLeft < 0) {
return;
}
float currentMagnitude = (block.c3 - block.c1).magnitude;
Block[] newBlocks = subDivideBlock (block);
bool subDivide;
if (Mathf.Max ((block.c2 - block.c1).magnitude, (block.c4 - block.c1).magnitude) > maximumBlockSize) { //block too large, subdivide
subDivide = true;
} else if (newBlocks [0].IsNull) { //block can be subdivided, keep it like this
subDivide = false;
blocks.Add (block);
} else {
if (currentMagnitude < minimumBlockSize * 6 && Random.value <= 0.2) {
subDivide = false;
} else if (Random.value <= 0.2) {
subDivide = false;
blocks.Add (block);
} else {
subDivide = true;
}
}
if (subDivide) {
recursiveBlockDivision (newBlocks [0], blocks, loopsLeft - 1);
recursiveBlockDivision (newBlocks [1], blocks, loopsLeft - 1);
}
}
示例4: GetFormattingObject
/// <summary>
/// Get formatting object for body element
/// </summary>
/// <param name="regionId"></param>
/// <param name="tick"></param>
/// <returns></returns>
public override FormattingObject GetFormattingObject(TimeCode tick)
{
Block block = null;
if (TemporallyActive(tick))
{
block = new Block(this);
foreach (var child in Children)
{
if (child is DivElement)
{
var fo = (child as DivElement).GetFormattingObject(tick);
if (fo != null)
{
fo.Parent = block;
block.Children.Add(fo);
}
}
if (child is SetElement)
{
var fo = ((child as SetElement).GetFormattingObject(tick)) as Animation;
if (fo != null)
{
// fo.Parent = block;
block.Animations.Add(fo);
}
}
}
}
return block;
}
示例5: IsSwitchType2
bool IsSwitchType2(Block switchBlock) {
Local local = null;
foreach (var instr in switchBlock.Instructions) {
if (!instr.IsLdloc())
continue;
local = Instr.GetLocalVar(blocks.Locals, instr);
break;
}
if (local == null)
return false;
foreach (var source in switchBlock.Sources) {
var instrs = source.Instructions;
for (int i = 1; i < instrs.Count; i++) {
var ldci4 = instrs[i - 1];
if (!ldci4.IsLdcI4())
continue;
var stloc = instrs[i];
if (!stloc.IsStloc())
continue;
if (Instr.GetLocalVar(blocks.Locals, stloc) != local)
continue;
return true;
}
}
return false;
}
示例6: PlaySoundPlayer
public static void PlaySoundPlayer(AudioClip clip, bool loop, Block player,
PlayerAudioType type)
{
if (clip == null)
return;
var audio = _instance.PlayerAudioSource;
if (!audio.enabled)
return;
if (player == Block.Player1)
_instance._player1 = type;
else if (player == Block.Player2)
_instance._player2 = type;
if (type == PlayerAudioType.Idle)
if (_instance._player1 == PlayerAudioType.Move ||
_instance._player2 == PlayerAudioType.Move)
return;
if (audio.clip == clip && audio.isPlaying)
return;
audio.loop = loop;
audio.clip = clip;
audio.Play();
}
示例7: Build
public void Build(Vector3 pos, int width, int height)
{
for (int i = -10; i < width + 10; i++)
{
for (int j = -10; j < height + 10; j++)
{
GameObject cell = Resources.Load("Cell", typeof(GameObject)) as GameObject;
float x = i * dx, y = j * dy;
if (j % 2 != 0) {
x += dx/2;
}
cell.transform.position = pos + new Vector3(x, y, 0);
GameObject cellClone = Instantiate(cell);
cellClone.GetComponent<CellPosition>().Set(i, j);
Entity e;
if (i < 0 || i >= width || j < 0 || j > height)
e = new Block(Block.BlockType.Water);
else
e = Entity.getRandom();
cellClone.GetComponent<CellContent>().SetEntity(e);
if (i == 0 && j == 0)
Camera.main.GetComponent<CameraMotion>().minpos = cellClone.transform.position;
if (i == width-1 && j == height-1)
Camera.main.GetComponent<CameraMotion>().maxpos = cellClone.transform.position;
}
}
}
示例8: FireworkParticle
public FireworkParticle(World world, Vector3I pos, Block block)
: base(world)
{
_startingPos = pos;
_nextZ = pos.Z - 1;
_block = block;
}
示例9: Deobfuscate
protected override bool Deobfuscate(Block block) {
bool modified = false;
var instructions = block.Instructions;
for (int i = 0; i < instructions.Count; i++) {
var instr = instructions[i];
switch (instr.OpCode.Code) {
// Xenocode generates stloc + ldloc (bool). Replace it with dup + stloc. It will eventually
// become dup + pop and be removed.
case Code.Stloc:
case Code.Stloc_S:
case Code.Stloc_0:
case Code.Stloc_1:
case Code.Stloc_2:
case Code.Stloc_3:
if (i + 1 >= instructions.Count)
break;
if (!instructions[i + 1].IsLdloc())
break;
var local = Instr.GetLocalVar(locals, instr);
if (local.Type.ElementType != ElementType.Boolean)
continue;
if (local != Instr.GetLocalVar(locals, instructions[i + 1]))
break;
instructions[i] = new Instr(OpCodes.Dup.ToInstruction());
instructions[i + 1] = instr;
modified = true;
break;
default:
break;
}
}
return modified;
}
示例10: Start
void Start()
{
filter = gameObject.GetComponent<MeshFilter>();
coll = gameObject.GetComponent<MeshCollider>();
//past here is just to set up an example chunk
blocks = new Block[chunkSize, chunkSize, chunkSize];
for (int x = 0; x < chunkSize; x++)
{
for (int y = 0; y < chunkSize; y++)
{
for (int z = 0; z < chunkSize; z++)
{
blocks[x, y, z] = new BlockAir();
}
}
}
blocks[1, 1, 1] = new Block();
blocks[1, 2, 1] = new Block();
blocks[1, 2, 2] = new Block();
blocks[2, 2, 2] = new Block();
UpdateChunk();
}
示例11: GenerateChunk
/// <summary>
/// Generate a chunk and return it. The terrain object remains unmodified.
/// </summary>
/// <param name="terrain">The terrain.</param>
/// <param name="chunkIndex">The chunk index.</param>
/// <returns>The chunk.</returns>
public Chunk GenerateChunk(Terrain terrain, Vector2I chunkIndex)
{
Chunk chunk = new Chunk();
// Calculate the position of the chunk in world coordinates
var chunkPos = new Vector2I(chunkIndex.X * Chunk.SizeX, chunkIndex.Y * Chunk.SizeY);
// Get the surface heights for this chunk
int[] surfaceHeights = this.GenerateSurfaceHeights(chunkPos);
// For now, fill the terrain with mud under the surface
for (int x = 0; x < Chunk.SizeX; x++)
{
int surfaceHeight = surfaceHeights[x];
if (surfaceHeight > 0)
{
for (int y = 0; y < surfaceHeight; y++)
{
chunk[x, y] = new Block(BlockType.Dirt);
}
}
}
return chunk;
}
示例12: BlockFloat
public BlockFloat(World world, Vector3I position, Block Type)
: base(world)
{
_pos = position;
_nextPos = position.Z + 1;
type = Type;
}
示例13: TwitterClient
public TwitterClient(IRestClient client, string consumerKey, string consumerSecret, string callback)
: base(client)
{
Encode = true;
Statuses = new Statuses(this);
Account = new Account(this);
DirectMessages = new DirectMessages(this);
Favourites = new Favourites(this);
Block = new Block(this);
Friendships = new Friendship(this);
Lists = new List(this);
Search = new Search(this);
Users = new Users(this);
FriendsAndFollowers = new FriendsAndFollowers(this);
OAuthBase = "https://api.twitter.com/oauth/";
TokenRequestUrl = "request_token";
TokenAuthUrl = "authorize";
TokenAccessUrl = "access_token";
Authority = "https://api.twitter.com/";
Version = "1";
#if !SILVERLIGHT
ServicePointManager.Expect100Continue = false;
#endif
Credentials = new OAuthCredentials
{
ConsumerKey = consumerKey,
ConsumerSecret = consumerSecret,
};
if (!string.IsNullOrEmpty(callback))
((OAuthCredentials)Credentials).CallbackUrl = callback;
}
示例14: subDivideBlock
private Block[] subDivideBlock(Block originBlock) {
bool xSpace = Mathf.Abs(originBlock.c3.x-originBlock.c1.x) > minimumBlockSize * 2.1;
bool ySpace = Mathf.Abs(originBlock.c3.y-originBlock.c1.y) > minimumBlockSize * 2.1;
float roadWidth = Random.Range(roadWidthMin, roadWidthMax);
if (!xSpace && !ySpace) {
Block b1 = new Block ();
Block b2 = new Block ();
Debug.Assert (b1.IsNull);
Debug.Assert (b2.IsNull);
return new Block[2]{new Block(), new Block()};
}
bool xSplit = (xSpace && Random.value < 0.5f) || !ySpace;
float splitPlace;
if (xSplit) {
splitPlace = Random.Range (originBlock.c1.x+minimumBlockSize, originBlock.c3.x-minimumBlockSize);
Block block1 = new Block (originBlock.c1, new Vector2(splitPlace-roadWidth/2, originBlock.c3.y));
Block block2 = new Block (new Vector2(splitPlace+roadWidth/2, originBlock.c1.y), originBlock.c3);
return new Block[2]{block1,block2};
} else {
splitPlace = Random.Range (originBlock.c1.y+minimumBlockSize, originBlock.c3.y-minimumBlockSize);
Block block1 = new Block (originBlock.c1, new Vector2(originBlock.c3.x, splitPlace-roadWidth/2));
Block block2 = new Block (new Vector2(originBlock.c1.x, splitPlace+roadWidth/2), originBlock.c3);
return new Block[2]{block1,block2};
}
}
示例15: Zombie
public Zombie(int x, int y)
: base(x, y)
{
updateTimer.Start();
lagTimer.Start();
zombieBlock = Block.CreateBlock(0, xBlock, yBlock, 32, 0);
}