Пример #1
0
        public void GenerateWalls(Vector3 position)
        {
            var walls    = Grid.GetWalls();
            var doorBase = position;

            doorBase.x += XSize / 2f;
            var wall = walls.FirstOrDefault(x => x.transform.position.Equals(doorBase));

            Grid.AddTile(wall);
            doorBase.x += 1;
            Grid.AddTile(walls.FirstOrDefault(x => x.transform.position.Equals(doorBase)));
            doorBase.x -= 2;
            Grid.AddTile(walls.FirstOrDefault(x => x.transform.position.Equals(doorBase)));
            for (int h = 1; h < 5; h++)
            {
                for (int x = 0; x < XSize; x++)
                {
                    var blockPosition = position;
                    blockPosition.x += x;
                    blockPosition.z += ZSize;
                    blockPosition.y += h;
                    Instantiate(Block, blockPosition, Quaternion.identity, transform);
                }
                for (int x = 0; x < XSize; x++)
                {
                    var blockPosition = position;
                    blockPosition.x += x;
                    blockPosition.y += h;
                    if (x != XSize / 2 && x != XSize / 2 + 1 && x != XSize / 2 - 1 || h > 3)
                    {
                        Instantiate(Block, blockPosition, Quaternion.identity, transform);
                    }
                    else
                    {
                        Grid.RemoveTile(blockPosition);
                    }
                }

                for (int z = 0; z < ZSize; z++)
                {
                    var blockPosition = position;
                    blockPosition.z += z;
                    blockPosition.y += h;
                    Instantiate(Block, blockPosition, Quaternion.identity, transform);
                }
                for (int z = 0; z < ZSize; z++)
                {
                    var blockPosition = position;
                    blockPosition.x += XSize;
                    blockPosition.z += z;
                    blockPosition.y += h;
                    Instantiate(Block, blockPosition, Quaternion.identity, transform);
                }
            }
        }