public static List <HexPoint> GetNeighbours(HexPoint p) { //These are all the hexes touching p //return HexRing(p, 1); //Lets do something faster then using the HexRing function var neighbours = new List <HexPoint>(6); foreach (var direction in HexDirection) { neighbours.Add(p + direction); } return(neighbours); }
//returns a list of hex coords that form a ring at radius around p public static List <HexPoint> HexRing(HexPoint p, int radius) { if (radius < 1) { return(new List <HexPoint>()); } var hexInRing = new List <HexPoint>(); var currPoint = p + HexScale(HexDirection[4], radius); for (int i = 0; i < 6; i++) { for (int j = 0; j < radius; j++) { hexInRing.Add(currPoint); currPoint += HexDirection[i]; } } return(hexInRing); }
//Multiplies the coordinates of a point by integer i public static HexPoint HexScale(HexPoint p, int i) { return(new HexPoint(p.Q * i, p.R * i, p.S * i)); }
public bool Equals(HexPoint p) { return(Q == p.Q && R == p.R && S == p.S); }
public bool PointExists(HexPoint p) { return(sands.Keys.Contains(p)); }