本文整理汇总了C#中FloatRect类的典型用法代码示例。如果您正苦于以下问题:C# FloatRect类的具体用法?C# FloatRect怎么用?C# FloatRect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FloatRect类属于命名空间,在下文中一共展示了FloatRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateBoundingBox
public FloatRect CalculateBoundingBox(float thrusterXScale = 0.3f)
{
var sprites = ServiceLocator.Instance.GetService<ISpriteManagerService>().Sprites;
return Parts.Where(p=>p.SpriteId!=null).Aggregate(new FloatRect(), (box, part) =>
{
Sprite spr;
if (!sprites.TryGetValue(part.SpriteId, out spr)) return box;
var aabb = new FloatRect(-(spr.OriginX ?? spr.W / 2), -(spr.OriginY ?? spr.H / 2), spr.W, spr.H);
var topleft = new Vector2(Math.Min(aabb.Left, aabb.Right), Math.Min(aabb.Top, aabb.Bottom));
var bottomright = new Vector2(Math.Max(aabb.Left, aabb.Right), Math.Max(aabb.Top, aabb.Bottom));
var matrix = part.Transform.Matrix;
if (part is Thruster)
{
matrix = Matrix.CreateScale(new Vector3(thrusterXScale, 1, 1)) * matrix;
}
Vector2.Transform(ref topleft, ref matrix, out topleft);
Vector2.Transform(ref bottomright, ref matrix, out topleft);
return new FloatRect(new Vector2(Math.Min(Math.Min(topleft.X, bottomright.X), box.Left), Math.Min(Math.Min(topleft.Y, bottomright.Y), box.Top)),
new Vector2(Math.Max(Math.Abs(topleft.X - bottomright.X), box.Width), Math.Max(Math.Abs(topleft.Y - bottomright.Y), box.Width)));
});
}
示例2: Draw
public void Draw(Texture2D texture, ref Matrix transform, FloatRect? sourceRectangle = null, Color? color=null, Vector3? normal = null)
{
Vertex3CTN vtx;
vtx.Color = color ?? Color.White;
vtx.Normal = normal ?? Vector3.Forward;
FloatRect texRect = sourceRectangle ?? new FloatRect(texture.Bounds);
Vector2 texCoordLT = texture.GetUV(texRect.Left, texRect.Top);
Vector2 texCoordBR = texture.GetUV(texRect.Right, texRect.Bottom);
vtx.Position = Vector3.Zero;
vtx.TextureCoords = texCoordLT;
_quadVertices[0] = vtx;
vtx.Position = new Vector3(0, texRect.Height, 0);
vtx.TextureCoords = new Vector2(texCoordLT.X, texCoordBR.Y);
_quadVertices[1] = vtx;
vtx.Position = new Vector3(texRect.Width, 0, 0);
vtx.TextureCoords = new Vector2(texCoordBR.X, texCoordLT.Y);
_quadVertices[2] = vtx;
vtx.Position = new Vector3(texRect.Width, texRect.Height, 0);
vtx.TextureCoords = texCoordBR;
_quadVertices[3] = vtx;
DrawVertices(texture, _quadVertices, _quadIndices, ref transform);
}
示例3: SetParameter
/// <summary>
/// Set parameters :)
/// </summary>
/// <param name="parameter"></param>
public override void SetParameter(ComponentParameter parameter)
{
var tileSize = IoCManager.Resolve<IMapManager>().TileSize;
//base.SetParameter(parameter);
switch (parameter.MemberName)
{
case "SizeX":
var width = parameter.GetValue<float>() / tileSize;
AABB = new FloatRect(AABB.Left + (AABB.Width - width) / 2f, AABB.Top, width, AABB.Height);
break;
case "SizeY":
var height = parameter.GetValue<float>() / tileSize;
AABB = new FloatRect(AABB.Left, AABB.Top + (AABB.Height - height) / 2f, AABB.Width, height);
break;
case "OffsetX":
var x = parameter.GetValue<float>() / tileSize;
AABB = new FloatRect(x - AABB.Width / 2f, AABB.Top, AABB.Width, AABB.Height);
break;
case "OffsetY":
var y = parameter.GetValue<float>() / tileSize;
AABB = new FloatRect(AABB.Left, y - AABB.Height / 2f, AABB.Width, AABB.Height);
break;
}
}
示例4: Draw
public void Draw(Stopwatch time)
{
myApp.window.Clear(myStyle.BackgroundColor);
if( myStyle.BackgroundImage != null )
{
ImagePart part= myStyle.BackgroundImage;
myUIManager.Painter.Begin();
if( myStyle.BackgroundDisplayMode == TextureDisplayMode.Stretch )
myUIManager.Painter.DrawImage(part.SourceTexture, new FloatRect(0f, 0f, myUIManager.ScreenSize.X, myUIManager.ScreenSize.Y), part.SourceRectangle);
else
{
// the image must be centered.
FloatRect destRect = new FloatRect(
0.5f*(myUIManager.ScreenSize.X - myStyle.BackgroundImage.Size.X),
0.5f * (myUIManager.ScreenSize.Y - myStyle.BackgroundImage.Size.Y),
myStyle.BackgroundImage.Size.X,
myStyle.BackgroundImage.Size.Y);
myUIManager.Painter.DrawImage(part.SourceTexture, destRect, part.SourceRectangle);
}
myUIManager.Painter.End();
}
myUIManager.Render();
}
示例5: Update
public override bool Update(Vector2i mouseS, IMapManager currentMap)
{
if (currentMap == null) return false;
spriteToDraw = GetDirectionalSprite(pManager.CurrentBaseSpriteKey);
mouseScreen = mouseS;
mouseWorld = CluwneLib.ScreenToWorld(mouseScreen);
var bounds = spriteToDraw.GetLocalBounds();
var spriteSize = CluwneLib.PixelToTile(new Vector2f(bounds.Width, bounds.Height));
var spriteRectWorld = new FloatRect(mouseWorld.X - (spriteSize.X / 2f),
mouseWorld.Y - (spriteSize.Y / 2f),
spriteSize.X, spriteSize.Y);
if (pManager.CurrentPermission.IsTile)
return false;
if (pManager.CollisionManager.IsColliding(spriteRectWorld))
return false;
//if (currentMap.IsSolidTile(mouseWorld)) return false;
var rangeSquared = pManager.CurrentPermission.Range * pManager.CurrentPermission.Range;
if (rangeSquared > 0)
if (
(pManager.PlayerManager.ControlledEntity.GetComponent<TransformComponent>(ComponentFamily.Transform)
.Position - mouseWorld).LengthSquared() > rangeSquared) return false;
currentTile = currentMap.GetTileRef(mouseWorld);
return true;
}
示例6: DrawRectangle
public static void DrawRectangle(FloatRect rect, Color color) => drawInfos.Add(new DebugDrawInfo(new[]
{
new Vertex(new Vector2f(rect.Left, rect.Top), color),
new Vertex(new Vector2f(rect.Left + rect.Width, rect.Top), color),
new Vertex(new Vector2f(rect.Left + rect.Width, rect.Top + rect.Height), color),
new Vertex(new Vector2f(rect.Left, rect.Top + rect.Height), color),
new Vertex(new Vector2f(rect.Left, rect.Top), color)
}, PrimitiveType.LinesStrip));
示例7: Backdrop
/// <summary>
/// The FloatRects are relative to inside that Texture sent in
/// </summary>
public Backdrop(String[] bgText, FloatRect startSquare, FloatRect finalSquare)
{
backgroundString = bgText[0];
waterString = bgText[1];
topProps = new List<PropSprite>();
lowProps = new List<PropSprite>();
}
示例8: QuadTreeNode
public QuadTreeNode(FloatRect range, int capacity, Vector2f minSize)
{
this.range = range;
this.capacity = capacity;
this.child = null;
this.cubeList = new List<Cube>();
this.minSize = minSize;
}
示例9: HWSurfaceInstance
public HWSurfaceInstance(ScriptEngine parent, Texture texture)
: base(parent.Object.InstancePrototype)
{
_source = new FloatRect(_ox, _oy, texture.Size.X, texture.Size.Y);
_ox += _source.Width + 1;
if (_ox > _aw) { _ox = 0; _oy += _source.Height + 1; }
Init();
}
示例10: Pillar
List<ChampItemPair> units; //ingroup
#endregion Fields
#region Constructors
internal Pillar(FloatRect postion)
{
rect = postion;
units = new List<ChampItemPair>();
pillarSprite = new Sprite();
unitSprite = new Sprite();
}
示例11: Draw
/// <summary>
/// Draws a rectangle.
/// </summary>
/// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
/// <param name="dest">Destination rectangle.</param>
/// <param name="color">Color of the rectangle.</param>
public static void Draw(ISpriteBatch sb, Rectangle dest, Color color)
{
var fDest = new FloatRect(dest.Left, dest.Top, dest.Width, dest.Height);
using (var s = Shape.Rectangle(fDest, color))
{
sb.Draw(s);
}
}
示例12: Player
public Player(FloatRect screenRect)
{
// setup player
_shape = new CircleShape(30, 3);
_shape.Position = new Vector2f(screenRect.Width/2 - (_shape.Radius), screenRect.Height - (_shape.Radius*2));
_shape.FillColor = Color.Green;
_bullets = new List<RectangleShape> ();
}
示例13: Update
public override void Update(float dt)
{
base.Update(dt);
Hitbox = new FloatRect(
MyEntity.Transform.Position.X - MyEntity.Transform.Origin.X,
MyEntity.Transform.Position.Y - MyEntity.Transform.Origin.Y,
Hitbox.Width,
Hitbox.Height);
}
示例14: OnColides
private void OnColides(ColiderComponent colider, FloatRect overlap)
{
if(colider.MyEntity.HasComponent<Player>() &&
StateManager.Instance.CurrentState is LevelState )
{
var levelState = StateManager.Instance.CurrentState as LevelState;
levelState.CurrentLevel++;
}
}
示例15: draw
internal override void draw(RenderWindow window)
{
//remember mPos is the middle this time
FloatRect r = new FloatRect((int)(mPos.X - length / 2), (int)(mPos.Y - ylength / 2), (int)length, (int)ylength);
sprite.Position = new Vector2f((mPos.X - (float)length / 2.0f),(mPos.Y - (float)ylength / 2.0f) );
sprite.Color = color;
sprite.Scale = new Vector2f((float)length / sprite.TextureRect.Width, (float)ylength / sprite.TextureRect.Height);
window.Draw(sprite);
}