示例#1
0
        private void Triangulate(HexagonCell cell)
        {
            Vector3 center = cell.transform.localPosition;

            for (int i = 0; i < 6; i++)
            {
                AddTriangle(
                    center,
                    center + HexagonCell.Corners[i],
                    center + HexagonCell.Corners[i + 1]
                    );
            }
        }
示例#2
0
        private void CreateCell(int x, int z, int i)
        {
            var position = new Vector3()
            {
                x = (x + z * 0.5f - z / 2) * (HexagonCell.InnerRadius * 2f),
                y = 0f,
                z = z * (HexagonCell.OuterRadius * 1.5f)
            };

            HexagonCell cell = m_Cells[i] = Instantiate <HexagonCell>(CellPrefab);

            cell.transform.SetParent(transform, false);
            cell.transform.localPosition = position;
            cell.Coordinates             = HexagonCoordinates.FromOffsetCoordinates(x, z);

            // debug display
            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();
        }