Beispiel #1
0
        public static OffsetCoordinates FromAxial(AxialCoordinates axial)
        {
            // Bitwise AND (& 1) to get 0 for even or 1 for odd column offset
            var col = axial.X + (axial.Z - (axial.Z & 1)) / 2;
            var row = axial.Z;

            return(new OffsetCoordinates(col: col, row: row));
        }
Beispiel #2
0
        public static CubicCoordinates FromAxial(AxialCoordinates axial)
        {
            var y = -1 * (axial.X + axial.Z);

            return(new CubicCoordinates(
                       x: axial.X,
                       y: y,
                       z: axial.Z
                       ));
        }
Beispiel #3
0
 public bool Equals(AxialCoordinates value)
 {
     if (value == null)
     {
         return(false);
     }
     return(
         X == value.X &&
         Z == value.Z
         );
 }
Beispiel #4
0
 public bool EqualsCubic(CubicCoordinates cubic) =>
 AxialCoordinates
 .FromCubic(cubic)
 .Equals(this);
Beispiel #5
0
 public static AxialCoordinates FromOffset(OffsetCoordinates offset) =>
 AxialCoordinates.FromCubic(
     CubicCoordinates.FromOffset(offset)
     );
Beispiel #6
0
 public AxialCoordinates ToAxial() => AxialCoordinates.FromOffset(this);
Beispiel #7
0
 public static OffsetCoordinates FromCubic(CubicCoordinates cubic) =>
 OffsetCoordinates.FromAxial(
     AxialCoordinates.FromCubic(cubic)
     );
Beispiel #8
0
 public AxialCoordinates ToAxial() => AxialCoordinates.FromCubic(this);
Beispiel #9
0
 public bool EqualsAxial(AxialCoordinates axial) =>
 CubicCoordinates
 .FromAxial(axial)
 .Equals(this);