Beispiel #1
0
        private void AddWallCap(Vector3 near, Vector3 far)
        {
            near = HexMetrics.Perturb(near);
            far  = HexMetrics.Perturb(far);

            Vector3 center    = HexMetrics.WallLerp(near, far);
            Vector3 thickness = HexMetrics.WallThicknessOffset(near, far);

            Vector3 v1, v2, v3, v4;

            v1   = v3 = center - thickness;
            v2   = v4 = center + thickness;
            v3.y = v4.y = center.y + HexMetrics.wallHeight;
            walls.AddQuadUnperturbed(v1, v2, v3, v4);
        }
        void AddWallSegment(Vector3 nearLeft, Vector3 farLeft, Vector3 nearRight, Vector3 farRight, bool addTower = false)
        {
            nearLeft  = HexMetrics.Perturb(nearLeft);
            farLeft   = HexMetrics.Perturb(farLeft);
            nearRight = HexMetrics.Perturb(nearRight);
            farRight  = HexMetrics.Perturb(farRight);

            Vector3 left  = HexMetrics.WallLerp(nearLeft, farLeft);
            Vector3 right = HexMetrics.WallLerp(nearRight, farRight);

            Vector3 leftThicknessOffset  = HexMetrics.WallThicknessOffset(nearLeft, farLeft);
            Vector3 rightThicknessOffset = HexMetrics.WallThicknessOffset(nearRight, farRight);

            float leftTop  = left.y + HexMetrics.wallHeight;
            float rightTop = right.y + HexMetrics.wallHeight;

            // One side
            Vector3 v1, v2, v3, v4;

            v1   = v3 = left - leftThicknessOffset;
            v2   = v4 = right - rightThicknessOffset;
            v3.y = leftTop;
            v4.y = rightTop;
            walls.AddQuadUnperturbed(v1, v2, v3, v4);

            Vector3 t1 = v3, t2 = v4;

            // The other side
            v1   = v3 = left + leftThicknessOffset;
            v2   = v4 = right + rightThicknessOffset;
            v3.y = leftTop;
            v4.y = rightTop;
            walls.AddQuadUnperturbed(v2, v1, v4, v3);

            // The top
            walls.AddQuadUnperturbed(t1, t2, v3, v4);

            if (addTower)
            {
                Transform towerInstance = Instantiate(wallTower);
                towerInstance.transform.localPosition = (left + right) * 0.5f;
                Vector3 rightDirection = right - left;
                rightDirection.y = 0f;
                towerInstance.transform.right = rightDirection;
                towerInstance.SetParent(container, false);
            }
        }
Beispiel #3
0
        private void AddWallWedge(Vector3 near, Vector3 far, Vector3 point)
        {
            near  = HexMetrics.Perturb(near);
            far   = HexMetrics.Perturb(far);
            point = HexMetrics.Perturb(point);

            Vector3 center    = HexMetrics.WallLerp(near, far);
            Vector3 thickness = HexMetrics.WallThicknessOffset(near, far);

            Vector3 v1, v2, v3, v4;
            Vector3 pointTop = point;

            point.y = center.y;

            v1   = v3 = center - thickness;
            v2   = v4 = center + thickness;
            v3.y = v4.y = pointTop.y = center.y + HexMetrics.wallHeight;
            walls.AddQuadUnperturbed(v1, point, v3, pointTop);
            walls.AddQuadUnperturbed(point, v2, pointTop, v4);
            walls.AddTriangleUnperturbed(pointTop, v3, v4);
        }