public override void MeleeEffects(Player player, Microsoft.Xna.Framework.Rectangle hitbox) { if (player.FindBuffIndex(WeaponOut.BuffIDManaReduction) != -1) { int d = Dust.NewDust(hitbox.TopLeft(), hitbox.Width, hitbox.Height, 15, (player.velocity.X * 0.2f) + (player.direction * 3), player.velocity.Y * 0.2f, 100, Color.White, 1.3f); Main.dust[d].noGravity = true; } else { int d = Dust.NewDust(hitbox.TopLeft(), hitbox.Width, hitbox.Height, 15, (player.velocity.X * 0.2f) + (player.direction * 3), player.velocity.Y * 0.2f, 100, Color.White, 0.6f); Main.dust[d].noGravity = true; } }
public static Rectangle Transform(this Rectangle value, Matrix matrix) { Vector2 topLeft = value.TopLeft().ToVector2().Transform(matrix); Vector2 bottomRight = value.BottomRight().ToVector2().Transform(matrix); return(new Rectangle(topLeft.ToPoint(), (bottomRight - topLeft).ToPoint())); }
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; }
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); }
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; }
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); } } } }
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); }
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; }