Beispiel #1
0
        public GraphicalHex getGraphicalHex(Hex hex)
        {
            GameObject   general  = Instantiate(graphicalHex) as GameObject;
            GraphicalHex specific = general.GetComponent <GraphicalHex>();

            specific.hex   = hex;
            specific.world = hex.map.world;
            specific.map   = hex.map;
            specific.checkData();
            return(specific);
        }
Beispiel #2
0
        public static Vector3 getLoc(GraphicalHex hex)
        {
            float off = 0;

            if (hex.hex.y % 2 == 1)
            {
                off = hexSizeX / 2;
            }
            return(new Vector3(
                       (-(hex.hex.x * hexSizeX) + (x * hexSizeX) + off) * scale,
                       (-(hex.hex.y * hexSizeY) + (y * hexSizeY)) * scale,
                       0
                       ));
        }
Beispiel #3
0
        public static GraphicalHex getHexUnderMouse(Vector3 mousePos)
        {
            float        dist    = 0;
            GraphicalHex closest = null;
            float        minDist = 1000000;

            foreach (GraphicalHex hex in loaded)
            {
                Vector3 line = mousePos - world.outerCamera.WorldToScreenPoint(hex.transform.position);
                dist = line.magnitude;
                if (dist < minDist)
                {
                    minDist = dist;
                    closest = hex;
                }
            }

            return(closest);
        }