38 lines
1.9 KiB
C#
38 lines
1.9 KiB
C#
using System.Numerics;
|
|
|
|
namespace Gameboard.ShogiUI.BoardState
|
|
{
|
|
/// <summary>
|
|
/// Provides normalized Vector2s relative to player.
|
|
/// "Up" for player 1 is "Down" for player 2; that sort of thing.
|
|
/// </summary>
|
|
public class Direction
|
|
{
|
|
private static readonly Vector2 PositiveX = new Vector2(1, 0);
|
|
private static readonly Vector2 NegativeX = new Vector2(-1, 0);
|
|
private static readonly Vector2 PositiveY = new Vector2(0, 1);
|
|
private static readonly Vector2 NegativeY = new Vector2(0, -1);
|
|
private static readonly Vector2 PositiveYX = new Vector2(1, 1);
|
|
private static readonly Vector2 NegativeYX = new Vector2(-1, -1);
|
|
private static readonly Vector2 NegativeYPositiveX = new Vector2(1, -1);
|
|
private static readonly Vector2 PositiveYNegativeX = new Vector2(-1, 1);
|
|
|
|
private readonly WhichPlayer whichPlayer;
|
|
public Direction(WhichPlayer whichPlayer)
|
|
{
|
|
this.whichPlayer = whichPlayer;
|
|
}
|
|
|
|
public Vector2 Up => whichPlayer == WhichPlayer.Player1 ? PositiveY : NegativeY;
|
|
public Vector2 Down => whichPlayer == WhichPlayer.Player1 ? NegativeY : PositiveY;
|
|
public Vector2 Left => whichPlayer == WhichPlayer.Player1 ? NegativeX : PositiveX;
|
|
public Vector2 Right => whichPlayer == WhichPlayer.Player1 ? PositiveX : NegativeX;
|
|
public Vector2 UpLeft => whichPlayer == WhichPlayer.Player1 ? PositiveYNegativeX : NegativeYPositiveX;
|
|
public Vector2 UpRight => whichPlayer == WhichPlayer.Player1 ? PositiveYX : NegativeYX;
|
|
public Vector2 DownLeft => whichPlayer == WhichPlayer.Player1 ? NegativeYX : PositiveYX;
|
|
public Vector2 DownRight => whichPlayer == WhichPlayer.Player1 ? NegativeYPositiveX : PositiveYNegativeX;
|
|
public Vector2 KnightLeft => whichPlayer == WhichPlayer.Player1 ? new Vector2(-1, 2) : new Vector2(1, -2);
|
|
public Vector2 KnightRight => whichPlayer == WhichPlayer.Player1 ? new Vector2(1, 2) : new Vector2(-1, -2);
|
|
}
|
|
}
|