本文整理汇总了C#中Vector2f类的典型用法代码示例。如果您正苦于以下问题:C# Vector2f类的具体用法?C# Vector2f怎么用?C# Vector2f使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector2f类属于命名空间,在下文中一共展示了Vector2f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetNewState
private void SetNewState(VelocityComponentState state)
{
if (_lastState != null)
_previousState = _lastState;
_lastState = state;
Velocity = new Vector2f(state.VelocityX, state.VelocityY);
}
示例2: Draw
public override void Draw(RenderTarget rt)
{
Vector2f actualPosition = Position + (Selected ? new Vector2f(0, -12.0f - 5.0f * GetSelectedIndex()) : new Vector2f());
// Draw card
Sprite sprite = new Sprite(Assets.LoadTexture(Info.Type == CardType.White ? "CardWhite.png" : "CardBlack.png"));
Size = new Vector2f(sprite.GetGlobalBounds().Width, sprite.GetGlobalBounds().Height);
sprite.Position = actualPosition;
sprite.Scale = Scale;
rt.Draw(sprite);
// Draw text
Text text = GameUtility.Wrap(Info.Value, Assets.LoadFont("arialbd.ttf"), (uint)Math.Floor(24.0f * Scale.X),
Math.Floor(207.0f * Scale.X));
text.Color = Info.Type == CardType.White ? Color.Black : Color.White;
text.Position = actualPosition + new Vector2f(16.0f * Scale.X, 10.0f * Scale.Y);
text.Round();
rt.Draw(text);
// Draw decorations
if (Info.PickCount > 1)
{
Sprite pickMultiple = new Sprite(Assets.LoadTexture(Info.PickCount == 2 ? "PickTwo.png" : "PickThree.png"))
{
Position =
actualPosition +
new Vector2f((241.0f - 56.0f - 10.0f - 4.0f) * Scale.X, (320.0f - 10.0f - 20.0f) * Scale.Y),
Scale = Scale
};
rt.Draw(pickMultiple);
}
}
示例3: LightWeightPolylineVertex
/// <summary>
/// Initializes a new instance of the <c>LightWeightPolylineVertex</c> class.
/// </summary>
public LightWeightPolylineVertex()
{
this.location = Vector2f.Zero;
this.bulge = 0.0f;
this.beginThickness = 0.0f;
this.endThickness = 0.0f;
}
示例4: HighscoreList
public HighscoreList(Vector2f position)
{
Text = new Text();
Text.Font = Game.Assets.Fonts["PixelPlay"];
Text.CharacterSize = 30;
Text.Position = position;
}
示例5: Draw
public override void Draw()
{
if (!_visible) return;
var d = new Vector2f(Math.Abs(Base.X - Pos.X), Math.Abs(Base.Y - Pos.Y));
var sx = Pos.X < Base.X ? 1 : -1;
var sy = Pos.Y < Base.Y ? 1 : -1;
var worker = new Vector2f(Pos.X, Pos.Y);
var err = d.X - d.Y;
while (!(worker.X == Base.X && worker.Y == Base.Y))
{
Parent.Parent.Window.Draw(new Sprite(Rsc.Tex("rsc/ThrowLine.png"))
{
Position = worker,
Rotation = Rotation + 90,
Origin = new Vector2f(2.5f, 2.5f),
Color = new Color(255,255,255,100)
});
var e2 = 2*err;
if (e2 > -d.Y)
{
err -= d.Y;
worker.X += sx;
}
if (!(e2 < d.X)) continue;
err += d.X;
worker.Y += sy;
}
base.Draw();
}
示例6: AddTile
public void AddTile(float x, float y)
{
Vector2f pos = new Vector2f (x, y);
CollisionTiles.Add (pos, new Tile (pos, true));
CollisionTiles [pos].ChangeSprite (DAO.GetSprite (Element.Tile5));
}
示例7: Draw
public override void Draw(RenderManager renderMgr, Camera camera)
{
int xStart = (int)((camera.Center.X - camera.Size.X * 0.5f) / TileWidth);
int xEnd = (int)(1 + (camera.Center.X + camera.Size.X * 0.5f) / TileWidth);
var yStart = (int)((camera.Center.Y - camera.Size.Y * 0.5f) / TileHeight);
var yEnd = (int)(1 + (camera.Center.Y + camera.Size.Y * 0.5f) / TileHeight); ;
if (xStart < 0)
xStart = 0;
if (xEnd > MapWidth - 1)
xEnd = MapWidth - 1;
if (yStart < 0)
yStart = 0;
if (yEnd > MapHeight - 1)
yEnd = MapHeight - 1;
for (var i = xStart; i < xEnd; i++)
{
for (var j = yStart; j < yEnd; j++)
{
if (Tiles[i, j].Texture == null)
continue;
var position = new Vector2f(
TileWidth * i + TileWidth * 0.5f,
TileHeight * j + TileHeight * 0.5f);
renderMgr.DrawSprite(Tiles[i, j].Texture, Tiles[i, j].SubImageRect, position + WorldPosition, TileWidth, TileHeight, false, false, Tint, ZIndex);
}
}
}
示例8: SpawnProjectile
public virtual Projectile SpawnProjectile(Vector2f pos, float direction, float offset, Vector2f? targetPos = null)
{
Projectile proj = new Projectile(Game, GetProjectileModel(), this);
// Position and Velocity
proj.SetPosition(pos);
proj.Rotate(direction);
float angle = offset == 0 ? (float)Utils.ToRadians(direction) : (float)Utils.ToRadians(direction + offset);
proj.Velocity = new Vector2f((float)Math.Cos(angle) * ProjectileSpeed, (float)Math.Sin(angle) * ProjectileSpeed);
// Stats
proj.Damage = Damage;
proj.SetLifeSpan(ProjectileLifeSpan);
if (targetPos.HasValue)
proj.SetTargetPosition(targetPos.Value);
if (ProjectileRotateSpeed != 0)
{
proj.RotateSpeed = ProjectileRotateSpeed*(Utils.RandomInt() == 1 ? 1 : -1);
proj.Rotate(Utils.RandomInt(0, 359));
}
Game.Layer_Other.AddChild(proj);
return proj;
}
示例9: SetFrame
public void SetFrame(int newFrame, bool resetTime)
{
if (Animation != null)
{
// calculate new vertex positions and texture coordinates
var rect = Animation.Frames[newFrame];
var texCoordA = new Vector2f(0, 0);
var texCoordB = new Vector2f(0, rect.Height);
var texCoordC = new Vector2f(rect.Width, rect.Height);
var texCoordD = new Vector2f(rect.Width, 0);
var left = rect.Left + 0.0001f;
var right = left + rect.Width;
float top = rect.Top;
var bottom = top + rect.Height;
_vertices[0] = new Vertex(texCoordA, new Vector2f(left, top));
_vertices[1] = new Vertex(texCoordB, new Vector2f(left, bottom));
_vertices[2] = new Vertex(texCoordC, new Vector2f(right, bottom));
_vertices[3] = new Vertex(texCoordD, new Vector2f(right, top));
}
if (resetTime)
{
_currentTime = Time.Zero;
}
}
示例10: Fire
public virtual void Fire(Vector2f pos, float direction, Vector2f? targetPos = null)
{
if (!CanShoot)
return;
SpawnProjectiles(pos, direction, targetPos);
}
示例11: getRectOfFrame
internal static IntRect getRectOfFrame(short mFrame, int framesPerRow, Vector2f frameSize)
{
int rowNum = mFrame / framesPerRow;
int colNum = mFrame % framesPerRow;
return new IntRect((int)(colNum * frameSize.X), (int)(rowNum * frameSize.Y), (int)frameSize.X, (int)frameSize.Y);
}
示例12: Circle
public Circle(float radius)
: base((float)Math.PI * radius * radius)
{
circle = new CircleShape(radius);
circle.FillColor = Color.Green;
Origin = new Vector2f(1, 1).Unit() * radius;
}
示例13: MeasureString
public Vector2f MeasureString(TextString str)
{
Vector2f size = new Vector2f(0f,0f);
Vector2f curLineSize = new Vector2f(0f, 0f);
foreach (KeyValuePair<TextStyle, string> s in str.FormatedText)
{
if (s.Key == TextStyle.EndLine)
{
size.Y += curLineSize.Y;
size.X = curLineSize.X > size.X ? curLineSize.X : size.X;
curLineSize = new Vector2f(0f, 0f);
}
else
{
Text textSlope = new Text(s.Value, Font, str.CharacterSize);
Text.Styles textStyle = Text.Styles.Regular;
if ((s.Key & TextStyle.Bold) != 0)
textStyle |= Text.Styles.Bold;
if( (s.Key & TextStyle.Italic) != 0)
textStyle |= Text.Styles.Italic;
textSlope.Style = textStyle;
FloatRect localBounds = textSlope.GetLocalBounds();
Vector2f ssize = new Vector2f(localBounds.Width,localBounds.Height);
curLineSize.X += (int)ssize.X;
curLineSize.Y = (int)ssize.Y > curLineSize.Y ? (int)ssize.Y : curLineSize.Y;
}
}
size.X = curLineSize.X > size.X ? curLineSize.X : size.X;
size.Y += curLineSize.Y;
return size;
}
示例14: Initialize
static void Initialize()
{
Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + Environment.CurrentDirectory + "\\libs");
dtClock = new Stopwatch();
textFps = new Text("0", new Font(new FileStream("assets\\fonts\\arial.ttf", FileMode.Open, FileAccess.Read)));
window = new RenderWindow(new VideoMode(1280, 768), "Test", Styles.Default);
window.SetFramerateLimit(60);
window.SetTitle("NATE");
tiles = new TileManager("assets\\tilemaps\\rpgtiles.png", 32);
iMap = new MapInterface();
//map = new Map(new Vector2i(32, 32), ((int)tiles.image.Size.X / tiles.tileSize) * ((int)tiles.image.Size.Y / tiles.tileSize), true); -- for random
//map = new Map(new Vector2i(32, 32), ((int)tiles.image.Size.X / tiles.tileSize) * ((int)tiles.image.Size.Y / tiles.tileSize), false); -- blank
map = iMap.ReadMap("map1.ntm");
scaling = new Vector2f(2, 2);
textureCollection = new Texture[(tiles.image.Size.X / tiles.tileSize) * (tiles.image.Size.Y / tiles.tileSize)];
camera = new Camera();
camera.speed = 1000;
window.Closed += (s, a) => window.Close();
window.KeyPressed += (s, a) => { if (a.Code == Keyboard.Key.Z) { iMap.WriteMap("map0.ntm", map); } };
window.MouseWheelMoved += (s, a) => { scaling.X += a.Delta * 0.075f; scaling.Y += a.Delta * 0.075f; };
dtClock.Start();
for (int i = 0; i < (tiles.image.Size.X / tiles.tileSize) * (tiles.image.Size.Y / tiles.tileSize); i++)
{
textureCollection[i] = tiles.GetTile(i);
textureCollection[i].Smooth = false;
}
}
示例15: InGame
public InGame(IEnumerable<Player> players)
{
ChatBacklog = new List<string>();
Input.Text = InputText;
chatValue = "";
// Add every player from lobby
foreach (Player p in players)
Entities.Add(p);
// Set local player position first
LocalPlayer.Position = new Vector2f(GameOptions.Width / 2.0f - 128.0f - 8.0f, GameOptions.Height - 194.0f - 8.0f - 64.0f);
// Add everyone else
Vector2f otherPosition = new Vector2f(GameOptions.Width / 2.0f - ((128.0f + 32.0f) * (Players.Count - 2)) / 2.0f - 128.0f - 8.0f, 100.0f + 32.0f + 8.0f);
foreach (Player p in Players.Where(p => !p.IsLocalPlayer))
{
p.Position = otherPosition;
otherPosition += new Vector2f(128.0f + 32.0f, 0.0f);
}
// Play match start sound
string startSoundFilename = "Start" + new Random().Next(5).ToString("G") + ".wav";
Timer.NextFrame(() => Assets.PlaySound(startSoundFilename));
}