本文整理汇总了C#中Microsoft.Xna.Framework.Rectangle.Inflate方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Inflate方法的具体用法?C# Rectangle.Inflate怎么用?C# Rectangle.Inflate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Rectangle
的用法示例。
在下文中一共展示了Rectangle.Inflate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: update
public void update(GameTime gameTime)
{
move(player.getPos() - pos);
camArea = levelManager.getCurrentLevelArea();
camArea.Inflate(-200, -200);
if (pos.X < camArea.Left)
pos.X = camArea.Left;
else if (pos.X > camArea.Right)
pos.X = camArea.Right;
if (pos.Y > camArea.Bottom)
pos.Y = camArea.Bottom;
else if (pos.Y < camArea.Top)
pos.Y = camArea.Top;
/*if (pos.X - screenPos.X < levelManager.getCurrentLevelArea().Left)
pos.X = levelManager.getCurrentLevelArea().Left + screenPos.X;
else if (pos.X + screenPos.X > levelManager.getCurrentLevelArea().Right)
pos.X = levelManager.getCurrentLevelArea().Right - screenPos.X;
if (pos.Y + screenPos.Y > levelManager.getCurrentLevelArea().Bottom)
pos.Y = levelManager.getCurrentLevelArea().Bottom - screenPos.Y;
else if (pos.Y - screenPos.Y < levelManager.getCurrentLevelArea().Top)
pos.Y = levelManager.getCurrentLevelArea().Top + screenPos.Y;*/
updateTransform();
//Console.WriteLine(transform);
}
示例2: Update
public override void Update()
{
Rectangle value = new Rectangle(0, 0, 32, 48);
value.Inflate(1600, 1600);
int x = value.X;
int y = value.Y;
if (this.npc != -1)
{
if (!Main.npc[this.npc].active || Main.npc[this.npc].type != 488 || Main.npc[this.npc].ai[0] != (float)this.Position.X || Main.npc[this.npc].ai[1] != (float)this.Position.Y)
{
this.Deactivate();
return;
}
}
else
{
TETrainingDummy.FillPlayerHitboxes();
value.X = (int)(this.Position.X * 16) + x;
value.Y = (int)(this.Position.Y * 16) + y;
bool flag = false;
foreach (KeyValuePair<int, Rectangle> current in TETrainingDummy.playerBox)
{
if (current.Value.Intersects(value))
{
flag = true;
break;
}
}
if (flag)
{
this.Activate();
}
}
}
示例3: GameNode
public GameNode(SpriteSheet spriteSheet) : base(spriteSheet)
{
bounds = new Rectangle(0, 0, Config.WorldBoundsX, Config.WorldBoundsY);
bounds.Inflate((int)(this.Sprite.Origin.X * 3), (int)(this.Sprite.Origin.Y * 3));
hitTimer = new Timer();
hitTimer.Fire += new NotifyHandler(hitTimer_Fire);
}
示例4: CreateCenteredRectangle
public static Rectangle CreateCenteredRectangle(Vector2 location, int width, int height)
{
Rectangle rect = new Rectangle((int)location.X , (int)location.Y, 0, 0);
rect.Inflate (width, height);
return rect;
}
示例5: Update
public override void Update()
{
Rectangle rectangle = new Rectangle(0, 0, 32, 48);
rectangle.Inflate(1600, 1600);
int num1 = rectangle.X;
int num2 = rectangle.Y;
if (this.npc != -1)
{
if (Main.npc[npc].active && Main.npc[npc].type == 488 && (Main.npc[npc].ai[0] == Position.X && Main.npc[npc].ai[1] == Position.Y))
return;
Deactivate();
}
else
{
FillPlayerHitboxes();
rectangle.X = (int)Position.X * 16 + num1;
rectangle.Y = (int)Position.Y * 16 + num2;
bool flag = false;
foreach (KeyValuePair<int, Rectangle> keyValuePair in playerBox)
{
if (keyValuePair.Value.Intersects(rectangle))
{
flag = true;
break;
}
}
if (!flag)
return;
Activate();
}
}
示例6: HandleFieldCheck
/// <summary>
/// Checks if the ship can be placed on its current position.
/// If the placing is allowed for the fields, they will marked green.
/// If the placing is forbidden for the fields, they will marked red.
/// </summary>
/// <param name="p">The playground with the fields</param>
/// <param name="currentShip">The current ship</param>
public static void HandleFieldCheck(Playground p, Ship currentShip)
{
int counter = 0;
List<Field> markedFields = new List<Field>();
foreach (Field field in p.fields)
{
int smaller = Convert.ToInt32(field.Size.Width / 2.1) * -1;
Rectangle rect = new Rectangle(currentShip.Rectangle.X, currentShip.Rectangle.Y, currentShip.Rectangle.Width, currentShip.Rectangle.Height);
rect.Inflate(smaller,smaller);
if ((field.ReferencedShip == null || field.ReferencedShip == currentShip) && field.Rectangle.Intersects(rect))
{
field.SetColor(Enum.FieldColor.Green);
counter++;
markedFields.Add(field);
}
else
{
field.ResetColor();
}
}
if (counter == currentShip.Size)
{
currentShip.OverlayColor = Color.Green;
AppCache.CurrentMatch.FooterMenu.Get("btnPlace").Visible = true;
}
else
{
currentShip.OverlayColor = Color.Red;
AppCache.CurrentMatch.FooterMenu.Get("btnPlace").Visible = false;
foreach (Field f in markedFields)
{
f.SetColor(Enum.FieldColor.Red);
}
}
}
示例7: Update
public void Update(GraphicsDevice graphicsdevice)
{
var worldAtZero = ScreenToWorld(Vector2.Zero);
var worldAtView = ScreenToWorld(new Vector2(Moxy.Graphics.Viewport.Width, Moxy.Graphics.Viewport.Height));
ViewFrustrum = new Rectangle((int)Math.Floor(worldAtZero.X), (int)Math.Floor(worldAtZero.Y), (int)Math.Ceiling(worldAtView.X - worldAtZero.X),
(int)Math.Ceiling(worldAtView.Y - worldAtZero.Y));
ViewFrustrum.Inflate(150, 150);
if (ViewTargets.Count > 0)
{
Vector2 min = ViewTargets[0].Location;
Vector2 max = ViewTargets[0].Location;
for (int i = 1; i < ViewTargets.Count; i++)
{
if (ViewTargets[i].Location.X < min.X) min.X = ViewTargets[i].Location.X;
else if (ViewTargets[i].Location.X > max.X) max.X = ViewTargets[i].Location.X;
if (ViewTargets[i].Location.Y < min.Y) min.Y = ViewTargets[i].Location.Y;
else if (ViewTargets[i].Location.Y > max.Y) max.Y = ViewTargets[i].Location.Y;
}
Rectangle rect = new Rectangle ((int)min.X, (int)min.Y,
(int)(max.X - min.X), (int)(max.Y - min.Y));
if (UseBounds)
{
if (rect.Width < MinimumSize.Width)
rect.Inflate((int)(MinimumSize.Width - rect.Width) / 2, 0);
if (rect.Height < MinimumSize.Height)
rect.Inflate(0, (int)(MinimumSize.Height - rect.Height) / 2);
}
rect.Inflate (InflateAmount, InflateAmount);
PlayerFrustrum = rect;
desiredPosition = new Vector2(rect.X, rect.Y);
float widthdiff = ((float)graphicsdevice.Viewport.Width) / ((float)rect.Width);
float heightdiff = ((float)graphicsdevice.Viewport.Height) / ((float)rect.Height);
desiredZoom = Math.Min (widthdiff, heightdiff);
}
Position = Vector2.Lerp(Position, desiredPosition, 0.1f);
Zoom = MathHelper.Lerp(Zoom, desiredZoom, 0.1f);
}
示例8: PadRectangle
/// <summary>
/// Copys a rectangle and inflates it
/// </summary>
/// <param name="source">Rectangle to copy and inflate</param>
/// <returns>Inflated rectangle</returns>
public static Rectangle PadRectangle(Rectangle source, float scaleX, float scaleY)
{
//return new Rectangle((int)(source.X * scale), (int)(source.Y * scale), (int)(source.Width * scale), (int)(source.Height * scale));
//inflate and return copy
source.Inflate((int)(source.Width * scaleX), (int)(source.Height * scaleY));
return source;
}
示例9: DrawCellBase
public void DrawCellBase(PathCell cell, Rectangle rectangle)
{
if (cell.Path != null && cell.Path.IsValid)
{
spriteBatch.Draw(parent.BlankTexture, rectangle, Color.Blue);
}
rectangle.Inflate(-CellSize / 8, -CellSize / 8);
spriteBatch.Draw(parent.BlankTexture, rectangle, cell.Color.ToXnaColor());
}
示例10: DrawModel
public override void DrawModel(SpriteBatch spriteBatch)
{
foreach (var selectedCard in selectedCards) {
var halo = new Rectangle(selectedCard.Position.X, selectedCard.Position.Y, selectedCard.Position.Width, selectedCard.Position.Height);
halo.Inflate(2, 2);
spriteBatch.Draw(haloTexture, halo, Color.White);
}
base.DrawModel(spriteBatch);
}
示例11: TileBackground
public TileBackground(Texture2D _sprite, Vector2 _pos, Vector2 _vel, int _hp, LevelManager l)
: base(_sprite, _pos, _vel, _hp, l)
{
rect = l.getCurrentLevelArea();
rect.Inflate(10000, 10000);
pos.X -= 5000;
pos.Y -= 5000;
center.X += 5000;
center.Y += 5000;
rotation = (float)Game1.random.NextDouble() * (float)Math.PI * 2.0f;
}
示例12: Init
//Texture2D tank, turret;
public void Init(Random r, Rectangle bounds)
{
bounds.Inflate(-boundingRadius, -boundingRadius);
position.X = (float)(bounds.Left + bounds.Width * r.NextDouble());
position.Y = (float)(bounds.Top + bounds.Height * r.NextDouble());
rotation = (float)(r.NextDouble() * MathHelper.TwoPi);
random = r;
}
示例13: Gauge
public Gauge(Rectangle pos, float max, Color color, Color fillColor)
{
// Init
_max = max;
_gaugeColor = color;
_fillColor = fillColor;
_position = new Vector2(pos.X, pos.Y);
_current = 0;
_gauge = pos;
_fill = new Rectangle(pos.X, pos.Y, pos.Width, pos.Height);
_fill.Inflate(-2, 0);
}
示例14: WorldBorder
public WorldBorder(Game game, Rectangle innerBorder, PhysicsSimulator physicsSimulator)
{
this.game = game;
var outerBorder = new Rectangle(innerBorder.X, innerBorder.X, innerBorder.Width, innerBorder.Height);
outerBorder.Inflate(buffer, buffer);
AddLeftBorder(physicsSimulator, innerBorder, outerBorder);
AddRightBorder(physicsSimulator, innerBorder, outerBorder);
AddTopBorder(physicsSimulator, innerBorder, outerBorder);
AddBottomBorder(physicsSimulator, innerBorder, outerBorder);
}
示例15: UpdateDummies
public static void UpdateDummies()
{
Dictionary<int, Rectangle> dictionary = new Dictionary<int, Rectangle>();
bool flag = false;
Rectangle value = new Rectangle(0, 0, 32, 48);
value.Inflate(1600, 1600);
int num = value.X;
int num2 = value.Y;
for (int i = 0; i < 1000; i++)
{
if (TargetDummy.dummies[i] != null)
{
TargetDummy.dummies[i].whoAmI = i;
if (TargetDummy.dummies[i].npc != -1)
{
if (!Main.npc[TargetDummy.dummies[i].npc].active || Main.npc[TargetDummy.dummies[i].npc].type != 488 || Main.npc[TargetDummy.dummies[i].npc].ai[0] != (float)TargetDummy.dummies[i].x || Main.npc[TargetDummy.dummies[i].npc].ai[1] != (float)TargetDummy.dummies[i].y)
{
TargetDummy.dummies[i].Deactivate();
}
}
else
{
if (!flag)
{
for (int j = 0; j < 255; j++)
{
if (Main.player[j].active)
{
dictionary[j] = Main.player[j].getRect();
}
}
flag = true;
}
value.X = (int)(TargetDummy.dummies[i].x * 16) + num;
value.Y = (int)(TargetDummy.dummies[i].y * 16) + num2;
bool flag2 = false;
foreach (KeyValuePair<int, Rectangle> current in dictionary)
{
if (current.Value.Intersects(value))
{
flag2 = true;
break;
}
}
if (flag2)
{
TargetDummy.dummies[i].Activate();
}
}
}
}
}