void CreateCell(int x, int z, int i) { Vector3 position; position.x = (x + z * 0.5f - z / 2) * (HexagonGridGen.innerRadius * 2f); position.y = 0f; position.z = z * (HexagonGridGen.outerRadius * 1.5f); HexagonCellGen cell = cells[i] = Instantiate <HexagonCellGen>(hexPrefab); cell.transform.SetParent(transform, false); cell.transform.localPosition = position; cell.coordinates = Hexcoords.FromOffsetCoordinates(x, z); /* * Text label = Instantiate<Text>(cellLabelPrefab); * label.rectTransform.SetParent(gridCanvas.transform, false); * label.rectTransform.anchoredPosition = * new Vector2(position.x, position.z); * label.text = cell.coordinates.ToStringOnSeparateLines(); */ GameObject platform = Instantiate(HexagonPlatform); platform.transform.SetParent(transform, false); platform.transform.localPosition = position; platform.transform.rotation = Quaternion.Euler(0, 30, 0); platform.transform.localPosition = new Vector3(platform.transform.position.x, RndRange(heightmod), platform.transform.position.z); HeightCheck(platform); }
void Triangulate(HexagonCellGen cell) { Vector3 center = cell.transform.localPosition; for (int i = 0; i < 6; i++) { AddTriangle( center, center + HexagonGridGen.corners[i], center + HexagonGridGen.corners[i + 1] ); } }