本文整理汇总了C#中FloatRect类的典型用法代码示例。如果您正苦于以下问题:C# FloatRect类的具体用法?C# FloatRect怎么用?C# FloatRect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FloatRect类属于命名空间,在下文中一共展示了FloatRect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)));
});
}
开发者ID:raycrasher,项目名称:Fell-Sky,代码行数:26,代码来源:ShipModel.cs
示例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);
}
开发者ID:raycrasher,项目名称:Fell-Sky,代码行数:25,代码来源:FastSpriteBatch.cs
示例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;
}
}
开发者ID:MSylvia,项目名称:space-station-14,代码行数:29,代码来源:HitboxComponent.cs
示例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();
}
开发者ID:Ziple,项目名称:NOubliezPas,代码行数:26,代码来源:ThemeSelectionMenu.cs
示例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;
}
开发者ID:MSylvia,项目名称:space-station-14,代码行数:33,代码来源:AlignNone.cs
示例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));
开发者ID:Spanfile,项目名称:LD33,代码行数:8,代码来源:Debug.cs
示例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>();
}
开发者ID:nik0kin,项目名称:ProjectTurtle,代码行数:11,代码来源:Backdrop.cs
示例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;
}
开发者ID:CyrilPaulus,项目名称:2dThing,代码行数:8,代码来源:QuadTree.cs
示例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();
}
开发者ID:Radnen,项目名称:sphere-sfml,代码行数:8,代码来源:HWSurfaceInstance2.cs
示例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();
}
开发者ID:nik0kin,项目名称:ProjectTurtle,代码行数:14,代码来源:Pillar.cs
示例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);
}
}
开发者ID:wtfcolt,项目名称:game,代码行数:15,代码来源:RenderRectangle.cs
示例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> ();
}
开发者ID:aishsingh,项目名称:EquationInvasion,代码行数:9,代码来源:Player.cs
示例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);
}
开发者ID:nikibobi,项目名称:LD26-fail,代码行数:9,代码来源:ColiderComponent.cs
示例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++;
}
}
开发者ID:nikibobi,项目名称:LD26-fail,代码行数:9,代码来源:LevelEnd.cs
示例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);
}
开发者ID:nik0kin,项目名称:ProjectTurtle,代码行数:10,代码来源:Puri.cs
示例16: PlayerShip
/// <summary>
/// Constructor
/// </summary>
/// <param name="resManager">Gestor de recursos</param>
/// <param name="worldBounds">Dimensiones de area de movimiento del PlayerShip</param>
/// <param name="shootPool">Piscina que gestiona el reciclaje de las balas</param>
public PlayerShip(ResourcesManager resManager, FloatRect worldBounds,ShootPlayerPool shootPool)
: base()
{
_sprite = new Sprite((Texture)resManager["Naves:NaveJugador"]);
_worldBounds = worldBounds;
// ubico el origen del sprite en el centro en vez de en la esquina superior derecha
FloatRect bounds = _sprite.GetLocalBounds();
_sprite.Origin = new SFML.System.Vector2f(bounds.Width / 2f, bounds.Height / 2f);
_shootPool = shootPool;
}
开发者ID:aoltra,项目名称:Galaga-SFML.Net,代码行数:18,代码来源:PlayerShip.cs
示例17: LevelEnd
public static Entity LevelEnd(int x, int y)
{
var entity = new Entity();
entity.Transform.Origin = new Vector2f(TILE_SIZE / 2f, TILE_SIZE / 2f);
entity.Transform.Position = new Vector2f(x * TILE_SIZE, y * TILE_SIZE);
var hitbox = new FloatRect(0, 0, TILE_SIZE, TILE_SIZE);
var colider = new ColiderComponent(hitbox);
var end = new LevelEnd();
entity.AddComponent(colider);
entity.AddComponent(end);
return entity;
}
开发者ID:nikibobi,项目名称:LD26-fail,代码行数:12,代码来源:EntityFactory.cs
示例18: EntitiesInRegion
public IEnumerable<Entity> EntitiesInRegion(FloatRect rect)
{
var min = new Vector2(rect.Left, rect.Top) / Program.PixelsPerMeter;
var aabb = new AABB(min, min + (new Vector2(rect.Width, rect.Height) / Program.PixelsPerMeter));
var result = new List<Entity>(256);
World.QueryAABB(f =>
{
result.Add((Entity)f.Body.UserData);
return true;
}, ref aabb);
return result.Distinct().OrderBy(e => e.Depth + e.DepthBias);
}
开发者ID:Rohansi,项目名称:FPCompo11,代码行数:14,代码来源:State.cs
示例19: Tile
public Tile(Game game, Vector2i mapPos, int scale, int tileID, bool solid = false)
{
this.game = game;
this.tileID = tileID;
this.solid = solid;
this.mapPos = mapPos;
Position = new Vector2f((mapPos.X * 16) * scale, (mapPos.Y * 16) * scale);
sprite = new Sprite(TextureLoader.GetTile(tileID));
sprite.Scale = new Vector2f(scale, scale);
bounds = new FloatRect(Position, new Vector2f(16 * scale, 16 * scale));
}
开发者ID:Spanfile,项目名称:LD33,代码行数:14,代码来源:Tile.cs
示例20: LoadContent
internal static new void LoadContent()
{
buffDmgAbilityTexture = GameBox.loadTexture("images/abilitys/buffDmgIcon");
buffCDAbilityTexture = GameBox.loadTexture("images/abilitys/buffCDIcon");
//beams
buffDmgBeamTexture = GameBox.loadTexture("images/abilitys/buffDmg_beam"); ;
buffDmgBeamRect = new FloatRect(0, 0, 4, 4);
buffCDBeamTexture = GameBox.loadTexture("images/abilitys/buffCD_beam");
buffCDBeamRect = new FloatRect(0, 0, 4, 4);
bardBaseTexture = GameBox.loadTexture(SimpleModel.CLASS_PATH + "bardbase");
bardWepAnimation = GameBox.loadTexture(SimpleModel.CLASS_PATH + "bardanim");
}
开发者ID:nik0kin,项目名称:ProjectTurtle,代码行数:14,代码来源:Bard.cs
注:本文中的FloatRect类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论