Beispiel #1
0
    public Cell(CornerNode topLeft, CornerNode topRight, CornerNode bottomLeft, CornerNode bottomRight)
    {
        this.topLeft     = topLeft;
        this.topRight    = topRight;
        this.bottomLeft  = bottomLeft;
        this.bottomRight = bottomRight;

        midLeft   = this.bottomLeft.Vertical;
        midTop    = this.topLeft.Horizontal;
        midRight  = this.bottomRight.Vertical;
        midBottom = this.bottomLeft.Horizontal;

        if (bottomLeft.IsOn)
        {
            configValue += BottomLeftActiveValue;
        }
        if (bottomRight.IsOn)
        {
            configValue += BottomRightActiveValue;
        }
        if (topRight.IsOn)
        {
            configValue += TopRightActiveValue;
        }
        if (TopLeft.IsOn)
        {
            configValue += TopLeftActiveValue;
        }
    }
        public Square(CornerNode topLeft, CornerNode topRight, CornerNode botRight, CornerNode botLeft)
        {
            this.topLeft  = topLeft;
            this.topRight = topRight;
            this.botLeft  = botLeft;
            this.botRight = botRight;

            this.topCent   = topLeft.posX;
            this.leftCent  = botLeft.posZ;
            this.rightCent = botRight.posZ;
            this.botCent   = botLeft.posX;

            cellType = 0;
            if (topLeft.state)
            {
                cellType |= 8;
            }
            if (topRight.state)
            {
                cellType |= 4;
            }
            if (botRight.state)
            {
                cellType |= 2;
            }
            if (botLeft.state)
            {
                cellType |= 1;
            }
        }
        public SquareGrid(int[,] map, float squareSize, int wallSize)
        {
            int mapX = map.GetLength(0);
            int mapZ = map.GetLength(1);

            // Build all the corner nodes
            CornerNode[,] cornerNodes = new CornerNode[mapX, mapZ];
            for (int x = 0; x < mapX; x++)
            {
                for (int z = 0; z < mapZ; z++)
                {
                    float xPos = -(mapX * squareSize) / 2 + x * squareSize;
                    float zPos = -(mapZ * squareSize) / 2 + z * squareSize;
                    // Set the state of the corner node to be true if there is a wall on the map
                    cornerNodes[x, z] = new CornerNode(new Vector3(xPos, wallSize, zPos), map[x, z] == 1, squareSize);
                }
            }
            // Build the squares onto the grid
            // The number of squares is 1 less in both directions
            grid = new Square[mapX - 1, mapZ - 1];
            // Note that this grid is iterating through, starting from the bottom left
            for (int x = 0; x < mapX - 1; x++)
            {
                for (int z = 0; z < mapZ - 1; z++)
                {
                    grid[x, z] = new Square(cornerNodes[x, z + 1],
                                            cornerNodes[x + 1, z + 1],
                                            cornerNodes[x + 1, z],
                                            cornerNodes[x, z]);
                }
            }
        }
Beispiel #4
0
    public void SaveJson()
    {
        JsonData jd = new JsonData();

        JsonData Arr = new JsonData();


        foreach (RawImageWarp item in rawImageWarps)
        {
            CornerNode cornerNode = new CornerNode(item.cornerOffsetTL, item.cornerOffsetTR, item.cornerOffsetBR, item.cornerOffsetBL);
            BezierNode bezierNode = new BezierNode(true, item.topBezierHandleA, item.topBezierHandleB, item.leftBezierHandleA, item.leftBezierHandleB, item.rightBezierHandleA, item.rightBezierHandleB, item.bottomBezierHandleA, item.bottomBezierHandleB);

            Display temp = new Display(rawImageWarps.IndexOf(item) + 1, cornerNode, bezierNode);

            Arr.Add(ConvertClassToJsonData(temp));
        }
        jd["Display"] = Arr;//标题

        JsonData data = new JsonData();

        data["info"] = jd;//大分类

        string json = data.ToJson();

        List <string> tempJsonStringArray = new List <string>();

        tempJsonStringArray.Add(json);

        UpdateJson(tempJsonStringArray.ToArray());
    }
Beispiel #5
0
    private CornerNode[,] GetCornerNodes(int[,] statesMap, float cellSize)
    {
        int   rowCount    = statesMap.GetLength(0);
        int   columnCount = statesMap.GetLength(1);
        float gridWidth   = rowCount * cellSize;
        float gridHeight  = columnCount * cellSize;

        CornerNode[,] cornerNodes = new CornerNode[rowCount, columnCount];

        for (int row = 0; row < rowCount; row++)
        {
            for (int col = 0; col < columnCount; col++)
            {
                Vector3 pos  = new Vector3(-gridWidth / 2 + row * cellSize / 2, 0, -gridHeight / 2 + col * cellSize + cellSize / 2);
                bool    isOn = (statesMap[row, col] == CaveGeneratorUtilities.DataConstants.Wall);
                cornerNodes[row, col] = new CornerNode(pos, isOn, cellSize);
            } // end for
        }     // end for

        return(cornerNodes);
    }
Beispiel #6
0
 public Display(int _index, CornerNode _cornerNode, BezierNode _bezierNodes)
 {
     index       = _index;
     cornerNode  = _cornerNode;
     bezierNodes = _bezierNodes;
 }