/// <summary> /// Constructor for hex coords (numbers) /// </summary> public HexagonCell(HexagonalGrid argOwner, int argM = 0, int argR = 0, int argL = 0) { Owner = argOwner; HexCoorinates = new HexagonCoord(argM, argR, argL); //Default initialisation for none-parametrised properties PresentedTile = MapTiles.Grass; InnerAgent = null; }
/// <summary> /// Getting hex coorinates from XY coordinates /// </summary> /// <param name="argX">X coord</param> /// <param name="argY">Y coord</param> /// <param name="argEdgeLenght">Hex edge lenght</param> /// <param name="argShiftVector">Shift vector for XY coords, need for optimisation</param> /// <returns>HexagonCoord: hex coordinates</returns> public static HexagonCoord GetHexCoords(double argX, double argY, double argEdgeLenght, Point argShiftVector) { logger.Trace("Getting hex coords for {0}, {1} with edge lenght {2}", argX, argY, argEdgeLenght); argX += (double)argShiftVector.X; argY += (double)argShiftVector.Y; var result = new HexagonCoord((int)Math.Round(2d / 3d * argY / argEdgeLenght), (int)Math.Round((Math.Sqrt(3) / 3d * argX - argY / 3d) / argEdgeLenght), (int)Math.Round(-(Math.Sqrt(3) / 3d * argX + argY / 3d) / argEdgeLenght)); logger.Trace("Result is {0}", result); return(result); }
/// <summary> /// Constructor for XY coords (class) /// </summary> public HexagonCell(HexagonalGrid argOwner, Point argXYcoords) : this(argOwner, HexagonCoord.GetHexCoords(argXYcoords.X, argXYcoords.Y, argOwner.EdgeLenght, new Point())) { }
/// <summary> /// Constructor for XY coords (numbers) /// </summary> public HexagonCell(HexagonalGrid argOwner, int argX = 0, int argY = 0) : this(argOwner, HexagonCoord.GetHexCoords(argX, argY, argOwner.EdgeLenght, new Point())) { }
/// <summary> /// Constructor for hex coords (class) /// </summary> public HexagonCell(HexagonalGrid argOwner, HexagonCoord argHexCoords) : this(argOwner, argHexCoords.M, argHexCoords.R, argHexCoords.L) { }
public HexagonCell GetCellByXYCoord(int argX, int argY) { var hexCoords = HexagonCoord.GetHexCoords(argX, argY, EdgeLenght, new Point()); return(GetCellByHexCoord(hexCoords.M, hexCoords.R, hexCoords.L)); }