Working through some localization stuff will probably be pretty fluid.
This commit is contained in:
2020-12-14 16:08:59 -07:00
parent 2c5f0b73b9
commit d63066c150
19 changed files with 199 additions and 258 deletions

View File

@@ -1,35 +1,49 @@
using System.Net.NetworkInformation;
namespace ConsoleApp.Maps
{
public class Oreientation
{
public static (int, int) Forward = (0, 1);
public static (int, int) Backward = (0, -1);
public static (int, int) Left = (-1, 0);
public static (int, int) Right = (1, 0);
public static (int, int) LeftBack = (-1, -1);
public static (int, int) LeftForward = (-1, 1);
public static (int, int) RightBack = (1, -1);
public static (int, int) RightForward = (1, 1);
}
public class Heading
{
private (int, int) _currentHeading;
public (int, int) CurrentHeading { get; }
public void SetHeading((int,int)frontAxel, (int,int)backAxel)
{
var x = frontAxel.Item1 - backAxel.Item1;
var y = frontAxel.Item2 - backAxel.Item2;
//forward
if (x == 0 && y >= 1) _currentHeading = (0, 1);
if (x == 0 && y >= 1) _currentHeading = Oreientation.Forward;
//backward
if (x == 0 && y <= -1) _currentHeading = (0, -1);
if (x == 0 && y <= -1) _currentHeading = Oreientation.Backward;
//right
if (x >= 1 && y == 0) _currentHeading = (1, 0);
if (x >= 1 && y == 0) _currentHeading = Oreientation.Right;
//left
if (x <= -1 && y == 0) _currentHeading = (-1, 0);
if (x <= -1 && y == 0) _currentHeading = Oreientation.Left;
//left, back
if (x <= -1 && y <= -1) _currentHeading = (-1, -1);
if (x <= -1 && y <= -1) _currentHeading = Oreientation.LeftBack;
//right, forward
if (x >= 1 && y >= 1) _currentHeading = (1, 1);
if (x >= 1 && y >= 1) _currentHeading = Oreientation.RightForward;
//left, forward
if (x <= -1 && y >= 1) _currentHeading = (-1, 1);
if (x <= -1 && y >= 1) _currentHeading = Oreientation.LeftForward;
//right, back
if (x >= 1 && y <= -1) _currentHeading = (1, -1);
if (x >= 1 && y <= -1) _currentHeading = Oreientation.RightBack;
}
public Heading()
{
_currentHeading = (1,0);
_currentHeading = Oreientation.Forward;
CurrentHeading = _currentHeading;
}