当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.TopLeft方法代码示例

本文整理汇总了C#中Rectangle.TopLeft方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.TopLeft方法的具体用法?C# Rectangle.TopLeft怎么用?C# Rectangle.TopLeft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rectangle的用法示例。


在下文中一共展示了Rectangle.TopLeft方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:hastinbe,项目名称:TerrariaAPI-Server,代码行数:100,代码来源:Projectile.cs

示例2: 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;
 }
开发者ID:sylar605,项目名称:TshockCN,代码行数:100,代码来源:Projectile.cs


注:本文中的Rectangle.TopLeft方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。