Esempio n. 1
0
        public ScreenTileHelper(Size boardSize, Size screenSize, SizeF gapRatio, int marginLeft, int marginRight, int marginTop, int marginBottom)
        {
            topLeft        = new Point(marginLeft, marginTop);
            totalPixelSize = new Size(screenSize.Width - marginLeft - marginRight, screenSize.Height - marginTop - marginBottom);
            lowerRght      = new Point(topLeft.X + totalPixelSize.Width, topLeft.Y + totalPixelSize.Height);

            float gap, tile;

            GameHelpers.findSpacingDistanceForGrid(marginLeft, marginRight, boardSize.Width, totalPixelSize.Width, gapRatio.Width, out tile, out gap);
            gapSize.Width  = gap;
            tileSize.Width = tile;
            GameHelpers.findSpacingDistanceForGrid(marginTop, marginBottom, boardSize.Height, totalPixelSize.Height, gapRatio.Height, out tile, out gap);
            gapSize.Height  = gap;
            tileSize.Height = tile;
            //tileFont = GameHelpers.fontSizer.generateGameFont((int)tileSize.Height, FontStyle.Regular);
            tileFont = FontFactory.GetFontByTotalHeight(FontFamily.GenericSerif, FontStyle.Regular, (int)tileSize.Height);

            positionLookup = new Point[boardSize.Width, boardSize.Height];

            for (int h = 0; h < boardSize.Height; h++)
            {
                for (int i = 0; i < boardSize.Width; i++)
                {
                    positionLookup[i, h] = new Point((int)(i * (gapSize.Width + tileSize.Width) + topLeft.X),
                                                     (int)(h * (gapSize.Height + tileSize.Height) + topLeft.Y));
                }
            }
            this.boardSize = boardSize;
        }