예제 #1
0
    // Reads in all information of a facade
    public List <Rectangle> initializeNewFacade(InputFacade facade)
    {
        allCurrentFacadeRectangles = RegionFinder.findRectangles(facade.facadeLayoutName, facade.inputFacade.width, facade.inputFacade.height);
        float maxY = 0; float maxX = 0;

        foreach (Color c in allCurrentFacadeRectangles.Keys)
        {
            foreach (Rectangle r in allCurrentFacadeRectangles[c])
            {
                maxX = Mathf.Max(maxX, r.toX);
                maxY = Mathf.Max(maxY, r.toY);
            }
        }

        buildingNameText.text = facade.gameObject.name;
        widthText.text        = facade.getBuildingWidth().ToString();
        heightText.text       = facade.getBuildingHeight().ToString();
        Vector3 previewScale = facadePreview.rectTransform.localScale;

        facadePreview.rectTransform.localScale = new Vector3(previewScale.y * facade.getBuildingWidth() / facade.getBuildingHeight(), previewScale.y, 1);
        layoutPreview.rectTransform.localScale = facadePreview.rectTransform.localScale;
        foreach (Color c in allCurrentFacadeRectangles.Keys)
        {
            Rectangle newRect = new Rectangle();
            newRect.symbol = c;
            currentFacadeRectangles.Enqueue(newRect);
        }
        return(null);
    }
예제 #2
0
    // Creates and returns the string that defines the size and shapes of that the rule splits into
    public string createShapeSplitString(List <Region> shapes, string axis, InputFacade inputF)
    {
        string splitString = " {";
        // Get width/height in pixels of the input facade depending on which axis we are working on
        int facadeLength = (axis == "X") ? inputF.inputFacade.width : inputF.inputFacade.height;
        // Get self defined height and length of building
        float buildingSize = (axis == "X") ? inputF.getBuildingWidth() : inputF.getBuildingHeight();

        for (int i = 0; i < shapes.Count; i++)
        {
            Region subarea   = shapes[i];
            float  size      = (axis == "X") ? (subarea.toX - subarea.fromX) * 1f / facadeLength : (subarea.toY - subarea.fromY) * 1f / facadeLength;
            string shapeName = getRegionName(subarea, inputF.gameObject.name);
            string relative  = (relativeRegions.Contains(shapeName)) ? "N" : "";
            splitString += size * buildingSize + relative + ": " + shapeName;

            if (i < shapes.Count - 1)
            {
                splitString += " | ";
            }
        }
        splitString += "}";
        return(splitString);
    }