public Square(ControlNode topLeft, ControlNode topRight, ControlNode bottomRight, ControlNode bottomLeft, Vector3 position = default(Vector3))
        {
            this.position = position;

            TopLeft     = topLeft;
            TopRight    = topRight;
            BottomRight = bottomRight;
            BottomLeft  = bottomLeft;

            TopCenter    = topLeft.nodeRight;
            RightCenter  = bottomRight.nodeUp;
            BottomCenter = bottomLeft.nodeRight;
            LeftCenter   = bottomLeft.nodeUp;

            vertexIndex = -1;

            configuration = topLeft.value | (topRight.value << 1) | (bottomRight.value << 2) | (bottomLeft.value << 3);
        }
Exemplo n.º 2
0
        public SquareGrid(Map map)
        {
            squares = new Square[map.width - 1, map.height - 1];

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    float xPos = map.GetPosition(x, y).x + 0.5f;
                    float yPos = map.GetPosition(x, y).y + 0.5f;

                    ControlNode topLeft     = new ControlNode(map.GetPosition(x, y + 1), map.GetValue(x, y + 1));
                    ControlNode topRight    = new ControlNode(map.GetPosition(x + 1, y + 1), map.GetValue(x + 1, y + 1));
                    ControlNode bottomRight = new ControlNode(map.GetPosition(x + 1, y), map.GetValue(x + 1, y));
                    ControlNode bottomLeft  = new ControlNode(map.GetPosition(x, y), map.GetValue(x, y));

                    Vector3 position = new Vector3(xPos, yPos, 0);

                    squares [x, y] = new Square(topLeft, topRight, bottomRight, bottomLeft, position);
                }
            }
        }