MapCellAndCoords MapCellFromPoint(Vector3 p)
    {
        Vector2 pos2d      = new Vector2(p.x, p.z) / mapScale;
        HexXY   cellCoords = HexXY.FromPlaneCoordinates(pos2d);

        return(new MapCellAndCoords(map.GetCell(cellCoords), cellCoords));
    }
 static Vector2 SampleInsideHex()
 {
     for (; ; )
     {
         Vector2 sample = new Vector2(UnityEngine.Random.Range(-limitX, limitX), UnityEngine.Random.Range(-limitY, limitY));
         if (HexXY.FromPlaneCoordinates(sample) == new HexXY(0, 0))
             return sample;
     }
 }
Esempio n. 3
0
    HexXY getMouseOverTile()
    {
        float dist;
        Ray   ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (G.gamePlane.Raycast(ray, out dist))
        {
            Vector3 inter    = ray.origin + dist * ray.direction;
            Vector2 planePos = new Vector2(inter.x, inter.z);
            return(HexXY.FromPlaneCoordinates(planePos));
        }
        else
        {
            return(new HexXY(0, 0));
        }
    }