Beispiel #1
0
        void HandleSizeChange(object sender, SizeChangedEventArgs args)
        {
            Canvas canvas = GameAreaGrid.FindName("GameArea") as Canvas;

            if (canvas == null)
            {
                throw new Exception("canvas not found");
            }

            var newCanvasWidth = Math.Ceiling(Math.Min(GameAreaGrid.ActualWidth, GameAreaGrid.ActualHeight));

            canvas.Width  = newCanvasWidth;
            canvas.Height = newCanvasWidth;

            GameState.cellWidth = newCanvasWidth / GameState.sideCellCount;
            var cellPosition = new Position();

            for (var y = 0; y < GameState.sideCellCount; y++)
            {
                cellPosition.Y = y;
                for (var x = 0; x < GameState.sideCellCount; x++)
                {
                    cellPosition.X = x;
                    var cellIndex = GameState.grid.GetIndexToCell(ref cellPosition);
                    var cell      = displayCells[cellIndex];
                    cell.Width  = GameState.cellWidth;
                    cell.Height = GameState.cellWidth;

                    Canvas.SetLeft(cell, cellPosition.X * GameState.cellWidth);
                    Canvas.SetTop(cell, cellPosition.Y * GameState.cellWidth);
                }
            }
        }
Beispiel #2
0
    public void Awake()
    {
        startButton = Button.GetComponent <StartButton>();
        grid        = gameAreaGrid.GetComponent <GameAreaGrid>();

        scopeReturns = new Stack <Transform>();

        CreateVarDict();
    }