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


C# Rectangle.TopLeft方法代码示例

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


在下文中一共展示了Rectangle.TopLeft方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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;
 }
开发者ID:Eldrazi,项目名称:Gyrolite,代码行数:9,代码来源:UnscratchedWispBeam_Friendly.cs

示例2: 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);
 }
开发者ID:bluemagic123,项目名称:tModLoader,代码行数:10,代码来源:NullLaser.cs

示例3: DrawTrace

        internal static void DrawTrace(SpriteBatch sb, IEnumerable<TraceLine> lines)
        {
            //TODO: clean this up, in some way or another
            if (lines.IsEmpty())
                return;

            sb.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.LinearClamp, null, null);

            OuterWindow = new Rectangle(PrismDebug.PADDING_X, Main.screenHeight * 2 / 3 + PrismDebug.PADDING_Y, Main.screenWidth - PrismDebug.PADDING_X * 2, Main.screenHeight / 3 - 2 * PrismDebug.PADDING_Y);

            sb.Draw(TMain.WhitePixel, OuterWindow, TraceWindowBg);

            sb.DrawString(Main.fontMouseText, "Prism Debug Tracer", OuterWindow.TopLeft() + new Vector2(2, 16), TraceText, 0f, new Vector2(0, Main.fontItemStack.LineSpacing / 2f), Vector2.One, SpriteEffects.None, 0f);

            sb.End();

            Viewport screen = sb.GraphicsDevice.Viewport;

            try
            {
                sb.GraphicsDevice.Viewport = new Viewport(InnerWindow);
            }
            catch
            {
                sb.GraphicsDevice.Viewport = screen;
            }

            sb.Begin();

            float curY = 0;
            bool altBg = false;

            var lineAmt = lines.Count();
            var drawText   = new List<string>(lineAmt);
            var fadeAlphas = new List<float >(lineAmt);

            var curLine = new StringBuilder();

            foreach (var l in lines.Take(lineAmt))
            {
                float curW = 0f;
                string[] words = l.Text.Split(SpaceArray);

                for (int i = 0; i < words.Length; i++)
                {
                    string append = (i > 0 ? Space : String.Empty) + words[i];
                    curW += Main.fontItemStack.MeasureString(append).X;

                    if (curW >= InnerWindow.Width)
                    {
                        curLine.AppendLine();
                        append = append.TrimStart();
                        curW = Main.fontItemStack.MeasureString(append).X;
                    }
                    curLine.Append(append);
                }

                fadeAlphas.Add(MathHelper.Clamp(l.Timeleft / 30f, 0f, 1f));
                drawText.Add(curLine.ToString());
                curY += Main.fontItemStack.MeasureString(curLine).Y + TraceMsgPadding;

                curLine.Clear();
            }

            TraceScroll = MathHelper.Clamp(curY - InnerWindow.Height, 0, Single.PositiveInfinity);
            curY = 0f;

            for (int i = 0; i < drawText.Count; i++)
            {
                var size = Main.fontItemStack.MeasureString(drawText[i]);

                sb.Draw(TMain.WhitePixel, new Vector2(0, curY - TraceScroll), null, (altBg ? TraceBgColour : TraceBgColourAlt) * fadeAlphas[i], 0f, Vector2.Zero, new Vector2(InnerWindow.Width, size.Y + TraceMsgPadding), SpriteEffects.None, 0f);
                altBg = !altBg;

                sb.DrawString(Main.fontItemStack, drawText[i], new Vector2(0, curY - TraceScroll), TraceText * fadeAlphas[i], 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);

                curY += size.Y + TraceMsgPadding;
            }

            sb.End();

            sb.GraphicsDevice.Viewport = screen;
        }
开发者ID:Reuged,项目名称:Prism,代码行数:83,代码来源:TraceDrawer.cs

示例4: DrawWaterChoices

			private void DrawWaterChoices(SpriteBatch spritebatch, Point start, Point mouse)
			{
				Rectangle r = new Rectangle(0, 0, 20, 20);
				for (int i = 0; i < 2; i++)
				{
					for (int j = 0; j < 5; j++)
					{
						if (i != 1 || j != 3)
						{
							int index = j + i * 5;
							r.X = start.X + 24 * j + 12 * i;
							r.Y = start.Y + 24 * i;
							if (i == 1 && j == 4)
							{
								r.X -= 24;
							}
							int num = 0;
							if (r.Contains(mouse))
							{
								if (Main.mouseLeft && Main.mouseLeftRelease)
								{
									CaptureInterface.Settings.BiomeChoice = this.BiomeWater(index);
								}
								num++;
							}
							if (CaptureInterface.Settings.BiomeChoice == this.BiomeWater(index))
							{
								num += 2;
							}
							Texture2D texture = Main.liquidTexture[this.BiomeWater(index)];
							int x = (int)Main.wFrame * 18;
							Color arg_CF_0 = Color.White;
							float num2 = 1f;
							if (num < 2)
							{
								num2 *= 0.5f;
							}
							if (num % 2 == 1)
							{
								spritebatch.Draw(Main.magicPixel, r.TopLeft(), new Rectangle?(new Rectangle(0, 0, 1, 1)), Color.Gold, 0f, Vector2.Zero, new Vector2(20f), SpriteEffects.None, 0f);
							}
							else
							{
								spritebatch.Draw(Main.magicPixel, r.TopLeft(), new Rectangle?(new Rectangle(0, 0, 1, 1)), Color.White * num2, 0f, Vector2.Zero, new Vector2(20f), SpriteEffects.None, 0f);
							}
							spritebatch.Draw(texture, r.TopLeft() + new Vector2(2f), new Rectangle?(new Rectangle(x, 0, 16, 16)), Color.White * num2);
						}
					}
				}
			}
开发者ID:thegamingboffin,项目名称:Ulterraria_Reborn_GitHub,代码行数:50,代码来源:CaptureInterface.cs

示例5: 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);
 }
开发者ID:itamargreen,项目名称:Terraria1,代码行数:6,代码来源:ElementLaser.cs

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


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