示例#1
0
文件: HexPoint.cs 项目: dgulyas/sand
        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);
        }
示例#2
0
文件: HexPoint.cs 项目: dgulyas/sand
        //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);
        }
示例#3
0
文件: HexPoint.cs 项目: dgulyas/sand
 //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));
 }
示例#4
0
文件: HexPoint.cs 项目: dgulyas/sand
 public bool Equals(HexPoint p)
 {
     return(Q == p.Q && R == p.R && S == p.S);
 }
示例#5
0
 public bool PointExists(HexPoint p)
 {
     return(sands.Keys.Contains(p));
 }