private GameObject _buildingObject;  // TODO: Remove it while finalizing- Risul

        public void GenerateBlocks()         //
        {
            _buildingLength = modularBuildingInput.BuildingLength;
            _buildingHeight = modularBuildingInput.BuildingHeight;
            _buildingDepth  = modularBuildingInput.BuildingDepth;
            _heightCurve    = modularBuildingInput.HeightCurve;

            // Get the blocks
            var blockSymbols = _modularRulesGenerator.GetBlockSymbols(_buildingLength, _buildingHeight, _buildingDepth, _heightCurve, _modularFootprintGenerator);

            _buildingObject = new GameObject($"Building X_{DateTime.UtcNow}");
            _buildingObject.transform.position = Vector3.zero;

            _building = new BuildingBlock[_buildingLength, _buildingHeight, _buildingDepth];
            for (var j = 0; j < _buildingHeight; j++)
            {
                for (var i = 0; i < _buildingLength; i++)
                {
                    for (var k = 0; k < _buildingDepth; k++)
                    {
                        var buildingBlock = _buildingBlockContainer.GetBlock(blockSymbols[i, j, k], _buildingObject.transform);
                        buildingBlock.CalculateDimension();
                        _building[i, j, k]           = buildingBlock;
                        _building[i, j, k].BlockName = $"{j}-{i}-{k}";
                    }
                }
            }
        }
Пример #2
0
        public void CreateRoof(int i, int j, int k, Vector3 blockPosition)
        {
            var isDepthBlock = false;
            var roofBlock    = _buildingBlockContainer.GetBlock(_building[i, j, k].BlockType.GetRoofName(), _buildingObject.transform);

            // Depth and Depth Double
            if (_building[i, j, k].BlockType.Contains(BlockSymbol.DepthLeft) || _building[i, j, k].BlockType.Contains(BlockSymbol.DepthDouble))             // For DepthLeft
            {
                isDepthBlock = true;
            }

            if (roofBlock == null)
            {
                throw new NotImplementedException("The Block is not set for roof.. Add roof book in BlockSymbol class");
            }

            roofBlock.CalculateDimension();
            var position = blockPosition;
            var scale    = roofBlock.transform.localScale;

            position.y += roofBlock.Dimension.Height;
            if (isDepthBlock)             // Extra roof placement calculation for Depth Roof Blocks.. can it be fixed later ?? TODO: Show Tom- Risul
            {
                position.x += roofBlock.Dimension.Width / 2;
                position.z -= roofBlock.Dimension.Width / 2;
            }

            if (_building[i, j, k].VerticalMirror)
            {
                position.z -= roofBlock.Dimension.Depth;
                scale.z     = -1;
            }

            if (_building[i, j, k].HorizontalMirror)
            {
                if (isDepthBlock
                    )             // Calculate Horizontal mirror differently // Extra roof placement calculation for Depth Roof Blocks.. can it be fixed later ?? TODO: Show Tom- Risul
                {
                    position.x -= roofBlock.Dimension.Width;
                    scale.z     = -1;
                }
                else
                {
                    scale.x = -1;
                }
            }

            roofBlock.transform.localScale = scale;
            roofBlock.transform.position   = position;
        }