Esempio n. 1
0
    public void SetNeighbours(MapBlock block, Vector3Int tablePos)
    {
        mapTable[tablePos.x, tablePos.y, tablePos.z] = block;
        MapBlock up    = GetBlockAt(mapTable, tablePos.x, tablePos.y, tablePos.z + 1);
        MapBlock down  = GetBlockAt(mapTable, tablePos.x, tablePos.y, tablePos.z - 1);
        MapBlock front = GetBlockAt(mapTable, tablePos.x, tablePos.y - 1, tablePos.z);
        MapBlock back  = GetBlockAt(mapTable, tablePos.x, tablePos.y + 1, tablePos.z);
        MapBlock left  = GetBlockAt(mapTable, tablePos.x - 1, tablePos.y, tablePos.z);
        MapBlock right = GetBlockAt(mapTable, tablePos.x + 1, tablePos.y, tablePos.z);

        block.neighbours = new MapBlock.Neighbours(block, up, down, front, back, left, right);
        block.CalculateVisibility();
    }
Esempio n. 2
0
        public Neighbours(MapBlock me, MapBlock up, MapBlock down, MapBlock front, MapBlock back, MapBlock left, MapBlock right)
        {
            this.up = up;
            if (up != null)
            {
                up.neighbours.down = me;
                up.CalculateVisibility();
            }

            this.down = down;
            if (down != null)
            {
                down.neighbours.up = me;
                down.CalculateVisibility();
            }

            this.front = front;
            if (front != null)
            {
                front.neighbours.back = me;
                front.CalculateVisibility();
            }

            this.back = back;
            if (back != null)
            {
                back.neighbours.front = me;
                back.CalculateVisibility();
            }

            this.left = left;
            if (left != null)
            {
                left.neighbours.right = me;
                left.CalculateVisibility();
            }

            this.right = right;
            if (right != null)
            {
                right.neighbours.left = me;
                right.CalculateVisibility();
            }
        }