Beispiel #1
0
        private void ButtonReset_Click(Object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < FieldSquare.GetLength(0); ++i)
            {
                for (int j = 0; j < FieldSquare.GetLength(1); ++j)
                {
                    FieldSquare[i, j].ButtonSquare.IsEnabled = true;
                    FieldSquare[i, j].IsPartOfSum            = false;
                    FieldSquare[i, j].Background             = new SolidColorBrush(Colors.AliceBlue);
                }
            }

            TextBlockSumma.Text = "Сумма =";
            _count = 0;
        }
Beispiel #2
0
    /// <summary>
    /// Draw field. Need saved screen position.
    /// </summary>
    void DrawField()
    {
        var heightInWorldPoint = Mathf.Abs(screenBottom) + Mathf.Abs(screenTop);

        //Drawing horizontal lines
        var startPoint = new Vector2(screenLeft, screenTop);
        var endPoint   = new Vector2(screenLeft + heightInWorldPoint, screenTop);

        while (startPoint.y >= screenBottom)
        {
            lineFactory.GetLine(startPoint, endPoint, drawingLineWidth, drawingLineColor);
            startPoint.y -= drawingLineStep;
            endPoint.y   -= drawingLineStep;
        }

        //Drawing vertical lines and create field[,]
        startPoint.x = screenLeft;
        startPoint.y = screenTop;
        endPoint.x   = screenLeft;
        endPoint.y   = screenBottom;

        var countHorizontalLine = lineFactory.GetActive().Count;

        field = new FieldSquare[countHorizontalLine - 1, countHorizontalLine - 1];

        for (var i = 0; i < countHorizontalLine; i++)
        {
            lineFactory.GetLine(startPoint, endPoint, drawingLineWidth, drawingLineColor);
            startPoint.x += drawingLineStep;
            endPoint.x   += drawingLineStep;

            if (i == countHorizontalLine - 1)
            {
                break; //Last line. Doesn't need spawn squares
            }
            //Create square of field
            //1)Down half of drawingStep
            var spawnPositionForSquare = new Vector2(startPoint.x - 0.5f * drawingLineStep, startPoint.y - 0.5f * drawingLineStep);
            //2) And spawn
            for (var j = 0; j < countHorizontalLine - 1; j++)
            {
                var square = Instantiate(squareOfField, spawnPositionForSquare, Quaternion.identity, this.transform);
                field[i, j] = new FieldSquare(square.GetComponent <SpriteRenderer>());

                spawnPositionForSquare.y -= drawingLineStep;
            }
        }
    }