Example #1
0
        public Vector2 HexPixel(HexLoc h)
        {
            float x = (or.f0 * h.q + or.f1 * h.r) * size.x;
            float y = (or.f2 * h.q + or.f3 * h.r) * size.y;

            return(new Vector2((float)(x + origin.x), (float)(y + origin.y)));
        }
Example #2
0
        public override bool Equals(Object o)
        {
            if (o.GetType() != typeof(HexLoc))
            {
                return(false);
            }
            HexLoc h = (HexLoc)o;

            return(this == h);
        }
Example #3
0
        public HexLoc Rotate(int steps)
        {
            HexLoc l = this;

            for (int i = 0; i < steps; i++)
            {
                l = l.Rotate60();
            }
            return(l);
        }
Example #4
0
        public             Vector2[] PolygonCorners(HexLoc h)
        {
            Vector2[] corners = new Vector2[6];
            Vector2   center  = HexPixel(h);

            for (int i = 0; i < 6; i++)
            {
                Vector2 offset = CornerOffset(i);
                corners[i] = center + offset;
            }
            return(corners);
        }
Example #5
0
        public static Hex GetHexAtMouse(WorldMap wm)
        {
            Vector3 worldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            HexLoc  l        = GameManager.l.PixelHex(worldPos);

            if (wm.map.ContainsKey(l))
            {
                Hex h = wm.map[l];
                return(h);
            }
            return(null);
        }
Example #6
0
 public int Distance(HexLoc b)
 {
     return((this - b).Length());
 }