public bool IsWithinGridBoundary(HexCoordinates coords) { var pos = HexCoordinates.ToPosition(coords); return(Mathf.Abs(pos.x) < boardHalfSizeWorldUnits.x && Mathf.Abs(pos.z) < boardHalfSizeWorldUnits.z); }
public void ScrollTo(HexCoordinates coords) { var pos = HexCoordinates.ToPosition(coords); pos.y = transform.position.y; pos.z -= 5f; // TODO lerp camTf.position = pos; }
public Vector3 GetBoardLimitsInWorldUnits() { var lengthCoord = new HexCoordinates(boardHalfSize.x, 0); var heightCoord = new HexCoordinates(0, boardHalfSize.y); var lengthPos = HexCoordinates.ToPosition(lengthCoord); var heightPos = HexCoordinates.ToPosition(heightCoord); return(new Vector3(lengthPos.x, 0f, heightPos.z)); }
private void ShowIndicatorGrid(List <HexCoordinates> coords, Color color) { var indicators = GetPlacementIndicators(coords.Count); for (int i = 0; i < coords.Count; i++) { indicators[i].transform.position = HexCoordinates.ToPosition(coords[i]); var mr = indicators[i].GetComponentInChildren <MeshRenderer>(); mr.material.color = color; } }
private HexCoordinates ShowPositionHandles(HexCoordinates coords, int player) { var pos = HexCoordinates.ToPosition(coords); Handles.color = Color.black; Handles.DrawSolidDisc(pos, Vector3.up, 1f); Handles.color = player == 1 ? Color.white : Color.black; Handles.DrawSolidDisc(pos, Vector3.up, 0.9f); var newPos = Handles.PositionHandle(pos, Quaternion.identity); var newCoord = HexCoordinates.FromPosition(newPos); return(newCoord); }
private static List <Vector3> ConstructPath(PathCell target, int maxDistance) { var path = new Stack <Vector3>(); var cell = target; while (cell != null) { if (path.Count - 1 >= maxDistance) { return(null); } path.Push(HexCoordinates.ToPosition(cell.X, cell.Z)); cell = cell.PreviousCell; } return(path.ToList()); }
public void SetCoordinates(HexCoordinates coords) { Coordinates = coords; transform.position = HexCoordinates.ToPosition(coords); }