本文整理汇总了C#中Point.ToVector2方法的典型用法代码示例。如果您正苦于以下问题:C# Point.ToVector2方法的具体用法?C# Point.ToVector2怎么用?C# Point.ToVector2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point.ToVector2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PointToVector2
public void PointToVector2()
{
var pt = new Point(-3, 5);
var actual = pt.ToVector2();
var expected = new System.Numerics.Vector2(-3, 5);
Assert.AreEqual(expected, actual);
}
示例2: UpdateGridPosition
void UpdateGridPosition(Point position, bool warp)
{
_targetPos = position;
if (warp)
{
FinishMove();
transform.position = _targetPos.ToVector2() * gridCellSize;
}
else
{
StartMove();
}
}
示例3: Draw
public override void Draw(SpriteBatch sb)
{
if (tiles == null || tiles.Length != BrushSize || tiles[0][0] != BaseTile) {
tiles = UtilityFramework.Util.GetInitialized2DArray<Tile>(BrushSize, BrushSize, BaseTile);
}
for (int x = 0; x < BrushSize; x++) {
for (int y = 0; y < BrushSize; y++) {
Point p = new Point(Origin.X + x - BrushSize / 2, Origin.Y + y - BrushSize / 2);
if (p.X >= 0 && p.Y >= 0 && p.X < Map.Settings.Dimensions.XCount && p.Y < Map.Settings.Dimensions.YCount && Map.GetTileAt(p.X, p.Y) != BaseTile) {
tiles[x][y].Draw(sb, p.ToVector2() * Map.Settings.TileSize + Map.Settings.TileSize / 2.0f, Color.White);
}
}
}
}
示例4: AnimatedBackground
public AnimatedBackground(string texture, Point worldDimensions, int segmentSeed)
{
_texture = "anim-" + texture;
_worldDimensions = worldDimensions.ToVector2();
_generatorSeed = segmentSeed;
_generatorLastValue = 0;
_generatorIteration = 0;
_segmentSequenceIndex = 0;
CalculateBackgroundTargetArea();
RenderLayer = Render_Layer;
Visible = true;
Wrap = false;
SetCloudMetrics(texture);
}
示例5: Contains
public bool Contains(Point point)
{
return Shape.Contains(point.ToVector2());
}
示例6: HandlePointerPressed
private void HandlePointerPressed(Point position, bool isLeft, bool isRight)
{
var pointerPos = position.ToVector2();
if (isLeft)
{
bool newSelection = false;
Tank tempTank = null;
//check if something get selected
foreach (var tank in Tanks)
{
if (tank.selected)
{
tempTank = tank;
}
if (!newSelection && Vector2.Distance(pointerPos, tank.CurrentPosition) < tank.size)
{
tank.selected = true;
isTankSelected = true;
newSelection = true;
}
else
{
tank.selected = false;
}
}
if (!newSelection && tempTank != null)
{
tempTank.TargetPosition = pointerPos;
tempTank.selected = true;
}
}
else if (isRight)
{
this.FiringTargetPos = pointerPos;
this.FireCommand = true;
}
}
示例7: WorldToGrid
/// <summary>
/// Convert screen coordinates in grid ones
/// </summary>
/// <param name="absolutePoint"></param>
/// <returns></returns>
public static Vector2 WorldToGrid(Point absolutePoint, Vector2 tileSize)
{
return WorldToGrid(absolutePoint.ToVector2(), tileSize);
}
示例8: Play
public static SoundEffectInstance Play(SfxEntry entry, Point tilePos, int variant, float volMod = Single.NaN, float pitch = Single.NaN, float panMod = Single.NaN)
{
return Play(entry, tilePos.ToVector2() * 16f, variant, (SfxEntry e, Vector2 p, ref int v, ref float vol, ref float pi, ref float pan) =>
{
if (!Single.IsNaN(vol))
vol *= volMod;
if (!Single.IsNaN(pi))
pi = pitch;
if (!Single.IsNaN(pan))
pan *= panMod;
return true;
});
}
示例9: SetPosition
public void SetPosition(Point pos)
{
this.Position = pos.ToVector2();
//this.SetPosition(pos.X, pos.Y);
}
示例10: Contains
public bool Contains(Point point)
{
return BoundingRectangle.Contains(point.ToVector2());
}
示例11: AddTeleportObject
public void AddTeleportObject(Point groundPoint, Point assetSize, Texture2D texture, bool isVisible, Point destination)
{
TeleportComponent teleComp = new TeleportComponent(texture.Width, texture.Height, destination);
GameObject tempObject = new GameObject(groundPoint.ToVector2(), texture, isVisible, teleComp);
tempObject.Size = assetSize;
LevelObjects.Add(tempObject);
}
示例12: UniversoAVentana
/// <summary>
/// Convierte de universo a ventana
/// </summary>
public Point UniversoAVentana (Point p)
{
return UniversoAVentana (p.ToVector2 ()).ToPoint ();
}
示例13: AddTrampolineObject
public void AddTrampolineObject(Point groundPoint, Point assetSize, Texture2D texture, bool isVisible, float jumpMagnifier)
{
TrampolineComponent trampComp = new TrampolineComponent(texture.Width, texture.Height, jumpMagnifier);
GameObject tempObject = new GameObject(groundPoint.ToVector2(), texture, isVisible, trampComp);
tempObject.Size = assetSize;
LevelObjects.Add(tempObject);
}
示例14: AddObject
public void AddObject(Point groundPoint, Texture2D texture, bool isVisible)
{
GameObject tempGameObject = new GameObject(groundPoint.ToVector2(), texture, isVisible, PhysicsType.StaticObject);
LevelObjects.Add(tempGameObject);
}
示例15: LoadExitTile
/// <summary>
/// Remembers the location of the level's exit.
/// </summary>
private Tile LoadExitTile(int x, int y)
{
if (exit != InvalidPosition)
throw new NotSupportedException("A level may only have one exit.");
exit = GetBounds(x, y).Center;
Game.Penumbra.Lights.Add(new PointLight
{
Position = exit.ToVector2(),
Scale = new Vector2(100),
Color = Color.Red,
CastsShadows = false
});
return LoadTile("Exit", TileCollision.Passable);
}