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); }
public void ChangeState(MatrixState state) { if (!(State is EmptyState)) { State.StateEnd(); State = state; State.StateStart(); } }
public SwapState(Matrix matrix, MatrixState oldState) : base(matrix) { this.oldState = oldState; Swap(matrix.selectedCellStart, matrix.selectedCellEnd); }
public GenerateState(Matrix matrix, MatrixState oldState) : base(matrix) { Generate(); }
public IdleState(Matrix matrix, MatrixState oldState) : base(matrix) { matrix.selectedCellStart = null; matrix.selectedCellEnd = null; }