예제 #1
0
    public void ComputeRoomDimensionsBasisImageList(ImageBank imageBank, double unitWidth)
    {
        //Compute the total perimeter needed
        ImageContainer t = imageList;
        double         totalPerimeterNeeded       = 0;
        double         largestImageContainerWidth = 0;

        while (t != null)
        {
            totalPerimeterNeeded += t.getWidth();
            if (t.getWidth() > largestImageContainerWidth)
            {
                largestImageContainerWidth = t.getWidth();
            }
            t = t.getNext();
        }


        // 3 units will be reserved for the opening
        if (largestImageContainerWidth < 3 * unitWidth)
        {
            largestImageContainerWidth = 3 * unitWidth;
        }
        int p = Units(totalPerimeterNeeded + 3 * unitWidth, unitWidth);
        int l = Units(largestImageContainerWidth, unitWidth);

        bool randomizeWidth = (Random.value > 0.5);
        int  min            = 6;
        int  max            = 12;

        if (randomizeWidth)
        {
            width  = Random.Range(l, LargestWidth + 1);
            height = (p - 2 * width) / 2 + Random.Range(min, max);
            if (height < min)
            {
                height = min;
            }
        }
        else
        {
            height = Random.Range(l, LargestWidth + 1);
            width  = (p - 2 * height) / 2 + Random.Range(min, max);
            if (width < min)
            {
                width = min;
            }
        }

        if (width < min || height < min)
        {
            Debug.Log("wrong dimension");
        }
    }
예제 #2
0
    public ImageContainer PopImageContainers(int n)
    {
        ImageContainer t          = top;
        ImageContainer popStart   = null;
        ImageContainer lastPopped = null;
        int            i          = 0;

        while (t != null && i++ < n)
        {
            if (lastPopped == null)
            {
                popStart = t;
            }
            lastPopped = t;
            //they are already linked so ne need to link them again
            //just move the top down
            top = top.getNext();
            //reduce the total perimeter in the image bank
            this.perimeter -= t.getWidth();
            this.totalContainers--;
            t = t.getNext();
        }
        if (lastPopped != null)
        {
            lastPopped.setNext(null);            //to terminate the list
        }
        return(popStart);
    }
예제 #3
0
    private int MakeImageContainerListAndComputePerimeter(Album album)
    {
        int total = 0;
//		ImageContainer top=null;
        ImageContainer last = null;

        this.perimeter = 0;
        for (int i = 0; i < album.photoList.Length; i++)
        {
            Photo          photo            = album.photoList[i];
            double         normalizedWidth  = (photo.width / this.largestWidthOfAPhoto) * maxWidth;
            double         normalizedHeight = (photo.width / this.largestHeightOfAPhoto) * maxHeight;
            ImageContainer imageContainer   = new ImageContainer(photo, normalizedWidth, normalizedHeight);

            if (last == null)
            {
                top = imageContainer;
            }
            else
            {
                last.setNext(imageContainer);
            }
            last = imageContainer;
            total++;
            this.perimeter += imageContainer.getWidth();
        }
        return(total);
    }