本文整理汇总了C#中Rectangle.Size方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Size方法的具体用法?C# Rectangle.Size怎么用?C# Rectangle.Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle.Size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Colliding
public bool Colliding(Rectangle myRect, Rectangle targetRect)
{
if (this.type == ProjectileID.BoneJavelin && targetRect.Width > 8 && targetRect.Height > 8)
{
targetRect.Inflate(-targetRect.Width / 8, -targetRect.Height / 8);
}
else if (this.type == ProjectileID.StardustCellMinionShot && targetRect.Width > 8 && targetRect.Height > 8)
{
targetRect.Inflate(-targetRect.Width / 8, -targetRect.Height / 8);
}
else if (this.type == ProjectileID.Daybreak && targetRect.Width > 8 && targetRect.Height > 8)
{
targetRect.Inflate(-targetRect.Width / 8, -targetRect.Height / 8);
}
else if (this.type == ProjectileID.SolarFlareRay)
{
myRect.X += (int)this.velocity.X;
myRect.Y += (int)this.velocity.Y;
}
if (myRect.Intersects(targetRect))
{
return true;
}
if (this.type == ProjectileID.ChargedBlasterLaser)
{
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 == ProjectileID.MoonlordTurretLaser)
{
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 == ProjectileID.LastPrismLaser)
{
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 == ProjectileID.PhantasmalDeathray)
{
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 == ProjectileID.SolarWhipSword)
{
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 == ProjectileID.StardustSoldierLaser)
{
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 == ProjectileID.CultistBossLightningOrbArc || this.type == ProjectileID.VortexLightning)
{
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 == ProjectileID.CultistBossIceMist && this.ai[1] != 1f)
{
Vector2 vector = new Vector2(0f, -720f).RotatedBy((double)this.velocity.ToRotation(), default(Vector2));
float num7 = this.ai[0] % 45f / 45f;
Vector2 spinningpoint = vector * num7;
for (int j = 0; j < 6; j++)
{
float num8 = (float)j * 6.28318548f / 6f;
Vector2 center = base.Center + spinningpoint.RotatedBy((double)num8, default(Vector2));
if (Utils.CenteredRectangle(center, new Vector2(30f, 30f)).Intersects(targetRect))
{
return true;
}
}
}
return false;
}
示例2: AnyoneNearCultists
public static bool AnyoneNearCultists()
{
int num = NPC.FindFirstNPC(437);
if (num == -1)
{
return false;
}
Rectangle rectangle = Utils.CenteredRectangle(Main.npc[num].Center, new Vector2(2500f, 1500f));
Rectangle r = new Rectangle(0, 0, 2500, 1500);
Vector2 vector = r.Size() / 2f;
for (int i = 0; i < 255; i++)
{
if (Main.player[i].active)
{
r.X = (int)Main.player[i].Center.X - (int)vector.X;
r.Y = (int)Main.player[i].Center.Y - (int)vector.Y;
if (rectangle.Intersects(r))
{
return true;
}
}
}
return false;
}
示例3: 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 vector = new Vector2(0f, -720f).RotatedBy((double)this.velocity.ToRotation(), default(Vector2));
float num7 = this.ai[0] % 45f / 45f;
Vector2 spinningpoint = vector * num7;
for (int j = 0; j < 6; j++)
{
float num8 = (float)j * 6.28318548f / 6f;
Vector2 center = base.Center + spinningpoint.RotatedBy((double)num8, default(Vector2));
if (Utils.CenteredRectangle(center, new Vector2(30f, 30f)).Intersects(targetRect))
{
return true;
}
}
}
return false;
}