Exemple #1
0
        public void Init(SquarePoint startPoint, SquareBaseShape shape)
        {
            if (startPoint == SquarePoint.Center)
            {
                throw new ArgumentException("start point can't be Center");
            }

            if (shape == SquareBaseShape.Triangle)
            {
                points = CreateTriangle(startPoint);
            }
            else if (shape == SquareBaseShape.Square)
            {
                points = CreateSquare(startPoint);
            }
            else if (shape == SquareBaseShape.Pie)
            {
                points = CreatePie(startPoint);
            }
            else if (shape == SquareBaseShape.Empty)
            {
                points = new List <SquarePoint> ();
            }
            else
            {
                throw new ArgumentException(string.Format("unknown shape '{0}'", shape));
            }

            Build();
        }
Exemple #2
0
        void AnalizeInternalTriagle(Buffer <int> buffer, Square square, int x, int y, float moveVertextToCorner = 0.3f)
        {
            SquarePoint     startPoint = SquarePoint.Center;
            SquareBaseShape shape      = SquareBaseShape.Triangle;

            int value;

            if (buffer.Get(x, y - 1, out value) && value >= DefaultValue && buffer.Get(x + 1, y, out value) && value >= DefaultValue)
            {
                startPoint = SquarePoint.BottomRight;
                square.Init(startPoint, shape);
                var point1       = SquarePoint.BottomLeft;
                var point2       = SquarePoint.TopRight;
                var pointOffset1 = Vector3.right * moveVertextToCorner;
                var pointOffset2 = Vector3.down * moveVertextToCorner;
                var pointPos1    = square.GetAbsolutePosition(point1) + pointOffset1;
                var pointPos2    = square.GetAbsolutePosition(point2) + pointOffset2;
                square.GetNode(point1).Vertex.Pos.x = pointPos1.x;
                square.GetNode(point2).Vertex.Pos.y = pointPos2.y;
            }

            if (buffer.Get(x, y + 1, out value) && value >= DefaultValue && buffer.Get(x - 1, y, out value) && value >= DefaultValue)
            {
                startPoint = SquarePoint.TopLeft;
                square.Init(startPoint, shape);
                var point1       = SquarePoint.BottomLeft;
                var point2       = SquarePoint.TopRight;
                var pointOffset1 = Vector3.up * moveVertextToCorner;
                var pointOffset2 = Vector3.left * moveVertextToCorner;
                var pointPos1    = square.GetAbsolutePosition(point1) + pointOffset1;
                var pointPos2    = square.GetAbsolutePosition(point2) + pointOffset2;
                square.GetNode(point1).Vertex.Pos.y = pointPos1.y;
                square.GetNode(point2).Vertex.Pos.x = pointPos2.x;
            }

            if (buffer.Get(x, y - 1, out value) && value >= DefaultValue && buffer.Get(x - 1, y, out value) && value >= DefaultValue)
            {
                startPoint = SquarePoint.BottomLeft;
                square.Init(startPoint, shape);
                var point1       = SquarePoint.TopLeft;
                var point2       = SquarePoint.BottomRight;
                var pointOffset1 = Vector3.down * moveVertextToCorner;
                var pointOffset2 = Vector3.left * moveVertextToCorner;
                var pointPos1    = square.GetAbsolutePosition(point1) + pointOffset1;
                var pointPos2    = square.GetAbsolutePosition(point2) + pointOffset2;
                square.GetNode(point1).Vertex.Pos.y = pointPos1.y;
                square.GetNode(point2).Vertex.Pos.x = pointPos2.x;
            }

            if (buffer.Get(x, y + 1, out value) && value >= DefaultValue && buffer.Get(x + 1, y, out value) && value >= DefaultValue)
            {
                startPoint = SquarePoint.TopRight;
                square.Init(startPoint, shape);
                var point1       = SquarePoint.TopLeft;
                var point2       = SquarePoint.BottomRight;
                var pointOffset1 = Vector3.right * moveVertextToCorner;
                var pointOffset2 = Vector3.up * moveVertextToCorner;
                var pointPos1    = square.GetAbsolutePosition(point1) + pointOffset1;
                var pointPos2    = square.GetAbsolutePosition(point2) + pointOffset2;
                square.GetNode(point1).Vertex.Pos.x = pointPos1.x;
                square.GetNode(point2).Vertex.Pos.y = pointPos2.y;
            }
        }