本文整理汇总了C#中Microsoft.Xna.Framework.Rectangle.Size方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Size方法的具体用法?C# Rectangle.Size怎么用?C# Rectangle.Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Rectangle
的用法示例。
在下文中一共展示了Rectangle.Size方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TabContainer
/// <summary>
/// Initializes a new instance of the <see cref="TabContainer"/> class with default settings.
/// </summary>
/// <param name="device"> The <see cref="GraphicsDevice"/> to display the <see cref="TabContainer"/> to. </param>
/// <param name="font"> The <see cref="SpriteFont"/> to use while drawing the text. </param>
public TabContainer(GraphicsDevice device, SpriteFont font)
: base(device)
{
this.font = font;
tabs = new KeyValuePair<Label, GuiItemCollection>[0];
tabRect = DefaultTabSize;
tabtexture = Drawing.FromColor(Color.White, tabRect.Size(), device);
}
示例2: Colliding
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
float num3 = 0f;
if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 22f * projectile.scale, ref num3))
{
return true;
}
return false;
}
示例3: Colliding
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
if (projectile.ai[1] > -warningTime)
{
return false;
}
float num = 0f;
Vector2 end = projectile.Center + projectile.localAI[1] * new Vector2((float)Math.Cos(projectile.rotation), (float)Math.Sin(projectile.rotation));
return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, end, projectile.width, ref num);
}
示例4: Colliding
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
float point = 0f;
Vector2 endPoint = Main.npc[(int)projectile.ai[1]].Center;
return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, endPoint, 4f, ref point);
}
示例5: Refresh
/// <summary>
/// Recalculates the background and the foreground.
/// </summary>
public override void Refresh()
{
if (suppressRefresh) return;
if (AutoSize)
{
Vector2 dim = font.MeasureString(HeaderText);
int yAdder = 0;
for (int i = 0; i < labels.Length; i++)
{
string full = string.Join(" ", labels[i].Select(l => l.Key));
Vector2 newDim = font.MeasureString(full);
if (newDim.X > dim.X) dim.X = newDim.X;
yAdder += (int)newDim.Y;
}
dim.X += 3;
bool width = dim.X != Bounds.Width ? true : false;
bool height = dim.Y != Bounds.Height ? true : false;
if (width && height) Bounds = new Rectangle(Bounds.X, Bounds.Y, (int)dim.X, (int)dim.Y + yAdder);
else if (width) Bounds = new Rectangle(Bounds.X, Bounds.Y, (int)dim.X, Bounds.Height);
else if (height) Bounds = new Rectangle(Bounds.X, Bounds.Y, Bounds.Width, (int)dim.Y + yAdder);
}
foregroundRectangle = Bounds;
backColorImage = backColorImage.ApplyBorderLabel(BorderStyle);
if (BackgroundImage != null) BackgroundImage = BackgroundImage.ApplyBorderLabel(BorderStyle);
foregroundTexture = Drawing.FromText(HeaderText, font, ForeColor, foregroundRectangle.Size(), false, 0, device);
headerTexture = Drawing.FromColor(HeaderBackgroundColor, new Size(foregroundTexture.Width, (int)font.MeasureString("a").Y), device);
itemTextures = new KeyValuePair<Texture2D, ButtonStyle>[labels.Length];
for (int i = 0; i < labels.Length; i++)
{
itemTextures[i] = new KeyValuePair<Texture2D, ButtonStyle>(
Drawing.FromLabels(labels[i], font, new Size(foregroundTexture.Width, foregroundRectangle.Height / (labels.Length + 1)), device),
ButtonStyle.Default);
}
}
示例6: Refresh
/// <summary>
/// Recalculates the background and the foreground.
/// </summary>
public override void Refresh()
{
if (suppressRefresh) return;
if (AutoSize)
{
Vector2 dim = font.MeasureString(text);
dim.X += 3;
bool width = dim.X != Bounds.Width && dim.X != 0;
bool height = dim.Y != Bounds.Height && dim.Y != 0;
if (width && height) Bounds = new Rectangle(Bounds.X, Bounds.Y, (int)dim.X, (int)dim.Y);
else if (width) Bounds = new Rectangle(Bounds.X, Bounds.Y, (int)dim.X, Bounds.Height);
else if (height) Bounds = new Rectangle(Bounds.X, Bounds.Y, Bounds.Width, (int)dim.Y);
}
foregroundRectangle = Bounds;
backColorImage = Drawing.FromColor(BackColor, Bounds.Size(), device).ApplyBorderLabel(BorderStyle);
if (BackgroundImage != null) BackgroundImage = BackgroundImage.ApplyBorderLabel(BorderStyle);
foregroundTexture = Drawing.FromText(text, font, ForeColor, foregroundRectangle.Size(), true, LineStart, device);
}
示例7: LightningLaserDraw
public static void LightningLaserDraw(int stage, Vector2 currentPosition, float distanceLeft, Rectangle lastFrame, out float distCovered, out Rectangle frame, out Vector2 origin, out Color color)
{
color = DelegateMethods.c_1 * DelegateMethods.f_1;
if (stage == 0)
{
distCovered = 0f;
frame = new Rectangle(0, 0, 21, 8);
origin = frame.Size() / 2f;
return;
}
if (stage == 1)
{
frame = new Rectangle(0, 8, 21, 6);
distCovered = (float)frame.Height;
origin = new Vector2((float)(frame.Width / 2), 0f);
return;
}
if (stage == 2)
{
distCovered = 8f;
frame = new Rectangle(0, 14, 21, 8);
origin = new Vector2((float)(frame.Width / 2), 2f);
return;
}
distCovered = 9999f;
frame = Rectangle.Empty;
origin = Vector2.Zero;
color = Color.Transparent;
}
示例8: TurretLaserDraw
public static void TurretLaserDraw(int stage, Vector2 currentPosition, float distanceLeft, Rectangle lastFrame, out float distCovered, out Rectangle frame, out Vector2 origin, out Color color)
{
color = DelegateMethods.c_1;
if (stage == 0)
{
distCovered = 32f;
frame = new Rectangle(0, 0, 22, 20);
origin = frame.Size() / 2f;
return;
}
if (stage == 1)
{
DelegateMethods.i_1++;
int num = DelegateMethods.i_1 % 5;
frame = new Rectangle(0, 22 * (num + 1), 22, 20);
distCovered = (float)(frame.Height - 1);
origin = new Vector2((float)(frame.Width / 2), 0f);
return;
}
if (stage == 2)
{
frame = new Rectangle(0, 154, 22, 30);
distCovered = (float)frame.Height;
origin = new Vector2((float)(frame.Width / 2), 1f);
return;
}
distCovered = 9999f;
frame = Rectangle.Empty;
origin = Vector2.Zero;
color = Color.Transparent;
}
示例9: Colliding
public bool Colliding(Rectangle myRect, Rectangle targetRect)
{
if (this.type == 598 && targetRect.Width > 8 && targetRect.Height > 8)
{
targetRect.Inflate(-targetRect.Width / 8, -targetRect.Height / 8);
}
else if (this.type == 614 && targetRect.Width > 8 && targetRect.Height > 8)
{
targetRect.Inflate(-targetRect.Width / 8, -targetRect.Height / 8);
}
else if (this.type == 636 && targetRect.Width > 8 && targetRect.Height > 8)
{
targetRect.Inflate(-targetRect.Width / 8, -targetRect.Height / 8);
}
else if (this.type == 607)
{
myRect.X += (int)this.velocity.X;
myRect.Y += (int)this.velocity.Y;
}
if (myRect.Intersects(targetRect))
{
return true;
}
if (this.type == 461)
{
float num = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 22f * this.scale, ref num))
{
return true;
}
}
else if (this.type == 642)
{
float num2 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 30f * this.scale, ref num2))
{
return true;
}
}
else if (this.type == 632)
{
float num3 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 22f * this.scale, ref num3))
{
return true;
}
}
else if (this.type == 455)
{
float num4 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 36f * this.scale, ref num4))
{
return true;
}
}
else if (this.type == 611)
{
float num5 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity, 16f * this.scale, ref num5))
{
return true;
}
}
else if (this.type == 537)
{
float num6 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 22f * this.scale, ref num6))
{
return true;
}
}
else if (this.type == 466 || this.type == 580)
{
for (int i = 0; i < this.oldPos.Length; i++)
{
myRect.X = (int)this.oldPos[i].X;
myRect.Y = (int)this.oldPos[i].Y;
if (myRect.Intersects(targetRect))
{
return true;
}
}
}
else if (this.type == 464 && this.ai[1] != 1f)
{
Vector2 value = new Vector2(0f, -720f).RotatedBy((double)this.velocity.ToRotation(), default(Vector2));
float scaleFactor = this.ai[0] % 45f / 45f;
Vector2 spinningpoint = value * scaleFactor;
for (int j = 0; j < 6; j++)
{
float num7 = (float)j * 6.28318548f / 6f;
Vector2 center = base.Center + spinningpoint.RotatedBy((double)num7, default(Vector2));
if (Utils.CenteredRectangle(center, new Vector2(30f, 30f)).Intersects(targetRect))
{
return true;
}
}
}
return false;
}