Esempio n. 1
0
        public void ConfiguringMatrix(int size, float matrixScale, float tileScale, Point screenSize, TileFactory tileFactory)
        {
            if (matrixScale > 1 || matrixScale < 0.5)
            {
                throw new System.ArgumentException("Margin must be between 1 and 0,5.");
            }

            int minScreenSide = Math.Min(screenSize.X, screenSize.Y);

            CellSize = Convert.ToInt32((minScreenSide * matrixScale) / size);

            // We need tile for get his size.
            var defaultTile = tileFactory.CreateRandomTile(new Cell(0, 0));

            // Calculate and set scale for tiles.
            tileFactory.TileScale = ((float)CellSize / (float)defaultTile.Size) * (tileScale);

            this.tileFactory = tileFactory;
            this.tileFactory.tileDestroying += OnTileDestroying;

            Rows    = size;
            Columns = size;

            data = new Tile[Rows, Columns];

            HeightIndent = (screenSize.Y - Rows * CellSize) / 2;
            WidthIndent  = (screenSize.X - Columns * CellSize) / 2;

            State = new GenerateState(this);
        }
Esempio n. 2
0
 /// <param name="size"> Rows or columns count. Matrix is always a cube. </param>
 /// <param name="matrixScale">
 /// Scale relative to the smallest side of the game screen.
 /// For example, if Scale = 1 then the side of the matrix = the smallest side of the screen.
 /// If you need to indent 5% (relative to the smallest side) from the near side of the screen, then set Scalee to 0.9f
 /// </param>
 /// <param name="tileScale">
 /// Tile scale relative to the matrix cell. For example, if scale = 1, then the tile will occupy the entire cell.
 /// </param>
 /// <param name="screenSize"> Height and width screen. Needed for display matrix on center and matrix resize. </param>
 /// <param name="tileFactory"> Factory for creates tiles. </param>
 public Matrix(int size, float matrixScale, float tileScale, Point screenSize, TileFactory tileFactory)
 {
     ConfiguringMatrix(size, matrixScale, tileScale, screenSize, tileFactory);
 }